CellInventory(appeng.me.storage.CellInventory)

基本信息

属性 值
源码 appeng/me/storage/CellInventory.java
类声明行号 46
类型 public abstract class
实现接口 appeng.api.storage.ICellInventory<StackType>
泛型约束 StackType extends IAEStack<StackType>
构造器 :65,两个参数 (ItemStack o, ISaveProvider container),可能抛 AppEngException

职责

cell 的数据本体。它持有物品栈(ItemStack)与持久化提供者, 负责:NBT 读写、字节记账、注入 / 抽取时维护内容表。

⚠️ 容量(kilobytes)不在本类。容量写在外壳物品上, 由 ApiItems 传给 new ItemBasicStorageCell(MaterialType.Cell1kPart, 1)。 见 材料条目:cell1k-part。

静态工厂

方法 行号 说明
isCell(ItemStack) 149 判断物品栈是否为 cell
getCell(ItemStack, ISaveProvider, IAEStackType<T>) 163 造出对应的 IMEInventoryHandler<?>

三个 abstract 方法

方法 行号 子类实现
readStack(NBTTagCompound) 409 ItemCellInventory:18 / FluidCellInventory:18
getStackTypeTag() 633 ItemCellInventory:23 / FluidCellInventory:23
getStackCountTag() 635 ItemCellInventory:28 / FluidCellInventory:28

三个都是 protected abstract。物品与流体 cell 的差别只在 NBT tag 名, 逻辑完全共用。

核心方法

方法 行号
injectItems(StackType, Actionable, BaseActionSource) 173
extractItems(StackType, Actionable, BaseActionSource) 285
saveChanges() 330,protected
loadCellStacks() 384,protected
getAvailableItems(IItemList<StackType>, int) 412
getAvailableItem(StackType, int) 421
getAvailableItems(IItemList, int, Optional<Predicate<T>>) 437
getItemStack() 445
getIdleDrain() 450

getIdleDrain()(:450)是 cell 的空闲能耗——每个 cell 都在耗电, 即使不装东西。

四个 ICellInventory 实现分支

类 源文件:行 继承 语义
ItemCellInventory :11 extends CellInventory<IAEItemStack> 物品 cell
FluidCellInventory :11 extends CellInventory<IAEFluidStack> 流体 cell
CreativeCellInventory<T> CreativeCellInventory.java:38 无父类,直接 implements ICellInventory 创造模式
VoidCellInventory<T> VoidCellInventory.java:25 无父类,直接 implements ICellInventory 作废 cell

后两个不继承 CellInventory,因为它们没有 ItemStack 外壳可记账 (创造 cell 的内容是配置的清单,作废 cell 根本不留内容)。

注册关系

普通 cell 的 handler 是注册表内置的(core/Registration.java:556 注释原文: BasicCellHandler is built into the Registry, so there is no need to register it here.), 只有两个特例显式注册:

特例 注册位置
CreativeCellHandler core/Registration.java:557
VoidCellHandler core/Registration.java:558

开关

cell 相关工作受 AEFeature.StorageCells 门控 (AEFeature.StorageCells)。

相关条目