public void removeTile(CrystalNetworkTile te) { tiles.remove(PylonFinder.getLocation(te)); if (te instanceof NotifiedNetworkTile) { notifyCache.remove(te); } for (NotifiedNetworkTile tile : notifyCache) { tile.onTileNetworkTopologyChange(te, true); } if (te instanceof TileEntityCrystalPylon) { TileEntityCrystalPylon tile = (TileEntityCrystalPylon) te; TileEntityCache<TileEntityCrystalPylon> c = pylons.get(tile.getColor()); if (c != null) c.remove(tile); } Collection<CrystalFlow> li = flows.get(te.getWorld().provider.dimensionId); Iterator<CrystalFlow> it = li.iterator(); while (it.hasNext()) { CrystalFlow p = it.next(); if (p.contains(te)) { CrystalNetworkLogger.logFlowBreak(p, FlowFail.TILE); p.resetTiles(); p.receiver.onPathBroken(p, FlowFail.TILE); it.remove(); } } PylonFinder.removePathsWithTile(te); WorldCrystalNetworkData.initNetworkData(te.getWorld()).setDirty(true); // was false if (te instanceof TileEntityCrystalPylon) { PylonLocationData.initNetworkData(te.getWorld()).setDirty(true); } }
@SubscribeEvent public void clearOnUnload(WorldEvent.Unload evt) { PylonFinder.stopAllSearches(); int dim = evt.world.provider.dimensionId; ChromatiCraft.logger.debug("Unloading dimension " + dim + ", clearing crystal network."); try { this.clear(dim); for (WorldLocation c : tiles.keySet()) { CrystalNetworkTile te = tiles.get(c); PylonFinder.removePathsWithTile(te); if (te instanceof CrystalTransmitter) ((CrystalTransmitter) te).clearTargets(true); } tiles.removeWorld(evt.world); for (TileEntityCache c : pylons.values()) c.removeWorld(evt.world); } catch (ConcurrentModificationException e) { ChromatiCraft.logger.logError( "Clearing the crystal network on world unload caused a CME. This is indicative of a deeper problem."); e.printStackTrace(); } }