1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge pull request #2755 from kii-chan-reloaded/master

Check inv maxStackSize
This commit is contained in:
TheBusyBiscuit 2021-01-25 16:34:47 +01:00 committed by GitHub
commit 30202d3f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,15 +105,18 @@ public class DirtyChestMenu extends ChestMenu {
if (stack == null) { if (stack == null) {
replaceExistingItem(slot, item); replaceExistingItem(slot, item);
return null; return null;
} else if (stack.getAmount() < stack.getMaxStackSize()) { } else {
if (wrapper == null) { int maxStackSize = Math.min(stack.getMaxStackSize(), toInventory().getMaxStackSize());
wrapper = new ItemStackWrapper(item); if (stack.getAmount() < maxStackSize) {
} if (wrapper == null) {
wrapper = new ItemStackWrapper(item);
}
if (ItemUtils.canStack(wrapper, stack)) { if (ItemUtils.canStack(wrapper, stack)) {
amount -= (stack.getMaxStackSize() - stack.getAmount()); amount -= (maxStackSize - stack.getAmount());
stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize())); stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), maxStackSize));
item.setAmount(amount); item.setAmount(amount);
}
} }
} }
} }