From 47a0de314d85b2706d68bc64a5a9c6748ce26e37 Mon Sep 17 00:00:00 2001 From: CoolMineman <62723322+CoolMineman@users.noreply.github.com> Date: Sun, 26 Jul 2020 17:11:03 -0500 Subject: fix SyncedGuiDescription.insertIntoExisting --- .../java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java | 9 +++++---- 1 file 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; } -- cgit