概述
Sable Assembly Fix 修复了一个物品复制漏洞,该漏洞在 Sable 组装/拆解过程中发生,针对未实现 Clearable 接口的方块实体。
问题所在
Sable 的 SubLevelAssemblyHelper.moveBlocks() 会在组装过程中对每个方块实体调用 Clearable.tryClear()。问题在于:
- 对于实现了
Clearable 的方块实体(例如箱子、漏斗)—— 工作正常,内容被正确清除
- 对于未实现
Clearable 的方块实体(例如 TableCloth、机械臂、弹出器等)—— tryClear() 无效,没有任何操作
- 方块被销毁,其物品掉落至世界中,但包含物品库存的 NBT 数据仍然存在
- 当方块在子层级中重新创建时,NBT 中的物品数据会被重新读取
- 结果:相同的物品既存在于地面,又存在于方块内部 —— 导致物品复制
触发此漏洞非常简单:
只需在飞船的物理模式和方块模式之间切换(反之亦然)—— 每次转换都会触发组装/拆解,从而复制飞船上任何非 Clearable 方块实体的内容。无需消耗大量资源或进行复杂设置。
工作原理
单个 @Redirect mixin 拦截了 SubLevelAssemblyHelper.moveBlocks() 内部的 Clearable.tryClear() 调用:
- 如果方块实体实现了
Clearable → 正常通过,无干预
- 如果方块实体未实现
Clearable → 调用 level.removeBlockEntity(pos) 完全移除该方块实体,防止其掉落任何内容
受影响的方块实体(Create + Addons)
| 方块实体 |
每次复制的物品数量 |
| TableCloth |
最多 4 个 |
| Mechanical Arm |
整个手持堆叠(例如一次性 64 个物品) |
此外,任何具有库存但未实现 Clearable 的模组方块实体也会受影响。
注意: 机械臂的情况尤为严重 —— 它会在一次操作中复制整个手持堆叠。如果机械臂正拿着满堆叠的 64 个物品,你将在每次组装/拆解循环中得到 64 个复制物品。
任何具有库存但未实现 Clearable 的模组方块实体也会受到影响。
配置
系统包含一个白名单机制。配置文件 config/sableassemblyfix/whitelist.json 会在首次启动时自动创建。
将方块实体 ID 添加到白名单中以跳过修复(例如,如果某个模组自行处理 Clearable)。需要重启游戏以重新加载配置。
依赖项
- NeoForge >=21.1.228
- Sable >=2.0
- Create: Aeronautics >=1.0.2
许可证
MIT
Overview
Sable Assembly Fix fixes an item duplication bug that occurs during Sable assembly/disassembly for block entities that do not implement the Clearable interface.
The Problem
Sable's SubLevelAssemblyHelper.moveBlocks() calls Clearable.tryClear() on every block entity during the assembly process. The issue is:
- For block entities that implement Clearable (e.g. chests, hoppers) — works fine, contents are properly cleared
- For block entities that do NOT implement Clearable (e.g. TableCloth, Mechanical Arm, Ejector, etc.) — tryClear() is a no-op, nothing happens
- The block is destroyed and its items drop into the world, but the NBT data containing the item inventory is still there
- When the block is recreated in the sub-level, the NBT items are read back
- Result: the same items exist both on the ground and inside the block — item duplication
Triggering this bug is trivially cheap:
simply toggle the ship between physics mode and block mode (or vice versa) — each transition triggers assembly/disassembly, which duplicates the contents of any non-Clearable block entity on the ship. No expensive resources or complex setup required.
How It Works
A single @Redirect mixin intercepts the Clearable.tryClear() call inside SubLevelAssemblyHelper.moveBlocks() :
- If the block entity implements Clearable → passes through normally, no intervention
- If the block entity does not implement Clearable → calls level.removeBlockEntity(pos) to remove the block entity entirely, preventing it from dropping any contents
Affected Block Entities (Create + Addons)
| Block Entity |
Items per dupe |
| TableCloth |
up to 4 |
| Mechanical Arm |
entire held stack (e.g. 64 items at once) |
Plus any modded BE with inventory that doesn't implement Clearable.
Note: The Mechanical Arm is especially severe — it duplicates the entire held stack in one operation. If the arm is holding a full stack of 64 items, you get 64 duplicated items per assembly/disassembly cycle.
Any modded block entity with an inventory that doesn't implement Clearable is also affected.
Configuration
A whitelist system is included. The config file config/sableassemblyfix/whitelist.json is automatically created on first launch.
Add block entity IDs to the whitelist to skip the fix (e.g. if a mod handles Clearable on its own). Requires a game restart to reload.
Dependencies
- NeoForge >=21.1.228
- Sable >=2.0
- Create: Aeronautics >=1.0.2
License
MIT
评论 0
登录后参与评分
还没有评论,来抢沙发吧