Skip to content

Commit

Permalink
Fixed item duping
Browse files Browse the repository at this point in the history
Closes #117
  • Loading branch information
TheDarkDnKTv committed May 5, 2021
1 parent 29862a3 commit 720bbf9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/gregtechmod/api/util/GT_Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,9 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity
if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlots[i], (byte)aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlots[i]))) {
if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize) {
ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlots[i]).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlots[i]));
ItemStack rStack = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
byte tMovedItemCount = (byte)(tStack.stackSize - (rStack == null ? 0 : rStack.stackSize));
if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) {
ItemStack remains = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack));
tMovedItemCount = (byte) (tStack.stackSize - remains.stackSize);
ItemStack remains = ((cofh.api.transport.IItemDuct)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack));
byte tMovedItemCount = (byte)(tStack.stackSize - (remains == null ? 0 : remains.stackSize));
if (tMovedItemCount >= 0) {
aTileEntity1.decrStackSize(aGrabSlots[i], tMovedItemCount);
aTileEntity1.markDirty();
return tMovedItemCount;
Expand All @@ -424,6 +422,7 @@ public static byte moveStackIntoPipe(IInventory aTileEntity1, Object aTileEntity
}
}
}

return 0;
}
if (BC_CHECK && aTileEntity2 instanceof buildcraft.api.transport.IPipeTile) {
Expand Down Expand Up @@ -582,8 +581,7 @@ private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity
}
}

moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
return 0;
return moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce);
}

/**
Expand Down

0 comments on commit 720bbf9

Please sign in to comment.