Quark Oddities

Quark Oddities

22M Downloads

Item Duplication on inventory merge (i.e. Smart-Dropoff) into full chest

CorbinSteele opened this issue ยท 1 comments

commented

Example of how to duplicate

  1. Fill a chest completely with cobblestone, except for one inventory slot.
  2. Add exactly half of a stack of diamonds in the empty inventory slot.
  3. With a full stack of diamonds in your player inventory (not the hotbar), click the 'Merge' button to attempt to drop off as many diamonds as possible into the chest.
  4. BUG: The chest fills with diamonds, but the diamonds in the player's inventory are not removed.
    NOTE: The specific items and quantities don't really matter. Attempting to smart-drop off more of an item than will fit into a chest containing a partial stack of the item causes the item duplication bug.

Suspected Cause

Being a programmer myself, I think I tracked down the problem:
vazkii.quark.base.handler.DropoffHandler Lines 215-216
if(!ItemStack.areItemsEqual(stackAt, ret)) inv.setInventorySlotContents(i, ret);

Those lines seem like they would skip updating the player's inventory if the insert operation doesn't complete, including when the insert operation partially completes. I'm guessing this can be easily fixed by using some other method instead, or maybe even always setting the inventory slot contents.
(Take my guess with a grain of salt, I have very little prior experience with Minecraft code.)

This was discovered on version r1.4 build 122

commented

You were close. areItemsEqual doesn't check stack sizes.