简体中文
占位符参考
EmakiItem 通过 PlaceholderAPI 提供的占位符与物品动作里可以引用的上下文变量如下; 占位符与变量名按原样复制即可使用
PlaceholderAPI 占位符
扩展标识符: emakiitem
前置条件: 已安装 PlaceholderAPI. 安装后 EmakiItem 自动注册以下占位符, 在 lore, 计分板或聊天格式里写入即可解析
| 占位符 | 说明 | 示例 |
|---|---|---|
%emakiitem_held_id% | 主手物品的 EmakiItem 定义 ID | shadow_blade |
%emakiitem_held_name% | 主手物品的显示名 (纯文本) | 影刃 |
%emakiitem_held_components% | 主手物品的组件 ID 列表 | minecraft:custom_name, minecraft:lore |
%emakiitem_held_components_raw% | 主手物品的原始组件字符串 | — |
%emakiitem_held_component_has_<id>% | 主手物品是否含有该组件, 返回 1 或 0 | %emakiitem_held_component_has_custom_model_data% |
%emakiitem_held_component_value_<id>% | 该组件的值字符串 | %emakiitem_held_component_value_rarity% |
%emakiitem_held_component_json_<id>% | 该组件的 JSON 输出 | %emakiitem_held_component_json_enchantments% |
%emakiitem_loaded_count% | 当前已加载的物品定义总数 | 156 |
%emakiitem_held_state_keys% | 主手物品已存在的 item state 字段名, 按字母升序用逗号连接 | charge,kills |
%emakiitem_held_state_revision% | item state 元数据的修订号 | 12 |
%emakiitem_held_state_instance% | item state 元数据的实例 ID | — |
%emakiitem_held_state_schema% | item state 元数据的 schema 版本号 | 1 |
%emakiitem_held_state_valid% | item state 元数据是否有效, 返回 1 或 0 | 1 |
%emakiitem_held_state_has_<key>% | 主手物品是否存在该 item state 字段, 返回 1 或 0 | %emakiitem_held_state_has_charge% |
%emakiitem_held_state_<key>% | 该 item state 字段的值; 字段不存在时返回空串 | %emakiitem_held_state_charge% |
组件 ID 可省略 minecraft: 命名空间
NOTE
注意重名优先级: keys, revision, instance, schema, valid 这五个名称同时也是可用的字段名. 如果物品上确实存在同名的 item state 字段, %emakiitem_held_state_<这些名称>% 会优先返回该字段的值, 而不是元数据
使用示例
yaml
item:
components:
lore:
- "<gray>物品 ID: <white>%emakiitem_held_id%</white></gray>"
- "<gray>已加载定义: <white>%emakiitem_loaded_count%</white></gray>"动作上下文变量
物品动作 (EmakiItemActionService) 触发时, 下面的变量注入 Action 上下文, 在动作参数里用 %变量名% 引用:
| 变量 | 说明 | 示例 |
|---|---|---|
%player% | 玩家名称 | Steve |
%item_id% | EmakiItem 定义 ID | shadow_blade |
%item_trigger% | 触发器名称 | right_click |
%item_name% | 物品显示名 (纯文本) | 影刃 |
部分触发器还会注入自己的变量, 例如 attack 的 %target% 和 %damage%, 完整列表见触发器; 占位符或变量解析为空时, 按下面的说明逐条排查
动作示例
yaml
actions:
right_click:
- 'send_message text="<green>%player% 使用了 %item_name%!</green>"'说明
- 玩家主手没有 EmakiItem 物品时,
held_id返回空字符串; 主手为空时held_name也返回空字符串 - 占位符请求没有玩家上下文时统一返回空字符串; 解析结果为空时先确认当前上下文里有没有玩家
loaded_count只统计items/加载的定义, 不含运行时注册的定义- 外部插件物品如果没有写入 EmakiItem PDC 标记, 无法被识别为 EmakiItem
- CoreLib 的内置上下文变量 (
%player_name%,%player_uuid%等) 在物品动作中同样可用