TagPlayerEquipment

10 组装备 tag × 5 槽位

基本信息

属性 值
路径 com.github.lunatrius.ingameinfo.tag.TagPlayerEquipment
行数 206
分类 playerequipment
构造调用数 50(10 类 × 5 槽位)

两张映射表(:19)

public static final int[]    SLOTS  = new int[] { -1, 3, 2, 1, 0 };
public static final String[] TYPES  = new String[] { "equipped", "helmet", "chestplate", "leggings", "boots" };

索引与槽位号刻意反向:

索引 i TYPES[i](tag 前缀) SLOTS[i] 含义
0 equipped -1 主手手持物
1 helmet 3 盔甲槽 3
2 chestplate 2 盔甲槽 2
3 leggings 1 盔甲槽 1
4 boots 0 盔甲槽 0

⚠️ 原版 EntityPlayer.getCurrentItemArmour(int) 的槽位约定是 0=靴 1=腿 2=胸 3=头,所以 SLOTS 用 3,2,1,0 反转以匹配显示顺序。 equipped 用 -1 作为哨兵值,表示「不查盔甲槽,改查主手」。

生成的 50 个 tag(:193-204)

每个 TYPES[i] 前缀拼 10 个后缀:

后缀 内部类 取值
name Name 显示名
uniquename UniqueName 唯一名
damage Damage 已损耐久
maxdamage MaximumDamage 最大耐久
damageleft DamageLeft 剩余耐久
itemmeta ItemMeta meta 值
itemid ItemId 数字 ID
quantity Quantity 堆叠数量
icon Icon(large=false) 16×16 图标
largeicon Icon(large=true) 大号图标

展开后共 50 个 tag 名,例如 helmetname / chestplatemaxdamage / bootsdamageleft / equippedquantity / legginglargeicon。

两个 Icon 共享同一类

TagRegistry.INSTANCE.register(new Icon(SLOTS[i], false).setName(TYPES[i] + "icon"));
TagRegistry.INSTANCE.register(new Icon(SLOTS[i], true).setName(TYPES[i] + "largeicon"));

⚠️ 两个都是内部类 Icon,只靠构造参数 large 区分。 ValueRegistry 那种「类 → 注册名」反查表 (classStringMap)若作用于此,后注册的 largeicon 会覆盖 icon。 本 mod 的 TagPlayerPotion 也用同样写法, 但 tag 与 value 是两套独立注册表,此处实际不受影响。

空槽位行为

SLOTS[0] = -1 与未装备的盔甲槽都会让对应 getValue() 返回空串, 配置里可用 ValueLogic 的 if 判空后再输出 (默认配置里 <if><var>daytime</var>… 就是这个用法)。

相关