Fixed the problem with the storage system item count increasing when voiding stuff.

This commit is contained in:
Geldorn
2016-10-06 22:17:48 +02:00
parent c502e3758f
commit a127a265e2
2 changed files with 15 additions and 4 deletions

View File

@@ -521,14 +521,25 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
((ItemStorageExternal) storage).updateCacheForcefully();
}
if (remainder == null) {
if (remainder == null || remainder.stackSize < 0) {
break;
} else {
size = remainder.stackSize;
}
}
int inserted = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize;
//If the stack size of the remainder is negative, it means of the original size abs(remainder.stackSize) items have been voided
int inserted;
if(remainder == null) {
inserted = orginalSize;
}
else if(remainder.stackSize < 0) {
inserted = orginalSize + remainder.stackSize;
remainder = null;
}
else {
inserted = orginalSize - remainder.stackSize;
}
if (!simulate && inserted > 0) {
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);

View File

@@ -53,9 +53,9 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
ItemStack result = super.insertItem(stack, size, simulate);
if(voidExcess) {
if(voidExcess && result != null) {
//Simulate should not matter as the items are voided anyway
return null;
result.stackSize = -result.stackSize;
}
return result;