aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorCoolMineman <62723322+CoolMineman@users.noreply.github.com>2020-07-26 17:11:03 -0500
committerCoolMineman <62723322+CoolMineman@users.noreply.github.com>2020-07-26 17:11:03 -0500
commit47a0de314d85b2706d68bc64a5a9c6748ce26e37 (patch)
tree8ec162035901a72154e0cfa0e64107805159ccc2 /src/main/java/io
parent65ff902aaf7025f90efb739ab0cca985f2f59c59 (diff)
downloadLibGui-47a0de314d85b2706d68bc64a5a9c6748ce26e37.tar.gz
LibGui-47a0de314d85b2706d68bc64a5a9c6748ce26e37.tar.bz2
LibGui-47a0de314d85b2706d68bc64a5a9c6748ce26e37.zip
fix SyncedGuiDescription.insertIntoExisting
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/SyncedGuiDescription.java9
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;
}