Prevent overflowing of item stacks in lists, #490

This commit is contained in:
Raoul Van den Berge
2016-10-22 15:48:00 +02:00
parent a894b58d8c
commit ae59137587

View File

@@ -20,7 +20,11 @@ public class ItemStackList implements IItemStackList {
public void add(ItemStack stack) { public void add(ItemStack stack) {
for (ItemStack otherStack : stacks.get(stack.getItem())) { for (ItemStack otherStack : stacks.get(stack.getItem())) {
if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) { if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) {
if ((long) otherStack.stackSize + (long) stack.stackSize > Integer.MAX_VALUE) {
otherStack.stackSize = Integer.MAX_VALUE;
} else {
otherStack.stackSize += stack.stackSize; otherStack.stackSize += stack.stackSize;
}
return; return;
} }