Integrated Tunnels

Integrated Tunnels

53M Downloads

Item dupe bug

Naosyth opened this issue ยท 7 comments

commented

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:

  1. Place a block down that can pull from adjacent inventories. A Thermal Expansion Item Allocator works well for this.
  2. Set one side of the allocator to push an pull
  3. Enable auto input and output (not necessary to set both, you get slightly different dupe behavior depending on how it's set)
  4. Set the allocator's input limit higher than its output limit
  5. Place an integrated tunnels item interface on the side you configured (all you need is an interface, not even a cable)
  6. Place a single stackable item in the allocator
  7. Profit

GIF of the process:
dupe-bug-simplified

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
commented

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

GitHub
Forge Capabilities that can be shared by multiple mods. - CyclopsMC/CommonCapabilities
commented

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

Streamable
Check out this video on Streamable using your phone, tablet or desktop.
commented

Thanks for checking, let's leave this issue open then.

commented

It appears the dupe still exists, albeit in a slightly different form:
dupe-bug

With a single interface, it didn't dupe anything, but once I put multiple interfaces on the same item allocator, it started duping items again.

commented

Hmm, thanks for letting me know again.

commented

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:

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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.

GitHub
Contribute to CoFH/ThermalExpansion development by creating an account on GitHub.
GitHub
Contribute to CoFH/CoFHCore development by creating an account on GitHub.
GitHub
Contribute to CoFH/CoFHCore development by creating an account on GitHub.
GitHub
Contribute to CoFH/CoFHCore development by creating an account on GitHub.
commented

Looks like this won't be fixed in CoFH 1.12 anymore. Fingers crossed for 1.15.