TInventory
基本信息
| 属性 | 值 |
|---|---|
| 路径 | mrtjp.core.inventory.TInventory |
| 源码 | src/main/scala/mrtjp/core/inventory/invtraits.scala |
IInventory 的实现 trait,提供整套默认行为,子类只需提供 storage。
| 成员 | 默认值 / 行为 |
|---|---|
size |
子类实现 |
name |
子类实现 |
stackLimit |
64 |
hasCustomInventoryName |
true |
isUseableByPlayer |
true(不校验任何所有权) |
isItemValidForSlot |
true(不校验) |
openInventory / closeInventory |
空 |
loadInv(tag, prefix) |
NBT 读入,prefix 默认取 name |
saveInv(tag, prefix) |
NBT 写出,prefix 默认取 name |
缺陷
isUseableByPlayer 恒返回 true 且 isItemValidForSlot 恒返回 true ——
若直接用于需要所有权校验的机器(如 ItemBlockCore.placeBlockAt 场景),
会造成任何玩家都能取走内容物。子类须显式覆写。