ContainerPlayerExpanded
基本信息
| 属性 | 值 |
|---|---|
| 路径 | baubles.common.container.ContainerPlayerExpanded |
| 类型 | class |
| 父类 | Container |
| 包名 | baubles.common.container |
| 对应 GUI ID | Baubles.GUI = 0 |
字段
| 字段 | 类型 | 说明 |
|---|---|---|
craftMatrix |
InventoryCrafting(2, 2) |
2×2 工作台矩阵 |
craftResult |
InventoryCraftResult |
合成结果槽 |
baubles |
InventoryBaubles |
关联的玩家饰品栏 |
thePlayer |
EntityPlayer |
持有此 container 的玩家 |
slotsAdded |
int |
已添加的 slot 计数(用于定位 bauble 首槽索引) |
baubleFirstSlotIndex |
int |
bauble 槽在 container 中的首索引 |
baubleSlotCount |
int |
bauble 槽数 |
构造时容器布局
布局按 BaublesConfig.useOldGuiRendering 切换:
| 顺序 | 内容 | 新版坐标 / 旧版坐标 |
|---|---|---|
| 0 | 合成结果槽(仅新版) | (144, 36) |
| 1…4 | 2×2 合成矩阵(仅新版) | (88 + j18, 26 + i18) |
| 5…8 | 4 个盔甲槽(堆叠上限 1,限定 armorType) | (8, 8 + i*18) |
| 9… | bauble 槽位,按 BaubleExpandedSlots.getCurrentSlotAssignments 顺序;新版按列排(左侧侧栏),旧版按 4 列网格排(嵌入主面板) | — |
| 后续 | 27 个背包槽(3×9) | |
| 最后 | 9 个快捷栏槽 |
关键方法
| 方法 | 行为 |
|---|---|
onCraftMatrixChanged(新版启用) |
实时根据 craftMatrix 更新 craftResult |
onContainerClosed |
调用 super;若 baubles 还关联本 container 则解绑;新版下如果 craftMatrix 还有残留物则回填到玩家背包;非客户端下调用 PlayerHandler.setPlayerBaubles |
addSlotToContainer |
覆写以计数 slotsAdded,便于定位 bauble 首索引 |
getBaubleSlot(int) |
从 inventorySlots 中按 baubleFirstSlotIndex + i 取 SlotBauble |
scrollTo(float offset)(新版启用) |
当槽位超出 maxColumns*8 行时,按 offset 平移每行 yDisplayPosition;不可见的行 y=-2000 |
getColumns |
找到列数 cols ∈ [1, maxColumns] 使得 (activeSlots + cols - 1) / cols <= 8 |
canScroll |
activeSlots > maxColumns * 8 && !useOldGuiRendering |
transferStackInSlot(player, slotIndex) |
shift-click 路由(详见下表) |
tryMergeIntoBaubleSlotsByPriority(itemTypes, priority) |
按指定优先级把物品尝试放入 bauble 槽位 |
getBestMatchPriority(itemTypes, slotType) |
返回 2 表示直接匹配/通用,返回 1 表示 universal 覆盖匹配,返回 0 表示不匹配 |
mergeItemStack |
在指定索引范围内尝试堆叠或放入空槽(注意:sourceSlot 是 SlotBauble 时调用 unequipBauble,目前是空实现) |
Shift-click 路由
| 来源 | 路由 |
|---|---|
| 合成结果槽 (slotIndex=0) | 移到背包/快捷栏 |
| 合成矩阵(slotIndex 1…4) | 移到背包/快捷栏 |
| bauble 槽位 | 移到背包/快捷栏,优先尝试堆叠 |
| 盔甲槽 | 直接装备(按 armorType) |
| 普通物品且可装备 | 尝试 bauble 槽位优先级 2,再尝试优先级 1 |
| 背包槽 | 移到快捷栏 |
| 快捷栏槽 | 移到背包 |
| 其他 | 尝试移到背包/快捷栏 |
相关条目
- BaubleExpandedSlots - 提供槽位分配
- InventoryBaubles
- SlotBauble
- GuiPlayerExpanded - 配套 GUI
- PlayerHandler - container 关闭时保存
- BaublesConfig -
useOldGuiRendering、showUnusedSlots、maxColumns等