use of crazypants.enderio.conduits.render.BlockStateWrapperConduitBundle.ConduitCacheKey in project EnderIO by SleepyTrousers.
the class TileConduitBundle method onAfterNbtRead.
@Override
protected void onAfterNbtRead() {
super.onAfterNbtRead();
if (world.isRemote) {
// keep conduits sorted so the client side cache key is stable
ConduitRegistry.sort(conduits);
CopyOnWriteArrayList<IClientConduit> temp = new CopyOnWriteArrayList<>();
for (IConduit c : conduits) {
if (c instanceof IClientConduit) {
c.setBundle(this);
temp.add((IClientConduit) c);
}
}
final ConduitCacheKey oldHashCode = new ConduitCacheKey(), newHashCode = new ConduitCacheKey();
makeConduitHashCode(getClientConduits(), oldHashCode);
makeConduitHashCode(temp, newHashCode);
if (hasWorld() && getWorld().isRemote && oldHashCode.hashCode() != newHashCode.hashCode()) {
clientUpdated = true;
}
// switch over atomically to avoid threading issues
clientConduits = temp;
conduits = new CopyOnWriteArrayList<IConduit>();
} else {
// no threads on server-side. but to be safe, conduits only go into the list after they got a bundle set
// (a.k.a. "do better than World.addTileEntities()"
serverConduits.clear();
for (IConduit c : conduits) {
if (c instanceof IServerConduit) {
c.setBundle(this);
serverConduits.add((IServerConduit) c);
}
}
conduits.clear();
}
cachedCollidables.clear();
}
Aggregations