Item dupe bug
Naosyth opened this issue ยท 7 comments
Issue type:
- ๐ Bug
Short description:
Item interfaces attached to blocks that are able to automatically pull from adjacent blocks can dupe items.
Steps to reproduce the problem:
- Place a block down that can pull from adjacent inventories. A Thermal Expansion Item Allocator works well for this.
- Set one side of the allocator to push an pull
- Enable auto input and output (not necessary to set both, you get slightly different dupe behavior depending on how it's set)
- Set the allocator's input limit higher than its output limit
- Place an integrated tunnels item interface on the side you configured (all you need is an interface, not even a cable)
- Place a single stackable item in the allocator
- Profit
I don't have any other mods that provide auto input/output in this pack, so I can't test against another mod to verify 100% that this is Integrated Dynamic's fault, but I was not able to get the item allocator to duplicate its content by auto pulling or pushing to anything other than an item interface.
Expected behaviour:
Items should not be duplicated when pushing/pulling via an item interface
Versions:
- Integrated Dynamics: 1.12.2-1.0.14
- Integrated Crafting: 1.12.2-1.0.7
- Integrated Terminals: 1.12.2-1.0.8
- Integrated Tunnels: 1.12.2-1.6.9
- Thermal Expansion: 5.5.3.41
- Minecraft: 1.12.2
- Forge: 14.23.5.2837
That's very bad.
It's possible though that my recent change in Common Capabilities may have fixed this problem. Could you try the latest dev build (see readme) to see if this fixes the problem for you? https://github.com/CyclopsMC/CommonCapabilities
Forge Capabilities that can be shared by multiple mods. - CyclopsMC/CommonCapabilities
The dev build fixed that particular dupe, but I found a slight variation on it that still worked: https://streamable.com/2nhn3
By attaching a player simulator, I was able to dupe or delete items depending on if the side facing the interface was set as an input or an output
StreamableCheck out this video on Streamable using your phone, tablet or desktop.
Ok, so I've been digging around a bit, and it looks like this is an issue with Thermal Expansion.
Since their issue tracker seems to be closed, let me ping @KingLemming here directly to see if this indeed correct.
So what I think is going wrong here is this:
- The item allocator calls
extractItem
on each side: https://github.com/CoFH/ThermalExpansion/blob/1.12/src/main/java/cofh/thermalexpansion/block/device/TileItemBuffer.java#L128 - Before any extraction is being done, the stack inside the current allocator slot is being stored (and copied): https://github.com/CoFH/CoFHCore/blob/1.12/src/main/java/cofh/core/block/TileInventory.java#L32
- Internally, this allocator will call
extractItem
on IT's item interface: https://github.com/CoFH/CoFHCore/blob/1.12/src/main/java/cofh/core/block/TileInventory.java#L59 - After this extraction is being done, the previously stored stack is being incremented with the extracted item: https://github.com/CoFH/CoFHCore/blob/1.12/src/main/java/cofh/core/block/TileInventory.java#L61
- Finally, the stored stack is placed again inside the inventory.
However, step 4 is the place where things are going wrong. Since step 3 extracts from the IT interface, IT will recursively extract again from the first slot inside the item allocator, which will modify the item in the first slot. However, since step 2 caches this item beforehand, and step 4 only modifies this cached item, any external changes (by IT) to this item are being ignored.
A simple solution would be to just call insertItem
in step 4 instead of modifying the cached item.
Contribute to CoFH/ThermalExpansion development by creating an account on GitHub.
Contribute to CoFH/CoFHCore development by creating an account on GitHub.
Contribute to CoFH/CoFHCore development by creating an account on GitHub.
Contribute to CoFH/CoFHCore development by creating an account on GitHub.