Fixed item duplication bug with External Storage

This commit is contained in:
Raoul Van den Berge
2016-08-11 23:32:05 +02:00
parent 75fdf13cbf
commit 8f55352330
4 changed files with 30 additions and 15 deletions

View File

@@ -81,7 +81,7 @@ public class GroupedItemStorage implements IGroupedItemStorage {
if (CompareUtils.compareStackNoQuantity(otherStack, stack)) {
otherStack.stackSize -= stack.stackSize;
if (otherStack.stackSize == 0) {
if (otherStack.stackSize <= 0) {
if (!NetworkUtils.hasPattern(network, stack)) {
stacks.remove(otherStack.getItem(), otherStack);
}

View File

@@ -47,21 +47,33 @@ public class ItemStorageItemHandler extends ItemStorageExternal {
@Override
public ItemStack extractItem(ItemStack stack, int size, int flags) {
int remaining = size;
ItemStack received = null;
for (int i = 0; i < handler.getSlots(); ++i) {
ItemStack slot = handler.getStackInSlot(i);
if (slot != null && CompareUtils.compareStack(slot, stack, flags)) {
size = Math.min(size, slot.stackSize);
ItemStack got = handler.extractItem(i, remaining, false);
ItemStack took = ItemHandlerHelper.copyStackWithSize(slot, size);
if (got != null) {
if (received == null) {
received = got;
} else {
received.stackSize += got.stackSize;
}
handler.extractItem(i, size, false);
remaining -= got.stackSize;
return took;
if (remaining == 0) {
break;
}
}
}
}
return null;
return received;
}
@Override

View File

@@ -102,18 +102,16 @@ public class TileExternalStorage extends TileMultipartNode implements IStoragePr
@Override
public void update() {
if (!worldObj.isRemote && network != null) {
if (ticks % (20 * 4) == 0) {
boolean shouldRebuild = false;
boolean changeDetected = false;
for (ItemStorageExternal storage : storages) {
if (storage.updateCache()) {
shouldRebuild = true;
}
for (ItemStorageExternal storage : storages) {
if (storage.updateCache()) {
changeDetected = true;
}
}
if (shouldRebuild) {
network.getItemStorage().rebuild();
}
if (changeDetected) {
network.getItemStorage().rebuild();
}
if (getFacingTile() instanceof IDrawerGroup && lastDrawerCount != ((IDrawerGroup) getFacingTile()).getDrawerCount()) {