Fixed external storage cache being de-synced from the network cache
This commit is contained in:
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed external storage cache being de-synced from the network cache.
|
||||
|
||||
## [v1.11.2] - 2022-12-17
|
||||
|
||||
### Added
|
||||
|
@@ -64,6 +64,8 @@ public class FluidExternalStorage implements IExternalStorage<FluidStack> {
|
||||
IFluidHandler fluidHandler = handlerSupplier.get();
|
||||
|
||||
if (fluidHandler != null) {
|
||||
cache.initCache(fluidHandler);
|
||||
|
||||
List<FluidStack> fluids = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < fluidHandler.getTanks(); ++i) {
|
||||
|
@@ -18,13 +18,11 @@ public class FluidExternalStorageCache {
|
||||
return stored;
|
||||
}
|
||||
|
||||
public void update(INetwork network, @Nullable IFluidHandler handler) {
|
||||
if (handler == null) {
|
||||
stored = 0;
|
||||
return;
|
||||
public boolean initCache(IFluidHandler handler) {
|
||||
if (cache != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cache == null) {
|
||||
cache = new ArrayList<>();
|
||||
|
||||
int stored = 0;
|
||||
@@ -35,6 +33,16 @@ public class FluidExternalStorageCache {
|
||||
}
|
||||
this.stored = stored;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(INetwork network, @Nullable IFluidHandler handler) {
|
||||
if (handler == null) {
|
||||
stored = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (initCache(handler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -68,6 +68,8 @@ public class ItemExternalStorage implements IExternalStorage<ItemStack> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
cache.initCache(handler);
|
||||
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
|
@@ -17,13 +17,11 @@ public class ItemExternalStorageCache {
|
||||
return stored;
|
||||
}
|
||||
|
||||
public void update(INetwork network, @Nullable IItemHandler handler) {
|
||||
if (handler == null) {
|
||||
stored = 0;
|
||||
return;
|
||||
public boolean initCache(IItemHandler handler) {
|
||||
if (cache != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cache == null) {
|
||||
cache = new ArrayList<>();
|
||||
|
||||
int stored = 0;
|
||||
@@ -34,6 +32,16 @@ public class ItemExternalStorageCache {
|
||||
}
|
||||
this.stored = stored;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(INetwork network, @Nullable IItemHandler handler) {
|
||||
if (handler == null) {
|
||||
stored = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (initCache(handler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user