fix integer overflow resulting in item lose
This commit is contained in:
@@ -95,13 +95,14 @@ public class FluidStorageDisk implements IStorageDisk<FluidStack> {
|
||||
|
||||
return StackUtils.copy(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
int maxConsumable = Math.min(size, Integer.MAX_VALUE - otherStack.getAmount());
|
||||
if (action == Action.PERFORM) {
|
||||
otherStack.grow(size);
|
||||
otherStack.grow(maxConsumable);
|
||||
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return FluidStack.EMPTY;
|
||||
return StackUtils.copy(otherStack, size - maxConsumable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -102,14 +102,15 @@ public class ItemStorageDisk implements IStorageDisk<ItemStack> {
|
||||
|
||||
return ItemHandlerHelper.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
int maxConsumable = Math.min(size, Integer.MAX_VALUE - otherStack.getCount());
|
||||
if (action == Action.PERFORM) {
|
||||
otherStack.grow(size);
|
||||
itemCount += size;
|
||||
otherStack.grow(maxConsumable);
|
||||
itemCount += maxConsumable;
|
||||
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
return ItemHandlerHelper.copyStackWithSize(otherStack, size - maxConsumable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user