Skip to content

feat: 输出总线支持物品过滤器(#1715) - #55

Open
alcox233 wants to merge 4 commits into
GregTech-Odyssey:gtofrom
alcox233:feat/output-bus-item-filter
Open

feat: 输出总线支持物品过滤器(#1715)#55
alcox233 wants to merge 4 commits into
GregTech-Odyssey:gtofrom
alcox233:feat/output-bus-item-filter

Conversation

@alcox233

@alcox233 alcox233 commented Jul 18, 2026

Copy link
Copy Markdown

摘要

移植 GregTechCEu 上游 Output bus filtering #4337Fix up output item bus filter #4686,实现普通输出总线物品过滤,并修复移植中发现的两个问题。

对应建议:GregTech-Odyssey/GregTech-Odyssey#1715

行为

  • 打开物品输出总线 GUI,库存网格正下方居中有过滤器槽
  • 放入物品过滤器(简易/智能/标签/矿辞等,与过滤覆盖板相同物品)
  • 通过过滤器的物品可进入总线库存(多方块输出 / 自动输出均受约束)
  • 未装过滤器时与原先一致;破坏总线时过滤器随库存一起掉落

实现

  • FilterHandler / FilterHandlers:宿主从 CoverBehavior 扩展为 IFieldDataHolder(Cover 与 Machine 均可)
  • ItemBusPartMachine:持有 filterHandler,inventory.setFilter(matchesFilter),仅 IO.OUT 显示过滤槽
  • Smart 过滤器在机器上可按总线定义名自动选模式

对上游的两处修正

  1. 破坏总线掉落过滤器:上游在 onMachineDestroyed 掉落 filterItem,本仓对应钩子是 onMachineRemoved,补上掉落(与 ConveyorCover#getAdditionalDrops 行为一致),避免过滤器凭空消失。
  2. 过滤槽布局:上游浮动坐标 (71+9r, 35+9r) 每级仅右移 9px,而库存网格每级加宽 18px——LuV(7 列)起网格追上过滤槽开始重叠,ZPM+ 完全被网格盖住不可见。改为输出总线在网格下方预留一行,过滤槽水平居中,任意等级不重叠。

测试(0.5.7 dev 实测,含服务端日志验证)

  • 过滤器插入正确到达服务端(FilterHandler.updateFilter 服务端日志确认)
  • 关闭/重开 GUI 过滤器保持(客户端同步正常)
  • 存档退出世界重进后过滤器保留(@SaveToDisk 嵌套 holder 持久化验证)
  • 扳手拆除时过滤器与库存一起掉落(服务端 onMachineRemoved 日志确认)
  • 输入总线无过滤槽、行为不变
  • LuV/ZPM+ 高等级输出总线过滤槽位置正确(布局修复后)
  • 白名单过滤约束多方块输出(逻辑与上游一致,读同一 filterItem 字段,待日常游戏验证)

🤖 Generated with Claude Code

- FilterHandler/FilterHandlers 宿主从 Cover 扩展为 IFieldDataHolder(机器可用)
- 输出总线 GUI 增加过滤器槽,仅允许匹配物品进入库存
- 无过滤器时行为与原先一致

Closes GregTech-Odyssey/GregTech-Odyssey#1715

protected NotifiableItemStackHandler createInventory(Object... args) {
return new NotifiableItemStackHandler(this, getInventorySize(), io);
return new NotifiableItemStackHandler(this, getInventorySize(), io).setFilter(this::matchesFilter);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成仅输出设置

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按批语修改:createInventory 仅在 io == IO.OUTsetFilter,输入总线不再套用过滤。

alcox233 and others added 3 commits July 19, 2026 19:01
对齐上游 CEu GregTechCEu#4686 的 onMachineDestroyed 与本仓 ConveyorCover 的
getAdditionalDrops:onMachineRemoved 清库存后补掉落 filterItem,
避免破坏机器时过滤器凭空消失。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
上游坐标 (71+9r, 35+9r) 随等级每级右移 9px,而库存网格每级加宽
18px,LuV(7列)起网格追上过滤槽开始重叠,ZPM+ 完全被网格盖住。
改为输出总线在网格下方预留一行,过滤槽水平居中,任何等级不重叠。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants