一个简单的IO平衡思路#2
Open
yansunsky wants to merge 2 commits into
Open
Conversation
2.启动棒可以用于还原工厂 3.添加黑名单机制,黑名单方块无法评估
- 新增配置项 EnableFactoryRevert (默认 false,禁止启动棒将工厂还原为空间方块) - 防止物品复制Bug的同时不破坏评估系统的正常工作 - 后续根据快照修复进度重新开启
link-fgfgui
requested changes
Jun 14, 2026
link-fgfgui
left a comment
Owner
There was a problem hiding this comment.
核心问题在于扫库存是没有通用办法的
不过检测到禁止的方块选择不进行评估而不是破坏方块后继续评估的逻辑是OK的
此PR包含内容过多,比如解包工厂方块,黑名单模组id,扫描库存并修正等,建议每个内容单独提PR,具体怎么分开可以问ai
| public InventorySnapshot inventoryEnd; | ||
|
|
||
| // 原机器的 neoforge:attachments(含 machine_color),由 createMachine 从 EvaluatorBlockEntity 读取 | ||
| public CompoundTag originalAttachments; |
Owner
There was a problem hiding this comment.
如果要存,不应该存储在这里,放这里不会持久化,一旦重开存档就丢失
|
|
||
| // 扫 IItemHandler | ||
| for (Direction dir : Direction.values()) { | ||
| IItemHandler itemHandler = compactWorld.getCapability(Capabilities.ItemHandler.BLOCK, pos, dir); |
Owner
There was a problem hiding this comment.
在模拟这种等级的要求下,NeoForge的Capability系统不能保证提供真实的信息
Comment on lines
+320
to
+322
| Set<IItemHandler> seenItemHandlers = Collections.newSetFromMap(new IdentityHashMap<>()); | ||
| Set<IFluidHandler> seenFluidHandlers = Collections.newSetFromMap(new IdentityHashMap<>()); | ||
| Set<IEnergyStorage> seenEnergyHandlers = Collections.newSetFromMap(new IdentityHashMap<>()); |
Owner
There was a problem hiding this comment.
这一整块试图对IItemHandler去重的逻辑都不可靠
| public class EvaluatorBlockEntity extends RoomCodeBlockEntity { | ||
| // 原机器方块信息,用于评估失败时还原 | ||
| private ResourceLocation originalMachineBlock; | ||
| private CompoundTag savedOriginalNbt; // 原 BE 的完整 NBT(含 data components) |
Owner
There was a problem hiding this comment.
目前没有存完整nbt的意义,原BE里只有颜色和RoomCode两个数据,只要RoomCode对应存在,还原的方块就能正常使用,只是颜色会丢失。如果要存颜色,直接写存颜色的代码
|
|
||
| public class EvaluatorBlockEntity extends RoomCodeBlockEntity { | ||
| // 原机器方块信息,用于评估失败时还原 | ||
| private ResourceLocation originalMachineBlock; |
Comment on lines
+332
to
+334
| for (int x = startX; x <= endX; x++) { | ||
| for (int y = startY; y <= endY; y++) { | ||
| for (int z = startZ; z <= endZ; z++) { |
| outputData.put(energyKey, outputData.get(energyKey) * ratio); | ||
| } | ||
| } | ||
|
|
| } | ||
| } | ||
|
|
||
| // ========== 工厂方块 → 还原为紧凑空间机器 ========== |
Comment on lines
+443
to
+446
| long s0Count = s0.items().getOrDefault(id, 0L); | ||
| long s1Count = s1.items().getOrDefault(id, 0L); | ||
| long totalO = machine.totalOutput.getOrDefault(id, 0L); | ||
| long totalI = machine.totalInput.getOrDefault(id, 0L); |
| ServerLevel compactWorld = overworldLevel.getServer().getLevel(CompactDimension.LEVEL_KEY); | ||
| if (compactWorld == null) return CreateResult.ABORTED_SUSPICIOUS_BLOCKS; | ||
|
|
||
| // 必须先生成 UUID,再 loadRoom(forceRoom 需要 UUID 来强制加载区块) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
通过评估前后统计容器内物品的变化来规避容器欺骗。