mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Check inv maxStackSize
As mentioned in CS-CoreLib2's #141 and #142 PR's, previous iterations of Slimefun AContainers would not consider the underlying Inventory's max stack size when determining sizing or pushing items. This commit changes DirtyChestMenus to act similarly by storing a variable defined as the lower of the Inventory's max stack size and the ItemStack's max stack size in a slot.
This commit is contained in:
parent
1169896034
commit
76a0ea1fdc
@ -105,15 +105,18 @@ public class DirtyChestMenu extends ChestMenu {
|
||||
if (stack == null) {
|
||||
replaceExistingItem(slot, item);
|
||||
return null;
|
||||
} else if (stack.getAmount() < stack.getMaxStackSize()) {
|
||||
if (wrapper == null) {
|
||||
wrapper = new ItemStackWrapper(item);
|
||||
}
|
||||
} else {
|
||||
int maxStackSize = Math.min(stack.getMaxStackSize(), toInventory().getMaxStackSize());
|
||||
if (stack.getAmount() < maxStackSize) {
|
||||
if (wrapper == null) {
|
||||
wrapper = new ItemStackWrapper(item);
|
||||
}
|
||||
|
||||
if (ItemUtils.canStack(wrapper, stack)) {
|
||||
amount -= (stack.getMaxStackSize() - stack.getAmount());
|
||||
stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize()));
|
||||
item.setAmount(amount);
|
||||
if (ItemUtils.canStack(wrapper, stack)) {
|
||||
amount -= (maxStackSize - stack.getAmount());
|
||||
stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), maxStackSize));
|
||||
item.setAmount(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user