跳到主要内容

⚖️ 条件

提示

在条件类型前添加 ! 可反转判断逻辑,例如:

type: "!permission"
permission: "craftengine.admin"

any_of

满足任意条件即可。

type: any_of
terms:
- type: xxx
- type: xxx

all_of

所有条件都必须满足。

type: all_of
terms:
- type: xxx
- type: xxx

inverted

对当前条件的结果值取反。

type: inverted
term:
type: xxx

falling_block

检测掉落物是否由下落的方块掉落

type: falling_block

survives_explosion

1/爆炸半径 的概率返回成功。需要上下文提供参数进行检测,若未提供则总是通过。

type: survives_explosion

has_item

检查是否有手持物品

type: has_item

match_item

检查手持物品。

type: match_item
id: "minecraft:iron_pickaxe"
regex: false # 是否使用正则表达式匹配
type: match_item
id:
- "minecraft:iron_pickaxe"
- "minecraft:stone_pickaxe"
regex: false # 是否使用正则表达式匹配

match_block_property

检查方块状态。

type: match_block_property
properties:
age: 3

match_block

匹配方块类型。

type: match_block
x: <arg:position.x>
y: <arg:position.y>
z: <arg:position.z>
id: minecraft:stone
regex: false

match_entity

匹配实体类型。

type: match_entity
id: minecraft:enderman
regex: false

match_furniture_variant

匹配家具变体。

type: match_furniture_variant
variants:
- wall

enchantment

检测手中物品的魔咒。

type: enchantment
predicate: minecraft:silk_touch>=1 # > >= = < <=

equipment

检查指定装备槽位的物品是否匹配配置的物品 ID 或 tag。槽位别名以及 ID/tag 之间采用 OR 逻辑。

type: equipment
slot: head # 必填; 枚举[mainhand, offhand, head, chest, legs, feet, body, saddle]
id: "minecraft:diamond_helmet" # 可选; 字符串/字符串列表; 匹配物品 ID
tag: ["my_pack:custom_tag"] # 可选; 字符串列表; 匹配 tag(与 id 为 OR 逻辑)
regex: false # 可选; 布尔; 默认值: false; id 是否使用正则匹配
# 示例:通过 ID 正则匹配
type: equipment
slot: chest
id: ["minecraft:.*_chestplate"]
regex: true
# 示例:仅通过 tag 匹配
type: equipment
slot: feet
tag: ["my_pack:fire_resistant"]

table_bonus

以魔咒等级为索引,从列表中挑选概率通过。

type: table_bonus
enchantment: minecraft:fortune
chances:
- 0.1
- 0.5
- 0.8
- 1

random

type: random
value: 0.1 # 10%

默认每次判定都独立 roll。指定 id 可让同一上下文内的多次判定共享同一次 roll:

type: random
value: 0.1
id: crit # 此上下文中所有 id 为 crit 的 random 条件使用同一次 roll

permission

检查玩家是否拥有权限

type: permission
permission: "craftengine.admin"

expression

检查表达式是否返回 true

type: expression
# https://ezylang.github.io/EvalEx/references/references.html
expression: "<papi:farming_level> >= 10"

string_equals

判断这两个值是否相等

type: string_equals
value1: "<arg:player.name>"
value2: "玩家A" # 译者注:在正常 Minecraft 服务端是不允许使用中文作为玩家名称的这里仅作为演示

string_contains

判断 value1 是否包含 value2

type: string_contains
value1: "<arg:player.name>"
value2: "A"

regex

判断 value 是否符合指定正则表达式

type: regex
value: "<arg:player.name>"
regex: "[a-Z]"

is_null

检查参数是否为空

type: is_null
argument: "player.main_hand_item"

hand

检查交互手

type: hand
hand: main_hand # off_hand

on_cooldown

检查玩家是否处于冷却时间(使用 set_cooldown 函数为玩家设置冷却)

type: on_cooldown
id: my_cooldown_id
信息

示例用法

events:
- on: right_click
functions:
- type: set_cooldown
id: test
time: 30s
- type: command
command: give <arg:player.name> minecraft:apple
conditions:
- type: "!on_cooldown"
id: test

worldguard:region

检测当前上下文中的位置是否位于WorldGuard区域内

type: worldguard:region
# 模式 1 为区域并集
# 模式 2 为区域交集
mode: 1
regions:
- A
- B

distance

检测当前上下文的玩家于上下文的位置的距离是否在范围内

type: distance
min: 0
max: 32

has_player

检测当前上下文玩家是否存在

type: has_player

has_money

检测玩家是否拥有足够的金钱(需要安装 Vault 和经济插件)

type: has_money
amount: 100 # 必填; 数字/表达式

inventory_has_item

检测当前上下文玩家背包中是否有指定物品或数量

type: inventory_has_item
id: "minecraft:iron_pickaxe"
count: 1

is_bedrock_player

检测当前上下文玩家是否为基岩版玩家

type: is_bedrock_player

test_flag

检查当前位置的权限标志

type: test_flag
flag: break # break, place, interact, open_container

js

将一个 JavaScript 函数的返回值作为条件(必须返回布尔值)。完整的脚本使用指南见 📜 脚本

type: js
script: "mypack:combo" # 必填; 字符串; 脚本 id(<命名空间>:<不含 .js 的相对路径>)
function: "canUse" # 可选; 字符串; 默认 main
# args - 可选; 列表或 map(注入为 args,或按名注入)
args:
min_level: 10
信息

更多条件即将到来...