Fix memory leak and add additional logging
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
- Fixed Exporter not exporting anything when using a Stack Upgrade and there isn't space for 64 items in the inventory (raoulvdberge)
|
- Fixed Exporter not exporting anything when using a Stack Upgrade and there isn't space for 64 items in the inventory (raoulvdberge)
|
||||||
- Fixed Controller always using the base usage even when turned off (raoulvdberge)
|
- Fixed Controller always using the base usage even when turned off (raoulvdberge)
|
||||||
- Added the Regulator Upgrade that can be inserted into a Exporter. This ensures a certain amount of items and fluids is kept in stock in a connected inventory (raoulvdberge)
|
- Added the Regulator Upgrade that can be inserted into a Exporter. This ensures a certain amount of items and fluids is kept in stock in a connected inventory (raoulvdberge)
|
||||||
|
- Fixed severe memory leak in the storage cache (raoulvdberge)
|
||||||
|
- Added debug logging on the server when an expensive operation occurs (raoulvdberge)
|
||||||
|
|
||||||
### 1.8.2
|
### 1.8.2
|
||||||
- Add Refined Storage silicon to forge:silicon tag for mod compatibility (jeremiahwinsley)
|
- Add Refined Storage silicon to forge:silicon tag for mod compatibility (jeremiahwinsley)
|
||||||
|
@@ -38,6 +38,8 @@ public interface INetworkNode {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when this node is disconnected from a network.
|
* Called when this node is disconnected from a network.
|
||||||
|
* This happens when the node is removed, or if the network is removed.
|
||||||
|
* If the network runs out of power or no longer runs due to redstone mode settings, this won't be called and has to be detected manually.
|
||||||
*
|
*
|
||||||
* @param network the network
|
* @param network the network
|
||||||
*/
|
*/
|
||||||
|
@@ -20,8 +20,10 @@ public interface IStorageCache<T> {
|
|||||||
* Invalidates the cache.
|
* Invalidates the cache.
|
||||||
* Will also call {@link IStorageCache#sort()} to sort the storages correctly.
|
* Will also call {@link IStorageCache#sort()} to sort the storages correctly.
|
||||||
* Typically called when a {@link IStorageProvider} is added or removed from the network.
|
* Typically called when a {@link IStorageProvider} is added or removed from the network.
|
||||||
|
*
|
||||||
|
* @param cause the cause of the invalidate
|
||||||
*/
|
*/
|
||||||
void invalidate();
|
void invalidate(InvalidateCause cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a stack to the cache.
|
* Adds a stack to the cache.
|
||||||
|
10
src/main/java/com/raoulvdberge/refinedstorage/api/storage/cache/InvalidateCause.java
vendored
Normal file
10
src/main/java/com/raoulvdberge/refinedstorage/api/storage/cache/InvalidateCause.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.api.storage.cache;
|
||||||
|
|
||||||
|
public enum InvalidateCause {
|
||||||
|
UNKNOWN,
|
||||||
|
DISK_INVENTORY_CHANGED,
|
||||||
|
CONNECTED_STATE_CHANGED,
|
||||||
|
DEVICE_CONFIGURATION_CHANGED,
|
||||||
|
INITIAL_TICK_INVALIDATION,
|
||||||
|
NEIGHBOR_CHANGED
|
||||||
|
}
|
@@ -44,6 +44,8 @@ import net.minecraftforge.common.util.Constants;
|
|||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@@ -56,6 +58,8 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
|||||||
private static final String NBT_ITEM_STORAGE_TRACKER = "ItemStorageTracker";
|
private static final String NBT_ITEM_STORAGE_TRACKER = "ItemStorageTracker";
|
||||||
private static final String NBT_FLUID_STORAGE_TRACKER = "FluidStorageTracker";
|
private static final String NBT_FLUID_STORAGE_TRACKER = "FluidStorageTracker";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(Network.class);
|
||||||
|
|
||||||
private final IItemGridHandler itemGridHandler = new ItemGridHandler(this);
|
private final IItemGridHandler itemGridHandler = new ItemGridHandler(this);
|
||||||
private final IFluidGridHandler fluidGridHandler = new FluidGridHandler(this);
|
private final IFluidGridHandler fluidGridHandler = new FluidGridHandler(this);
|
||||||
private final INetworkItemManager networkItemManager = new NetworkItemManager(this);
|
private final INetworkItemManager networkItemManager = new NetworkItemManager(this);
|
||||||
@@ -160,6 +164,8 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
|||||||
couldRun = canRun;
|
couldRun = canRun;
|
||||||
throttlingDisabled = false;
|
throttlingDisabled = false;
|
||||||
|
|
||||||
|
LOGGER.info("Network at position {} changed running state to {}, causing an invalidation of the node graph", pos, couldRun);
|
||||||
|
|
||||||
nodeGraph.invalidate(Action.PERFORM, world, pos);
|
nodeGraph.invalidate(Action.PERFORM, world, pos);
|
||||||
securityManager.invalidate();
|
securityManager.invalidate();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||||
|
|
||||||
|
public enum ConnectivityStateChangeCause {
|
||||||
|
GRAPH_CHANGE,
|
||||||
|
REDSTONE_MODE_OR_NETWORK_ENERGY_CHANGE
|
||||||
|
}
|
@@ -148,8 +148,8 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onConnectedStateChange(INetwork network, boolean state) {
|
protected void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
network.getCraftingManager().invalidate();
|
network.getCraftingManager().invalidate();
|
||||||
}
|
}
|
||||||
|
@@ -100,8 +100,8 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
powered = false;
|
powered = false;
|
||||||
|
@@ -6,6 +6,7 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||||
@@ -33,6 +34,8 @@ import net.minecraft.util.text.TranslationTextComponent;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@@ -40,6 +43,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
public class ExternalStorageNetworkNode extends NetworkNode implements IStorageProvider, IStorageScreen, IComparable, IWhitelistBlacklist, IPrioritizable, IType, IAccessType, IExternalStorageContext {
|
public class ExternalStorageNetworkNode extends NetworkNode implements IStorageProvider, IStorageScreen, IComparable, IWhitelistBlacklist, IPrioritizable, IType, IAccessType, IExternalStorageContext {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "external_storage");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "external_storage");
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(ExternalStorageNetworkNode.class);
|
||||||
|
|
||||||
private static final String NBT_PRIORITY = "Priority";
|
private static final String NBT_PRIORITY = "Priority";
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
@@ -69,10 +74,12 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
updateStorage(network);
|
LOGGER.debug("Connectivity state of external storage at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
|
updateStorage(network, InvalidateCause.CONNECTED_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,7 +88,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
|
|
||||||
if (canUpdate()) {
|
if (canUpdate()) {
|
||||||
if (networkTicks++ == 0) {
|
if (networkTicks++ == 0) {
|
||||||
updateStorage(network);
|
updateStorage(network, InvalidateCause.INITIAL_TICK_INVALIDATION);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -101,7 +108,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
super.onDirectionChanged(direction);
|
super.onDirectionChanged(direction);
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
updateStorage(network);
|
updateStorage(network, InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +205,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStorage(INetwork network) {
|
public void updateStorage(INetwork network, InvalidateCause cause) {
|
||||||
itemStorages.clear();
|
itemStorages.clear();
|
||||||
fluidStorages.clear();
|
fluidStorages.clear();
|
||||||
|
|
||||||
@@ -224,8 +231,8 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(cause));
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -298,8 +305,8 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
this.accessType = type;
|
this.accessType = type;
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getItemStorageCache().invalidate();
|
network.getItemStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
network.getFluidStorageCache().invalidate();
|
network.getFluidStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
@@ -322,7 +329,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
updateStorage(network);
|
updateStorage(network, InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected(INetwork network) {
|
public void onConnected(INetwork network) {
|
||||||
onConnectedStateChange(network, true);
|
onConnectedStateChange(network, true, ConnectivityStateChangeCause.GRAPH_CHANGE);
|
||||||
|
|
||||||
this.network = network;
|
this.network = network;
|
||||||
}
|
}
|
||||||
@@ -87,10 +87,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
public void onDisconnected(INetwork network) {
|
public void onDisconnected(INetwork network) {
|
||||||
this.network = null;
|
this.network = null;
|
||||||
|
|
||||||
onConnectedStateChange(network, false);
|
onConnectedStateChange(network, false, ConnectivityStateChangeCause.GRAPH_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onConnectedStateChange(INetwork network, boolean state) {
|
protected void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
return redstoneMode.isEnabled(world, pos);
|
return redstoneMode.isEnabled(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canUpdate() {
|
protected final boolean canUpdate() {
|
||||||
if (isActive() && network != null) {
|
if (isActive() && network != null) {
|
||||||
return network.canRun();
|
return network.canRun();
|
||||||
}
|
}
|
||||||
@@ -122,10 +122,6 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThrottlingDisabled() {
|
|
||||||
throttlingDisabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
++ticks;
|
++ticks;
|
||||||
@@ -147,7 +143,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
onConnectedStateChange(network, canUpdate);
|
onConnectedStateChange(network, canUpdate, ConnectivityStateChangeCause.REDSTONE_MODE_OR_NETWORK_ENERGY_CHANGE);
|
||||||
|
|
||||||
if (shouldRebuildGraphOnChange()) {
|
if (shouldRebuildGraphOnChange()) {
|
||||||
network.getNodeGraph().invalidate(Action.PERFORM, network.getWorld(), network.getPosition());
|
network.getNodeGraph().invalidate(Action.PERFORM, network.getWorld(), network.getPosition());
|
||||||
|
@@ -129,8 +129,8 @@ public class SecurityManagerNetworkNode extends NetworkNode implements ISecurity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
network.getSecurityManager().invalidate();
|
network.getSecurityManager().invalidate();
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,11 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ConnectivityStateChangeCause;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.DiskState;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.DiskState;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.FluidStorageCache;
|
||||||
@@ -31,6 +33,8 @@ import net.minecraft.world.server.ServerWorld;
|
|||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -45,6 +49,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
|||||||
|
|
||||||
private static final int DISK_STATE_UPDATE_THROTTLE = 30;
|
private static final int DISK_STATE_UPDATE_THROTTLE = 30;
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(DiskDriveNetworkNode.class);
|
||||||
|
|
||||||
private int ticksSinceBlockUpdateRequested;
|
private int ticksSinceBlockUpdateRequested;
|
||||||
private boolean blockUpdateRequested;
|
private boolean blockUpdateRequested;
|
||||||
|
|
||||||
@@ -70,8 +76,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getItemStorageCache().invalidate();
|
network.getItemStorageCache().invalidate(InvalidateCause.DISK_INVENTORY_CHANGED);
|
||||||
network.getFluidStorageCache().invalidate();
|
network.getFluidStorageCache().invalidate(InvalidateCause.DISK_INVENTORY_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reading) {
|
if (!reading) {
|
||||||
@@ -139,11 +145,13 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
|
LOGGER.debug("Connectivity state of disk drive at {} changed to {} due to {}", pos, state, cause);
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
|
|
||||||
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
|
|
||||||
WorldUtils.updateBlock(world, pos);
|
WorldUtils.updateBlock(world, pos);
|
||||||
}
|
}
|
||||||
@@ -267,8 +275,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
|||||||
this.accessType = value;
|
this.accessType = value;
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getFluidStorageCache().invalidate();
|
network.getFluidStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
network.getItemStorageCache().invalidate();
|
network.getItemStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
|
@@ -5,10 +5,12 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ConnectivityStateChangeCause;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
|
||||||
@@ -32,6 +34,8 @@ import net.minecraft.util.text.TranslationTextComponent;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -43,6 +47,8 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
|||||||
public static final ResourceLocation FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "4096k_fluid_storage_block");
|
public static final ResourceLocation FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "4096k_fluid_storage_block");
|
||||||
public static final ResourceLocation CREATIVE_FLUID_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "creative_fluid_storage_block");
|
public static final ResourceLocation CREATIVE_FLUID_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "creative_fluid_storage_block");
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(FluidStorageNetworkNode.class);
|
||||||
|
|
||||||
private static final String NBT_PRIORITY = "Priority";
|
private static final String NBT_PRIORITY = "Priority";
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
@@ -86,10 +92,12 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE);
|
LOGGER.debug("Connectivity state of fluid storage block at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
|
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -276,7 +284,7 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
|||||||
this.accessType = value;
|
this.accessType = value;
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getFluidStorageCache().invalidate();
|
network.getFluidStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
|
@@ -5,10 +5,12 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ConnectivityStateChangeCause;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IStorageScreen;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||||
@@ -33,6 +35,8 @@ import net.minecraft.util.text.TranslationTextComponent;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -44,6 +48,8 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
|||||||
public static final ResourceLocation SIXTY_FOUR_K_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "64k_storage_block");
|
public static final ResourceLocation SIXTY_FOUR_K_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "64k_storage_block");
|
||||||
public static final ResourceLocation CREATIVE_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "creative_storage_block");
|
public static final ResourceLocation CREATIVE_STORAGE_BLOCK_ID = new ResourceLocation(RS.ID, "creative_storage_block");
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(StorageNetworkNode.class);
|
||||||
|
|
||||||
private static final String NBT_PRIORITY = "Priority";
|
private static final String NBT_PRIORITY = "Priority";
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
@@ -86,10 +92,12 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
public void onConnectedStateChange(INetwork network, boolean state, ConnectivityStateChangeCause cause) {
|
||||||
super.onConnectedStateChange(network, state);
|
super.onConnectedStateChange(network, state, cause);
|
||||||
|
|
||||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE);
|
LOGGER.debug("Connectivity state of item storage block at {} changed to {} due to {}", pos, state, cause);
|
||||||
|
|
||||||
|
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -275,7 +283,7 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
|||||||
this.accessType = value;
|
this.accessType = value;
|
||||||
|
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getItemStorageCache().invalidate();
|
network.getItemStorageCache().invalidate(InvalidateCause.DEVICE_CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
|
@@ -6,10 +6,13 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -17,9 +20,12 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
public class FluidStorageCache implements IStorageCache<FluidStack> {
|
||||||
public static final Consumer<INetwork> INVALIDATE = n -> n.getFluidStorageCache().invalidate();
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE = cause -> network -> network.getFluidStorageCache().invalidate(cause);
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(FluidStorageCache.class);
|
||||||
|
|
||||||
private final INetwork network;
|
private final INetwork network;
|
||||||
private final CopyOnWriteArrayList<IStorage<FluidStack>> storages = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<IStorage<FluidStack>> storages = new CopyOnWriteArrayList<>();
|
||||||
@@ -33,7 +39,9 @@ public class FluidStorageCache implements IStorageCache<FluidStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate(InvalidateCause cause) {
|
||||||
|
LOGGER.debug("Invalidating fluid storage cache of network at position {} due to {}", network.getPosition(), cause);
|
||||||
|
|
||||||
storages.clear();
|
storages.clear();
|
||||||
|
|
||||||
network.getNodeGraph().all().stream()
|
network.getNodeGraph().all().stream()
|
||||||
|
@@ -6,10 +6,13 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -17,9 +20,12 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
public class ItemStorageCache implements IStorageCache<ItemStack> {
|
||||||
public static final Consumer<INetwork> INVALIDATE = network -> network.getItemStorageCache().invalidate();
|
public static final Function<InvalidateCause, Consumer<INetwork>> INVALIDATE = cause -> network -> network.getItemStorageCache().invalidate(cause);
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(ItemStorageCache.class);
|
||||||
|
|
||||||
private final INetwork network;
|
private final INetwork network;
|
||||||
private final CopyOnWriteArrayList<IStorage<ItemStack>> storages = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<IStorage<ItemStack>> storages = new CopyOnWriteArrayList<>();
|
||||||
@@ -33,7 +39,9 @@ public class ItemStorageCache implements IStorageCache<ItemStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate(InvalidateCause cause) {
|
||||||
|
LOGGER.debug("Invalidating item storage cache of network at position {} due to {}", network.getPosition(), cause);
|
||||||
|
|
||||||
storages.clear();
|
storages.clear();
|
||||||
|
|
||||||
network.getNodeGraph().all().stream()
|
network.getNodeGraph().all().stream()
|
||||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
@@ -24,7 +25,7 @@ public class PortableFluidStorageCache implements IStorageCache<FluidStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate(InvalidateCause cause) {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
if (portableGrid.getFluidStorage() != null) {
|
if (portableGrid.getFluidStorage() != null) {
|
||||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.cache;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
import com.raoulvdberge.refinedstorage.api.util.StackListResult;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
@@ -24,7 +25,7 @@ public class PortableItemStorageCache implements IStorageCache<ItemStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate(InvalidateCause cause) {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
if (portableGrid.getItemStorage() != null) {
|
if (portableGrid.getItemStorage() != null) {
|
||||||
|
@@ -119,6 +119,7 @@ public class FluidStackList implements IStackList<FluidStack> {
|
|||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
stacks.clear();
|
stacks.clear();
|
||||||
|
index.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,8 +139,10 @@ public class FluidStackList implements IStackList<FluidStack> {
|
|||||||
FluidStackList list = new FluidStackList();
|
FluidStackList list = new FluidStackList();
|
||||||
|
|
||||||
for (StackListEntry<FluidStack> entry : stacks.values()) {
|
for (StackListEntry<FluidStack> entry : stacks.values()) {
|
||||||
list.stacks.put(entry.getStack().getFluid(), new StackListEntry<>(entry.getId(), entry.getStack().copy()));
|
FluidStack newStack = entry.getStack().copy();
|
||||||
list.index.put(entry.getId(), entry.getStack());
|
|
||||||
|
list.stacks.put(entry.getStack().getFluid(), new StackListEntry<>(entry.getId(), newStack));
|
||||||
|
list.index.put(entry.getId(), newStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@@ -117,6 +117,7 @@ public class ItemStackList implements IStackList<ItemStack> {
|
|||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
stacks.clear();
|
stacks.clear();
|
||||||
|
index.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,8 +137,10 @@ public class ItemStackList implements IStackList<ItemStack> {
|
|||||||
ItemStackList list = new ItemStackList();
|
ItemStackList list = new ItemStackList();
|
||||||
|
|
||||||
for (StackListEntry<ItemStack> entry : stacks.values()) {
|
for (StackListEntry<ItemStack> entry : stacks.values()) {
|
||||||
list.stacks.put(entry.getStack().getItem(), new StackListEntry<>(entry.getId(), entry.getStack().copy()));
|
ItemStack newStack = entry.getStack().copy();
|
||||||
list.index.put(entry.getId(), entry.getStack());
|
|
||||||
|
list.stacks.put(entry.getStack().getItem(), new StackListEntry<>(entry.getId(), newStack));
|
||||||
|
list.index.put(entry.getId(), newStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ExternalStorageNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ExternalStorageNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.container.ExternalStorageContainer;
|
import com.raoulvdberge.refinedstorage.container.ExternalStorageContainer;
|
||||||
import com.raoulvdberge.refinedstorage.container.factory.PositionalTileContainerProvider;
|
import com.raoulvdberge.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||||
@@ -122,7 +123,7 @@ public class ExternalStorageBlock extends CableBlock {
|
|||||||
if (node instanceof ExternalStorageNetworkNode &&
|
if (node instanceof ExternalStorageNetworkNode &&
|
||||||
node.getNetwork() != null &&
|
node.getNetwork() != null &&
|
||||||
fromPos.equals(pos.offset(((ExternalStorageNetworkNode) node).getDirection()))) {
|
fromPos.equals(pos.offset(((ExternalStorageNetworkNode) node).getDirection()))) {
|
||||||
((ExternalStorageNetworkNode) node).updateStorage(node.getNetwork());
|
((ExternalStorageNetworkNode) node).updateStorage(node.getNetwork(), InvalidateCause.NEIGHBOR_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
||||||
@@ -129,7 +130,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
cache.invalidate();
|
cache.invalidate(InvalidateCause.DISK_INVENTORY_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(handler, 4, stack.getTag());
|
StackUtils.writeItems(handler, 4, stack.getTag());
|
||||||
|
@@ -12,6 +12,7 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.storage.cache.InvalidateCause;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
||||||
@@ -212,7 +213,7 @@ public class PortableGridTile extends BaseTile implements IGrid, IPortableGrid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
cache.invalidate();
|
cache.invalidate(InvalidateCause.DISK_INVENTORY_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user