Fixed item duplication bug with External Storage
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user