boolean flagXZUChunk = w.getChunkProvider().chunkExists(cx - 1, cz + 1);
boolean flagXZDChunk = w.getChunkProvider().chunkExists(cx - 1, cz - 1);
for (int j = 0; j < 16; j++)
{
if (chunk.getBlockStorageArray()[j] == null) chunk.getBlockStorageArray()[j] = new ExtendedBlockStorage(j, false);
}
int i = chunk.getTopFilledSegment();
chunk.heightMapMinimum = Integer.MAX_VALUE;
for (int j = 0; j < 16; ++j)
{
int k = 0;
while (k < 16)
{
chunk.precipitationHeightMap[j + (k << 4)] = -999;
int y = i + 15;
while (true)
{
if (y > 0)
{
if (chunk.func_150808_b(j, y - 1, k) == 0)
{
--y;
continue;
}
chunk.heightMap[k << 4 | j] = y;
if (y < chunk.heightMapMinimum)
{
chunk.heightMapMinimum = y;
}
}
++k;
break;
}
}
}
for (AsteroidData a : this.largeAsteroids)
{
int yMin = a.asteroidYArray - a.asteroidSizeArray;
int yMax = a.asteroidYArray + a.asteroidSizeArray;
int xMin = a.xMinArray;
if (yMin < 0) yMin = 0;
if (yMax > 255) yMax = 255;
if (xMin == 0) xMin = 1;
for (int x = a.xMax - 1; x >= xMin; x--)
{
for (int z = a.zMinArray; z < a.zMax; z++)
{
for (int y = yMin; y < yMax; y++)
{
if (chunk.getBlock(x - 1, y, z) instanceof BlockAir && !(chunk.getBlock(x, y, z) instanceof BlockAir))
{
int count = 2;
if (x > 1)
{
if ((chunk.getBlock(x - 2, y, z) instanceof BlockAir)) count+=2;
}
if (x > 2)
{
if ((chunk.getBlock(x - 3, y, z) instanceof BlockAir)) count+=2;
if ((chunk.getBlock(x - 3, y + 1, z) instanceof BlockAir)) count++;
if ((chunk.getBlock(x - 3, y + 1, z) instanceof BlockAir)) count++;
if ((z > 0 /*|| ((xPos & 15) > 2 ? flagZDChunk : flagXZDChunk)*/) && (chunk.getBlock(x - 3, y, z - 1) instanceof BlockAir)) count++;
if ((z < 15/* || ((xPos & 15) > 2 ? flagZUChunk : flagXZUChunk)*/) && (chunk.getBlock(x - 3, y, z + 1) instanceof BlockAir)) count++;
}
if (/*flagXChunk || */x > 3)
{
if ((chunk.getBlock(x - 4, y, z) instanceof BlockAir)) count+=2;
if ((chunk.getBlock(x - 4, y + 1, z) instanceof BlockAir)) count++;
if ((chunk.getBlock(x - 4, y + 1, z) instanceof BlockAir)) count++;
if ((z > 0/* || ((xPos & 15) > 3 ? flagZDChunk : flagXZDChunk)*/) && !(chunk.getBlock(x - 4, y, z - 1) instanceof BlockAir)) count++;
if ((z < 15/* || ((xPos & 15) > 3 ? flagZUChunk : flagXZUChunk)*/) && !(chunk.getBlock(x - 4, y, z + 1) instanceof BlockAir)) count++;
}
if (count > 12) count = 12;
chunk.func_150807_a(x - 1, y & 15, z, GCBlocks.brightAir, 15 - count);
ExtendedBlockStorage extendedblockstorage = chunk.getBlockStorageArray()[y >> 4];
if (extendedblockstorage != null)
{
extendedblockstorage.setExtBlocklightValue(x - 1, y & 15, z, count);
}
}
}
}
}