unload pipes when chunks get unloaded

Closes #86
This commit is contained in:
Ell 2021-06-19 14:48:47 +02:00
parent e9b38d0df5
commit e6e00191f2
2 changed files with 10 additions and 0 deletions

View file

@ -253,6 +253,11 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
return tile;
}
public void uncachePipe(BlockPos pos) {
if (this.tileCache.remove(pos) != null)
System.out.println("Uncaching pipe at " + pos);
}
public List<Pair<BlockPos, ItemStack>> getCurrentlyCrafting(BlockPos node, ItemEquality... equalityTypes) {
this.startProfile("get_currently_crafting");
List<Pair<BlockPos, ItemStack>> items = new ArrayList<>();

View file

@ -89,6 +89,11 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
super(type);
}
@Override
public void onChunkUnloaded() {
PipeNetwork.get(this.world).uncachePipe(this.pos);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
compound.put("modules", this.modules.serializeNBT());