跳到主要内容

✅ 枚举条件型

概述

先计算物品堆叠内给定的一个枚举属性,游戏会使用枚举属性值对应的物品模型映射。如果没有匹配的枚举值,则使用回落物品模型映射。如果此项不存在,则使用无效模型。

items:
demo:crossbow:
material: crossbow
model:
type: minecraft:select
property: minecraft:charge_type
cases:
- when: arrow
model:
type: minecraft:model
path: minecraft:item/custom/crossbow_arrow
- when: rocket
model:
type: minecraft:model
path: minecraft:item/custom/crossbow_firework
fallback:
type: minecraft:model
path: minecraft:item/custom/crossbow_standby

字段

字段类型必需默认值说明
typestringminecraft:select
propertystring枚举属性类型(见下方)
caseslist{when, model} 配对的列表
fallbackmodel无效模型回落物品模型映射,无匹配时使用
transformationobject物品模型变换(26.1+)

每个分支:

字段类型说明
whenstring / list要匹配的值(区分大小写)
modelmodel属性等于此值时使用的模型

属性

无额外字段

属性返回值可能取值
minecraft:charge_typecharged_projectiles 中的弹射物类型nonearrowrocket
minecraft:context_dimension上下文实体所在维度的 ID任意维度 ID(如 minecraft:overworld
minecraft:context_entity_type持有物品的实体类型任意实体类型 ID
minecraft:display_context物品当前渲染位置nonethirdperson_lefthandthirdperson_righthandfirstperson_lefthandfirstperson_righthandheadguigroundfixedon_shelf
minecraft:main_hand玩家的主手leftright
minecraft:trim_materialminecraft:trim 组件中的 material 字段任意盔甲纹饰材料 ID

minecraft:block_state

读取 minecraft:block_state 组件中的属性。

property: minecraft:block_state
block_state_property: facing
字段类型说明
block_state_propertystring方块状态属性键

minecraft:component(1.21.5+)

返回物品堆叠上某个组件的值。

property: minecraft:component
component: minecraft:unbreakable
字段类型说明
componentstring命名空间组件 ID

minecraft:custom_model_data

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

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

minecraft:local_time

返回按 ICU 模式格式化的当前时间。每秒更新一次。

property: minecraft:local_time
pattern: "HH:mm:ss"
locale: "zh_CN"
time_zone: "GMT+8:00"
字段类型默认值说明
patternstringICU 日期/时间格式模式
localestring""(根)格式化所用的地区
time_zonestring客户端时区时区 ID