Iron Chest(铁箱子)
基本信息
| 属性 | 值 |
|---|---|
| 注册名 | IronChest:BlockIronChest @ metadata 0 |
| metadata 来源 | IronChestType.IRON.ordinal() |
| 显示名 | tile.ironchest:IRON.name = Iron Chest |
| 枚举常量 | IRON |
| TileEntity | cpw.mods.ironchest.TileEntityIronChest(基类本身,不是专属子类) |
| 硬度 | 3.0F(与所有变体相同) |
| 爆炸抗性 | 否(resistance = 0) |
| 容量 | 54(size = 54) |
| 槽位形状 | getRowCount() = 54 / 9 = 6 行 × getRowLength() = 9 列 |
| 物品栏堆叠上限 | 64(getInventoryStackLimit()) |
| GUI 尺寸 | 184 × 202(GUIChest.GUI.IRON),贴图 ironchest:textures/gui/ironcontainer.png |
| 箱子等级 | tier = 2 |
| 材质 | ingotIron、ingotRefinedIron(两个,故每条箱子配方都会注册 2 份) |
| 物品过滤 | 无(itemFilter = null,任何物品可放入) |
| 是否配置可关 | 否(isEnabled() 对 IRON 恒返回 true) |
容量同级对比
IRON 是第一个有 9 列宽度的箱子(rowLength = 9),也是升级链上唯一"从 5×9 直接跳到 6×9"的档位。它比 Copper Chest 大 9 格(54 vs 45)——铜箱子虽然 tier 更低(1 < 2),但容量只有 5 行,是全表唯一的"等级与容量倒挂"档。
rowLength 从 IRON 到 Gold Chest 一直是 9;只有 Diamond Chest 及 108 格以上的箱子才切成 12 列。
配方
IRON 是全枚举中唯一 recipeDirect 走 else 分支的箱子。IronChestType.generateRecipesForType:
Object[] curTiers = getRegistredChestsByTier(typ, typ.tier, typ.resistance - 1); // tier=2, resistance-1=-1
if (curTiers.length > 1) { /* 逐个 curTier 生成,P = curTier */ }
else { addRecipe(chest, ..., 'm', mainMaterial, 'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian); }
getRegistredChestsByTier(IRON, 2, -1) 只返回 IRON 自己,长度为 1,走 else 分支——而 recipeDirect = "mGmGPGmGm" 切成三行是 mGm / GPG / mGm,正中心是 P,else 分支没有传 'P' 键。源码级观察:这条配方的 3×3 中心格没有对应材料。
[!NOTE] 以上配方路径只在 未加载 GTNH 时执行(
IronChest.isGTNHLoaded为 false)。在 GTNH(Loader.isModLoaded("dreamcraft"))上本 mod 一条合成配方都不注册,全部交给 DreamCraft/GT。
IRON 的 recipeUpgradeOneTier = "mmmmPmmmm"(mmm / mPm / mmm)本应从 tier 1(铜箱子)升级,但 IRON.tier = 2 时 getRegistredChestsByTier(IRON, 1, 0) 返回的仍是 tier == 2 的 IRON 自身,因此这条 P 路径同样不会生成有效配方。实际上铁箱子的正规获取途径是升级器 Iron to Gold Chest Upgrade 的来源端,以及 Wood to Iron Chest Upgrade。
升级去向
| 升级器 | 目标 | 配方形态 |
|---|---|---|
| Iron to Gold Chest Upgrade | Gold Chest | mmm / msm / mmm |
| Iron to Steel Chest Upgrade | Steel Chest | mGm / GsG / mGm |
| Iron to Silver Chest Upgrade | Silver Chest | mGm / GsG / mGm |
| Copper to Iron Chest Upgrade | 本箱子(来源是 Copper Chest) | mGm / GsG / mGm |
| Wood to Iron Chest Upgrade | 本箱子(来源是原版木箱子) | mmm / msm / mmm |
升级时的物品流转
TileEntityIronChest.applyUpgradeItem(TileEntityIronChest.java:339):
numUsingPlayers > 0→ 返回null(有人开着 GUI 时不能升级)。canUpgrade(this.getType())不匹配 → 返回null。- 用目标 metadata 反射建新 TE,
System.arraycopy把min(新容量, 旧容量)个格子搬过去。 dropContent(新容量, this, ...)把装不下的剩余物品散落在世界里。- 新 TE 继承
facing,并重置ticksSinceSync = -1强制重发描述包。
铁箱子容量 54 < 目标容量,所以向上升级时不会掉任何东西。
NBT 字段
| 字段 | 类型 | 说明 |
|---|---|---|
Items |
NBTTagList(元素为 TAG_Compound) |
物品栏;每个元素含 Slot(byte,下标)+ 原版 ItemStack NBT |
facing |
byte | 箱子朝向(2/3/4/5),由 onBlockPlacedBy 写入 |
id / x / y / z |
— | 继承自 TileEntity |
readFromNBT 读取时会 new ItemStack[getSizeInventory()] 重建数组,并按 Slot & 0xff 越界检查。
渲染与图标
图标 ironchest:iron_top / iron_front / iron_side;模型贴图 ironchest:textures/model/ironchest.png。
不透明(isTransparent() 仅对 CRYSTAL 返回 true),不显示内部物品。
相关条目
- Iron Chest 方块 - 宿主方块与 metadata 机制
- ItemIronChest - 物品形态
- ItemIronChest - 物品形态;GUI 容器为
ContainerIronChest(@ChestContainer(isLargeChest = true),getNumColumns()返回本类型的getRowLength())