}
@Override
public void tick() {
final Profiler profiler = this.theProfiler;
final WorldInfo worldInfo = this.worldInfo;
final int tickCount = ++this.tickCount;
final boolean hasPlayers = !playerEntities.isEmpty();
this.updateWeather();
if (!forcedChunksInited) {
ForgeChunkManager.loadForcedChunks(this);
}
updateEntityTick = 0;
if (this.difficultySetting < 3 && this.getWorldInfo().isHardcoreModeEnabled()) {
this.difficultySetting = 3;
}
if (tickCount % 120 == 0) {
redstoneBurnoutMap.clear();
}
if (tickCount % 200 == 0) {
this.provider.worldChunkMgr.cleanupCache();
}
if (hasPlayers && this.areAllPlayersAsleep()) {
long var2 = worldInfo.getWorldTime();
worldInfo.setWorldTime(var2 + 24000L - (var2 % 24000L));
this.wakeAllPlayers();
}
profiler.startSection("mobSpawner");
if (hasPlayers && (loadedEntityList.size() / TickThreading.instance.maxEntitiesPerPlayer) < playerEntities.size() && this.getGameRules().getGameRuleBooleanValue("doMobSpawning")) {
if (TickThreading.instance.shouldFastSpawn(this)) {
SpawnerAnimals.spawnMobsQuickly(this, spawnHostileMobs && (ticksPerMonsterSpawns != 0 && tickCount % ticksPerMonsterSpawns == 0L), spawnPeacefulMobs && (ticksPerAnimalSpawns != 0 && tickCount % ticksPerAnimalSpawns == 0L), worldInfo.getWorldTotalTime() % 400L == 0L);
} else {
animalSpawner.findChunksForSpawning(this, spawnHostileMobs && (ticksPerMonsterSpawns != 0 && tickCount % ticksPerMonsterSpawns == 0L), spawnPeacefulMobs && (ticksPerAnimalSpawns != 0 && tickCount % ticksPerAnimalSpawns == 0L), worldInfo.getWorldTotalTime() % 400L == 0L);
}
}
profiler.endStartSection("chunkSource");
theChunkProviderServer.unloadQueuedChunks();
theChunkProviderServer.tick();
this.skylightSubtracted = this.calculateSkylightSubtracted(1.0F);
this.sendAndApplyBlockEvents();
worldInfo.incrementTotalWorldTime(worldInfo.getWorldTotalTime() + 1L);
worldInfo.setWorldTime(worldInfo.getWorldTime() + 1L);
profiler.endStartSection("tickPending");
this.tickUpdates(false);
profiler.endStartSection("tickTiles");
this.tickBlocksAndAmbiance();
profiler.endStartSection("chunkMap");