Building Gadgets

Building Gadgets

110M Downloads

Duplication Bug with Mekanism Mod

Cepterman opened this issue ยท 1 comments

commented

Building Gadgets Version
1.3.8

Describe the bug
When binding to the inventory of the Digital Miner from "Mekanism" it duplicates the blocks in the inventory, without using them.

To Reproduce
-Select the Bind Inventory mode
-Bind to the center top block of the Digital miner (has a yellow item port)
-Select the block you want to place
-put the block in the inventory of the digital miner
-place infinite copies of that block

Expected behavior
It should use the blocks in the inventory when placing the blocks

commented

I was playing around with the code and I think I know why the issue exists. First of all, Mekanism Miner works the way, you put items from the top and you take items from the back. It actually doesn't allow to take items from the top.

Then I found this part of code, that actually doesn't check the ItemStack after extraction...

handler.extractItem(j, matchingStack.getCount(), simulate);

And because there's only check for items in that inventory, it basically duplicates them...

So I tried to modify the code to something like this (code below), that basically checks if the extracted item is AIR and not the actual item, then do nothing.

ItemStack newStack = handler.extractItem(j, matchingStack.getCount(), simulate);
if (newStack.isEmpty() || newStack.is(Items.AIR)) {
    break;
}

So far it seems it works nicely for all gadgets that supports inventory binding. But because I'm pretty new in Minecraft Modding, I don't know if there's some possible downsides to this code modification, but I'm down to open a PR and include some other fixes I found during testing with maybe some improvements..

@Direwolf20-MC or @MichaelHillcox could I get your feedback on this since you're the owners? :)