item_binding(物品绑定)
文件位置:data/<namespace>/mxt/item_binding/<path>.json
用途:现有物品到行为数组的绑定。
| 字段 | 类型 | 默认 | 说明 |
|---|---|---|---|
items | ItemMatcher | 必填 | 物品 ID、标签或混合数组。 |
actions | List<EntityAction> | [] | 食用完成或绑定事件执行的行为数组。 |
quality_group | Tag<item_quality> | 无 | 物品允许使用的品质组。 |
conditions | EntityCondition[] | [] | 绑定使用条件;每项可以是内联条件,或带翻译键 description 的 {condition, description} 对象。带描述的条件会在 Tooltip 中以绿色 ✓ 或红色 ✗ 标记结果。 |
绑定表只匹配现有物品,不负责创建物品。weapon_binding、pill_binding 和 technique_binding 的字段互不混用;武器拥有伤害、攻击速度、属性和攻击/使用/Tick 行为。
json
{
"items": ["minecraft:iron_sword", "#minecraft:swords"],
"actions": [{"type": "mxt:grant_spirit_root", "spirit_root": "mxt:fire_root"}],
"conditions": [
{"type": "mxt:always_true"},
{
"condition": {"type": "mxt:realm", "realm": "example:foundation"},
"description": "condition.example.foundation_required"
}
]
}绑定表的 conditions 中可以直接填写 EntityCondition,也可以填写带翻译键 description 的对象。所有条件都必须满足;带描述的条件会在物品 Tooltip 中显示绿色 ✓ 或红色 ✗,描述文字保持普通样式。
灵根和体质的持有判定与增删都是数据包原语:mxt:has_spirit_root / mxt:has_physique 用于条件,mxt:grant_spirit_root / mxt:remove_spirit_root / mxt:grant_physique / mxt:remove_physique 用于行为。例如体质丹只对已有火灵根的玩家生效,并把先决灵根换成水灵根:
json
{
"items": "kubejs:root_switching_pill",
"conditions": [
{
"condition": {"type": "mxt:has_spirit_root", "spirit_root": "mxt:fire_root"},
"description": "condition.example.requires_fire_root"
}
],
"actions": [
{"type": "mxt:remove_spirit_root", "spirit_root": "mxt:fire_root"},
{"type": "mxt:grant_spirit_root", "spirit_root": "mxt:water_root"}
]
}item_quality 定义品质内容,品质组使用原版标签组织顺序,物品通过 quality_group 引用品质序列。currency 为物品定义货币价值,unavailable_when 是包含 condition 和 reason 的 ItemCondition 数组。