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);
}
}