1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-07-26 05:42:56 +00:00

Replace direct equality with InventoryUtil.areItemsEqual

Some IItemHandler.insertItem implementations clone the item, so we must
check whether the object is equal instead.

Fixes #340
This commit is contained in:
SquidDev 2017-06-28 22:08:10 +01:00
parent 93d1facbab
commit c9a3bcb68b

View File

@ -163,13 +163,13 @@ public class InventoryUtil
} }
// Inspect the slots in order and try to find empty or stackable slots // Inspect the slots in order and try to find empty or stackable slots
ItemStack remainder = stack; ItemStack remainder = stack.copy();
for( int slot : slots ) for( int slot : slots )
{ {
if( remainder == null ) break; if( remainder == null ) break;
remainder = inventory.insertItem( slot, remainder, false ); remainder = inventory.insertItem( slot, remainder, false );
} }
return remainder; return areItemsEqual( stack, remainder ) ? stack : remainder;
} }
private static ItemStack takeItems( int count, IItemHandler inventory, int[] slots ) private static ItemStack takeItems( int count, IItemHandler inventory, int[] slots )