Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit 720bbf9

Browse files
committed
Fixed item duping
Closes #117
1 parent 29862a3 commit 720bbf9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/main/java/gregtechmod/api/util/GT_Utility.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,9 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity
411411
if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte)aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
412412
if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
413413
ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
414-
ItemStack rStack = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
415-
byte tMovedItemCount = (byte)(tStack.stackSize - (rStack == null ? 0 : rStack.stackSize));
416-
if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) {
417-
ItemStack remains = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack));
418-
tMovedItemCount = (byte) (tStack.stackSize - remains.stackSize);
414+
ItemStack remains = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
415+
byte tMovedItemCount = (byte)(tStack.stackSize - (remains == null ? 0 : remains.stackSize));
416+
if (tMovedItemCount >= 0) {
419417
aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
420418
aTileEntity1.markDirty();
421419
return tMovedItemCount;
@@ -424,6 +422,7 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity
424422
}
425423
}
426424
}
425+
427426
return 0;
428427
}
429428
if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) {
@@ -582,8 +581,7 @@ private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity
582581
}
583582
}
584583

585-
moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
586-
return 0;
584+
return moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
587585
}
588586

589587
/**

0 commit comments

Comments
 (0)