Fixed External Storage cache not working properly on Compacting Drawers, fixes #591
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
- Fixed Disk Drive stored quantity GUI text hovering over other text (raoulvdberge)
|
||||
- Fixed External Storage being in item and fluid mode at the same time (raoulvdberge)
|
||||
- Fixed Wrench working when player is not sneaking (raoulvdberge)
|
||||
- Fixed External Storage cache counting items up when extracting (raoulvdberge)
|
||||
- Fixed External Storage cache not working properly on Compacting Drawers (raoulvdberge)
|
||||
|
||||
### 1.2.3
|
||||
- Fixed fluid cache updating wrongly (raoulvdberge)
|
||||
|
||||
@@ -563,6 +563,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
int orginalSize = size;
|
||||
AccessType accessType = AccessType.INSERT_EXTRACT;
|
||||
ItemStack remainder = stack;
|
||||
int externalStorageInserted = 0;
|
||||
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
accessType = storage.getAccessType();
|
||||
@@ -573,13 +574,17 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
if (remainder == null || remainder.stackSize <= 0) {
|
||||
if (storage instanceof ItemStorageExternal && !simulate) {
|
||||
((ItemStorageExternal) storage).updateForced();
|
||||
((ItemStorageExternal) storage).detectChanges(this);
|
||||
// the external storage will send the change, we don't need to anymore
|
||||
externalStorageInserted += size;
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
if (size != remainder.stackSize && storage instanceof ItemStorageExternal && !simulate) {
|
||||
((ItemStorageExternal) storage).updateForced();
|
||||
((ItemStorageExternal) storage).detectChanges(this);
|
||||
// the external storage will send the change, we don't need to anymore
|
||||
externalStorageInserted += size - remainder.stackSize;
|
||||
}
|
||||
|
||||
size = remainder.stackSize;
|
||||
@@ -598,9 +603,12 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
inserted = orginalSize - remainder.stackSize;
|
||||
}
|
||||
|
||||
if (!simulate && inserted > 0 && accessType != AccessType.INSERT) {
|
||||
itemStorage.add(stack, inserted, false);
|
||||
if (!simulate && accessType != AccessType.INSERT) {
|
||||
if (inserted - externalStorageInserted > 0) {
|
||||
itemStorage.add(stack, inserted - externalStorageInserted, false);
|
||||
}
|
||||
|
||||
if (inserted > 0) {
|
||||
ItemStack checkSteps = ItemHandlerHelper.copyStackWithSize(stack, inserted);
|
||||
|
||||
for (ICraftingTask task : craftingTasks) {
|
||||
@@ -611,6 +619,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return remainder;
|
||||
}
|
||||
@@ -619,6 +628,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
public ItemStack extractItem(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
|
||||
int requested = size;
|
||||
int received = 0;
|
||||
int externalStorageExtracted = 0;
|
||||
ItemStack newStack = null;
|
||||
|
||||
for (IItemStorage storage : this.itemStorage.getStorages()) {
|
||||
@@ -630,7 +640,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
if (took != null) {
|
||||
if (storage instanceof ItemStorageExternal && !simulate) {
|
||||
((ItemStorageExternal) storage).updateForced();
|
||||
((ItemStorageExternal) storage).detectChanges(this);
|
||||
// the external storage will send the change, we don't need to anymore
|
||||
externalStorageExtracted += took.stackSize;
|
||||
}
|
||||
|
||||
if (newStack == null) {
|
||||
@@ -647,8 +659,8 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
if (newStack != null && !simulate) {
|
||||
itemStorage.remove(newStack, newStack.stackSize);
|
||||
if (newStack != null && newStack.stackSize - externalStorageExtracted > 0 && !simulate) {
|
||||
itemStorage.remove(newStack, newStack.stackSize - externalStorageExtracted);
|
||||
}
|
||||
|
||||
return newStack;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.externalstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.item.IItemStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -13,9 +14,17 @@ public abstract class ItemStorageExternal implements IItemStorage {
|
||||
public abstract int getCapacity();
|
||||
|
||||
public void detectChanges(INetworkMaster network) {
|
||||
// if we are insert-only, we don't care about sending changes
|
||||
if (getAccessType() == AccessType.INSERT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cache == null) {
|
||||
updateForced();
|
||||
} else {
|
||||
cache = getStacks();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemStack> newStacks = getStacks();
|
||||
|
||||
for (int i = 0; i < newStacks.size(); ++i) {
|
||||
@@ -68,8 +77,3 @@ public abstract class ItemStorageExternal implements IItemStorage {
|
||||
this.cache = newStacks;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateForced() {
|
||||
this.cache = getStacks();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user