}
}
@Override
public void updateEntities() {
final Profiler theProfiler = this.theProfiler;
theProfiler.startSection("updateEntities");
int var1;
Entity weatherEffect;
CrashReport var4;
CrashReportCategory var5;
theProfiler.startSection("global");
final List<Entity> weatherEffects = this.weatherEffects;
synchronized (weatherEffects) {
Iterator<Entity> iterator = weatherEffects.iterator();
while (iterator.hasNext()) {
weatherEffect = iterator.next();
if (weatherEffect == null) {
iterator.remove();
continue;
}
try {
++weatherEffect.ticksExisted;
weatherEffect.onUpdate();
} catch (Throwable t) {
Log.severe("Failed to tick weather " + Log.toString(weatherEffect), t);
}
if (weatherEffect.isDead) {
iterator.remove();
}
}
}
theProfiler.endStartSection("remove");
int var3;
int var13;
final List loadedEntityList = this.loadedEntityList;
boolean tickTT = loadedEntityList instanceof EntityList;
if (tickTT) {
((EntityList) loadedEntityList).manager.batchRemoveEntities(unloadedEntitySet);
((EntityList) loadedEntityList).manager.doTick();
} else {
loadedEntityList.removeAll(unloadedEntitySet);
for (Entity entity : unloadedEntitySet) {
var3 = entity.chunkCoordX;
var13 = entity.chunkCoordZ;
if (entity.addedToChunk) {
Chunk chunk = getChunkIfExists(var3, var13);
if (chunk != null) {
chunk.removeEntity(entity);
}
}
onEntityRemoved(entity);
}
unloadedEntitySet.clear();
theProfiler.endStartSection("entities");
for (var1 = 0; var1 < loadedEntityList.size(); ++var1) {
weatherEffect = (Entity) loadedEntityList.get(var1);
if (weatherEffect.ridingEntity != null) {
if (!weatherEffect.ridingEntity.isDead && weatherEffect.ridingEntity.riddenByEntity == weatherEffect) {
continue;
}
weatherEffect.ridingEntity.riddenByEntity = null;
weatherEffect.ridingEntity = null;
}
theProfiler.startSection("tick");
if (!weatherEffect.isDead) {
try {
updateEntity(weatherEffect);
} catch (Throwable var7) {
var4 = CrashReport.makeCrashReport(var7, "Ticking entity");
var5 = var4.makeCategory("Entity being ticked");
weatherEffect.addEntityCrashInfo(var5);
throw new ReportedException(var4);
}
}
theProfiler.endSection();
theProfiler.startSection("remove");
if (weatherEffect.isDead) {
var3 = weatherEffect.chunkCoordX;
var13 = weatherEffect.chunkCoordZ;
if (weatherEffect.addedToChunk) {
Chunk chunk = getChunkIfExists(var3, var13);
if (chunk != null) {
chunk.removeEntity(weatherEffect);
}
}
loadedEntityList.remove(var1--);
onEntityRemoved(weatherEffect);
}
theProfiler.endSection();
}
theProfiler.endStartSection("tileEntities");
scanningTileEntities = true;
Iterator var14 = loadedTileEntityList.iterator();
while (var14.hasNext()) {
TileEntity var9 = (TileEntity) var14.next();
if (!var9.isInvalid() && var9.hasWorldObj() && blockExists(var9.xCoord, var9.yCoord, var9.zCoord)) {
try {
var9.updateEntity();
} catch (Throwable var8) {
var4 = CrashReport.makeCrashReport(var8, "Ticking tile entity");
var5 = var4.makeCategory("Tile entity being ticked");
var9.func_85027_a(var5);
throw new ReportedException(var4);
}
}
if (var9.isInvalid()) {
var14.remove();
Chunk var11 = getChunkIfExists(var9.xCoord >> 4, var9.zCoord >> 4);
if (var11 != null) {
var11.cleanChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15);
}
}
}
}
theProfiler.endStartSection("removingTileEntities");
final List loadedTileEntityList = this.loadedTileEntityList;
if (loadedTileEntityList instanceof LoadedTileEntityList) {
((LoadedTileEntityList) loadedTileEntityList).manager.batchRemoveTileEntities(tileEntityRemovalSet);
} else {
if (!warnedWrongList && loadedTileEntityList.getClass() != ArrayList.class) {
Log.severe("TickThreading's replacement loaded tile entity list has been replaced by one from another mod!\n" +
"Class: " + loadedTileEntityList.getClass() + ", toString(): " + loadedTileEntityList);
warnedWrongList = true;
}
for (TileEntity tile : tileEntityRemovalSet) {
tile.onChunkUnload();
}
loadedTileEntityList.removeAll(tileEntityRemovalSet);
tileEntityRemovalSet.clear();
}
scanningTileEntities = false;
theProfiler.endStartSection("pendingTileEntities");
if (!addedTileEntityList.isEmpty()) {
for (TileEntity te : (Iterable<TileEntity>) addedTileEntityList) {
if (te.isInvalid()) {
Chunk var15 = getChunkIfExists(te.xCoord >> 4, te.zCoord >> 4);
if (var15 != null) {
var15.cleanChunkBlockTileEntity(te.xCoord & 15, te.yCoord, te.zCoord & 15);
}
} else {
if (!loadedTileEntityList.contains(te)) {
loadedTileEntityList.add(te);
}
}
}
addedTileEntityList.clear();
}
theProfiler.endSection();
theProfiler.endSection();
}