diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-07-27 02:18:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-27 02:18:06 +0300 |
commit | a1eb465a84d1907dd5f2a9a7e83ec2e182af6051 (patch) | |
tree | 8ec162035901a72154e0cfa0e64107805159ccc2 | |
parent | 65ff902aaf7025f90efb739ab0cca985f2f59c59 (diff) | |
parent | 47a0de314d85b2706d68bc64a5a9c6748ce26e37 (diff) | |
download | LibGui-a1eb465a84d1907dd5f2a9a7e83ec2e182af6051.tar.gz LibGui-a1eb465a84d1907dd5f2a9a7e83ec2e182af6051.tar.bz2 LibGui-a1eb465a84d1907dd5f2a9a7e83ec2e182af6051.zip |
Merge pull request #78 from CoolMineman/master
Fix SyncedGuiDescription.insertIntoExisting Not Respecting the Slot Max Stack Amount
-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; } |