力量握持(Augmented Holding)
基本信息
sigil_of_augmented_holding(SigilAugmentedHolding)及其配套的
容器 / 界面 / 网络包,共 5 个类,是本 mod 唯一带自建网络通道
的子系统。
| 类 | 文件 | 作用 |
|---|---|---|
SigilAugmentedHolding |
items/sigil/holding/SigilAugmentedHolding.java |
物品本体,内嵌 8 格 库存 |
InventoryAugmentedHolding |
同目录 | 库存实现 + NBT 读写 |
ContainerAugmentedHolding |
同目录 | 服务端容器 |
GuiAugmentedHolding |
同目录 | 客户端界面 |
AHPacketHandler / AHPacketProcessor |
同目录 | 网络通道与数据包 |
注册名 sigil_of_augmented_holding 在 ModItems.init()
(ModItems.java:181)注册,不走 postInit 的软依赖分支。
数值
| 项 | 值 | 来源 |
|---|---|---|
内嵌库存大小 invSize |
8 | SigilAugmentedHolding.java:21 |
| NBT 当前符文键 | "CurrentSigil" |
:23 |
| NBT 物品列表键 | InventoryAugmentedHolding.NBT_ITEMS |
:204 |
容器列数 inventoryColumns |
9 | ContainerAugmentedHolding.java:18 |
| 玩家背包行 × 列 | 3 × 9 | :14-15 |
| 槽位 x 起点 | 8 + columnIndex * 18 |
:28 |
invSize声明为private static int(不是final), 循环上界常写成i <= invSize(:70)—— 即遍历 0…8 共 9 槽, 比声明的 8 多一格。这一格的用途在setCurrentSigil里:if (index >= invSize + 1) …,MathHelper.clamp_int(currentSigil, 0, invSize)允许currentSigil == invSize == 8,即索引 8 是「未装备符文」状态 而非一个槽位。
符文轮换
物品 NBT 用 NBT_CURRENT_SIGIL 记录当前选中的符文索引,
切换时该槽的物品被写入库存、新槽的物品被装到手上
(setCurrentSigil 逻辑)。getIcon 也读 getCurrentSigil(stack)
来决定贴图 —— 所以图标随当前符文变化。
网络通道
AHPacketHandler(BloodArsenal.java:143 处 AHPacketHandler.init() 调用):
| 项 | 值 |
|---|---|
| 通道名 | "AugmentedHolding" |
| 构造 | NetworkRegistry.INSTANCE.newSimpleChannel("AugmentedHolding") |
| 消息数 | 1 |
| 消息类 | AHPacketProcessor,discriminator = 0 |
| 方向 | Side.SERVER |
AHPacketProcessor 实现 IMessage 与
IMessageHandler<AHPacketProcessor, AHPacketProcessor>(自发自收),
载荷为两个 int:slot 与 mode。
处理时用 message.slot > -1 && message.slot < 9 校验,
只取玩家主手 9 格,越界则 itemStack 保持 null。
槽位限制
SigilAugmentedHolding 继承 EnergyItems 但不实现 ISigil
(与另外四个符文不同),因此无法作为普通符文被绑定使用。
相关条目
源码
src/main/java/com/arc/bloodarsenal/common/items/sigil/holding/(7 个.java)- 注册处:
src/main/java/com/arc/bloodarsenal/common/items/ModItems.java:181 - 通道初始化:
src/main/java/com/arc/bloodarsenal/common/BloodArsenal.java:143