mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-16 17:33:13 +01:00
backport bf7760c5fb
This commit is contained in:
parent
9ff65e3b06
commit
2f75a2c774
2 changed files with 5 additions and 5 deletions
|
@ -464,13 +464,13 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearDestinationCache(BlockPos... nodes) {
|
public void clearDestinationCache(List<BlockPos> nodes) {
|
||||||
this.startProfile("clear_node_cache");
|
this.startProfile("clear_node_cache");
|
||||||
// remove caches for the nodes
|
// remove caches for the nodes
|
||||||
for (BlockPos node : nodes)
|
for (BlockPos node : nodes)
|
||||||
this.nodeToConnectedNodes.keySet().remove(node);
|
this.nodeToConnectedNodes.keySet().remove(node);
|
||||||
// remove caches that contain the nodes as a destination
|
// remove caches that contain the nodes as a destination
|
||||||
this.nodeToConnectedNodes.values().removeIf(cached -> Arrays.stream(nodes).anyMatch(cached::contains));
|
this.nodeToConnectedNodes.values().removeIf(cached -> nodes.stream().anyMatch(cached::contains));
|
||||||
this.endProfile();
|
this.endProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,12 +493,12 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void edgeAdded(GraphEdgeChangeEvent<BlockPos, NetworkEdge> e) {
|
public void edgeAdded(GraphEdgeChangeEvent<BlockPos, NetworkEdge> e) {
|
||||||
this.clearDestinationCache(e.getEdgeSource(), e.getEdgeTarget());
|
this.clearDestinationCache(e.getEdge().pipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void edgeRemoved(GraphEdgeChangeEvent<BlockPos, NetworkEdge> e) {
|
public void edgeRemoved(GraphEdgeChangeEvent<BlockPos, NetworkEdge> e) {
|
||||||
this.clearDestinationCache(e.getEdgeSource(), e.getEdgeTarget());
|
this.clearDestinationCache(e.getEdge().pipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
if (prio != this.priority) {
|
if (prio != this.priority) {
|
||||||
this.priority = prio;
|
this.priority = prio;
|
||||||
// clear the cache so that it's reevaluated based on priority
|
// clear the cache so that it's reevaluated based on priority
|
||||||
PipeNetwork.get(this.world).clearDestinationCache(this.pos);
|
PipeNetwork.get(this.world).clearDestinationCache(Collections.singletonList(this.pos));
|
||||||
}
|
}
|
||||||
profiler.endSection();
|
profiler.endSection();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue