Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
continue;
if (depositItemInHand && i != inventory.selected)
continue;
ItemStack item = inventory.getItem(i);
ItemStack item = depositItemInHand ? stack : inventory.getItem(i);
if (item.isEmpty())
continue;
if (!item.getItem()
Expand All @@ -136,10 +136,15 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev
if (remainder.getCount() == item.getCount())
continue;

ItemStack extracted = inventory.removeItem(i, item.getCount() - remainder.getCount());
ItemStack extracted = depositItemInHand ? stack.copy() : inventory.removeItem(i, item.getCount() - remainder.getCount());
remainder = ItemHandlerHelper.insertItemStacked(targetInv, extracted, false);
anyInserted = true;

if(depositItemInHand) {
stack.setCount(remainder.getCount());
remainder.setCount(0); // clear it because we already set the count and don't want to duplicate it
}

// remainder might not be empty in itemhandler edge cases
if (!remainder.isEmpty())
failedInsertions.add(remainder);
Expand Down
Loading