final Random rand = randoms.get();
final Iterator<ChunkCoordIntPair> chunkCoordIterator = this.chunkCoordIterator;
final ChunkProviderServer chunkProviderServer = this.theChunkProviderServer;
final boolean isRaining = this.isRaining();
final boolean isThundering = this.isThundering();
final WorldProvider provider = this.provider;
int updateLCG = this.updateLCG;
// We use a random per thread - randoms are threadsafe, however it can result in some contention. See Random.nextInt - compareAndSet.
// This reduces contention -> slightly increased performance, woo! :P
while (true) {
ChunkCoordIntPair chunkCoordIntPair;
synchronized (chunkCoordIterator) {
if (!chunkCoordIterator.hasNext()) {
break;
}
try {
chunkCoordIntPair = chunkCoordIterator.next();
} catch (ConcurrentModificationException e) {
break;
}
}
if (tpsFactor < 1 && rand.nextFloat() > tpsFactor) {
continue;
}
int cX = chunkCoordIntPair.chunkXPos;
int cZ = chunkCoordIntPair.chunkZPos;
Chunk chunk = chunkProviderServer.getChunkFastUnsafe(cX, cZ);
if (chunk == null || !chunk.isTerrainPopulated || chunk.partiallyUnloaded || chunk.queuedUnload) {
continue;
}
int xPos = cX * 16;
int zPos = cZ * 16;
this.moodSoundAndLightCheck(xPos, zPos, chunk);
chunk.updateSkylight();
int var8;
int var9;
int var10;
int var11;
if (isRaining && isThundering && provider.canDoLightning(chunk) && rand.nextInt(100000) == 0) {
updateLCG = updateLCG * 1664525 + 1013904223;
var8 = updateLCG >> 2;
var9 = xPos + (var8 & 15);
var10 = zPos + (var8 >> 8 & 15);
var11 = this.getPrecipitationHeight(var9, var10);
if (this.canLightningStrikeAt(var9, var11, var10)) {
this.addWeatherEffect(new EntityLightningBolt(this, (double) var9, (double) var11, (double) var10));
}
}
int blockID;
if (provider.canDoRainSnowIce(chunk) && rand.nextInt(16) == 0) {
updateLCG = updateLCG * 1664525 + 1013904223;
var8 = updateLCG >> 2;
var9 = var8 & 15;
var10 = var8 >> 8 & 15;
var11 = this.getPrecipitationHeight(var9 + xPos, var10 + zPos);