Fix fluid external storage cache

This commit is contained in:
raoulvdberge
2019-10-29 13:49:03 +01:00
parent 231027ebd8
commit f3e8183800
2 changed files with 6 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ public class FluidExternalStorageCache {
FluidStack actual = handler.getFluidInTank(i); FluidStack actual = handler.getFluidInTank(i);
if (i >= cache.size()) { // ENLARGED if (i >= cache.size()) { // ENLARGED
if (actual != null) { if (!actual.isEmpty()) {
network.getFluidStorageCache().add(actual, actual.getAmount(), false, true); network.getFluidStorageCache().add(actual, actual.getAmount(), false, true);
cache.add(actual.copy()); cache.add(actual.copy());
@@ -43,15 +43,15 @@ public class FluidExternalStorageCache {
FluidStack cached = cache.get(i); FluidStack cached = cache.get(i);
if (actual == null && cached == null) { // NONE if (actual.isEmpty() && cached.isEmpty()) { // NONE
continue; continue;
} }
if (actual == null && cached != null) { // REMOVED if (actual.isEmpty() && !cached.isEmpty()) { // REMOVED
network.getFluidStorageCache().remove(cached, cached.getAmount(), true); network.getFluidStorageCache().remove(cached, cached.getAmount(), true);
cache.set(i, null); cache.set(i, null);
} else if (actual != null && cached == null) { // ADDED } else if (!actual.isEmpty() && cached.isEmpty()) { // ADDED
network.getFluidStorageCache().add(actual, actual.getAmount(), false, true); network.getFluidStorageCache().add(actual, actual.getAmount(), false, true);
cache.set(i, actual.copy()); cache.set(i, actual.copy());
@@ -75,7 +75,7 @@ public class FluidExternalStorageCache {
for (int i = cache.size() - 1; i >= handler.getTanks(); --i) { // Reverse order for the remove call. for (int i = cache.size() - 1; i >= handler.getTanks(); --i) { // Reverse order for the remove call.
FluidStack cached = cache.get(i); FluidStack cached = cache.get(i);
if (cached != null) { if (!cached.isEmpty()) {
network.getFluidStorageCache().remove(cached, cached.getAmount(), true); network.getFluidStorageCache().remove(cached, cached.getAmount(), true);
} }

View File

@@ -59,6 +59,7 @@ public final class WorldUtils {
if (tile != null) { if (tile != null) {
return tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side).orElse(null); return tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side).orElse(null);
} }
return null; return null;
} }