跳到主要内容

⚖️ 布尔条件型

概述

先计算物品堆叠内给定的谓词,当谓词为真时选择一个物品模型映射,为假时选择另一个。

items:
demo:bow:
material: bow
model:
type: minecraft:condition
property: minecraft:using_item
on_true:
type: minecraft:model
path: minecraft:item/custom/bow_pull
on_false:
type: minecraft:model
path: minecraft:item/custom/bow

字段

字段类型必需默认值说明
typestringminecraft:condition
propertystring布尔谓词类型(见下方)
on_truemodel谓词为真时使用的模型
on_falsemodel谓词为假时使用的模型
transformationobject物品模型变换(26.1+)

谓词

无额外字段

以下谓词只需指定 property 名称,无需额外参数。

谓词触发条件
minecraft:broken物品即将损坏
minecraft:carried物品正在 GUI 槽位间被光标携带
minecraft:damaged物品可损坏且已被使用过至少一次
minecraft:extended_view玩家按住 Shift 且物品在 GUI 中渲染
minecraft:fishing_rod/cast此钓鱼竿已抛出浮漂
minecraft:selected物品在快捷栏上被选中
minecraft:using_item玩家正在使用此物品(进食、拉弓等)
minecraft:view_entity上下文实体为本地玩家(或旁观模式下的被旁观实体)
minecraft:bundle/has_selected_item收纳袋"打开"且有选中物品在 GUI 中可见

minecraft:component(1.21.5+)

使用数据组件谓词匹配物品组件。

property: minecraft:component
predicate: minecraft:damage
value:
damage: 0
字段类型说明
predicatestring组件谓词类型
valuevaries与谓词对应的值结构

minecraft:has_component

若物品上存在指定组件则返回 true

property: minecraft:has_component
component: minecraft:enchantments
ignore_default: false
字段类型默认值说明
componentstring命名空间组件 ID
ignore_defaultboolfalse将具有默认值的组件视为不存在

minecraft:keybind_down

指定按键被按住时返回 true

property: minecraft:keybind_down
keybind: key.left
字段类型说明
keybindstring按键标识符(如 key.leftkey.sprint

minecraft:custom_model_data

读取 minecraft:custom_model_data 组件中的 flags 列表。

property: minecraft:custom_model_data
index: 0
字段类型默认值说明
indexint0flags 数组中的位置