diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java index cd47af4..2215d4b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java @@ -152,14 +152,15 @@ public class SyncedGuiDescription extends ScreenHandler implements GuiDescriptio ItemStack curSlotStack = slot.getStack(); if (!curSlotStack.isEmpty() && canStacksCombine(toInsert, curSlotStack) && slot.canTakeItems(player)) { int combinedAmount = curSlotStack.getCount() + toInsert.getCount(); - if (combinedAmount <= toInsert.getMaxCount()) { + int maxAmount = Math.min(toInsert.getMaxCount(), slot.getMaxStackAmount()); + if (combinedAmount <= maxAmount) { toInsert.setCount(0); curSlotStack.setCount(combinedAmount); slot.markDirty(); return true; - } else if (curSlotStack.getCount() < toInsert.getMaxCount()) { - toInsert.decrement(toInsert.getMaxCount() - curSlotStack.getCount()); - curSlotStack.setCount(toInsert.getMaxCount()); + } else if (curSlotStack.getCount() < maxAmount) { + toInsert.decrement(maxAmount - curSlotStack.getCount()); + curSlotStack.setCount(maxAmount); slot.markDirty(); return true; } |