{
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--)
{
if (local_y >= 0 && local_y < this.worldSettings.worldHeightCap)
{
LocalMaterialData material = generatingChunkBuffer.getBlock(local_x, local_y, local_z);
if (material.isMaterial(DefaultMaterial.WATER)
|| material.isMaterial(DefaultMaterial.STATIONARY_WATER))
{
waterFound = true;
}
if ((local_y != i1 - 1) && (local_x != m) && (local_x != n - 1) && (local_z != i3) && (local_z != i4 - 1))
local_y = i1;
}
}
}
}
if (waterFound)
continue;
// Generate cave
for (int local_x = m; local_x < n; local_x++)
{
double d9 = (local_x + generatingChunk.getBlockX() + 0.5D - x) / d3;
for (int local_z = i3; local_z < i4; local_z++)
{
LocalBiome biome = this.world.getBiome(local_x + generatingChunk.getBlockX(), local_z + generatingChunk.getBlockZ());
double d10 = (local_z + generatingChunk.getBlockZ() + 0.5D - z) / d3;
boolean grassFound = false;
if (d9 * d9 + d10 * d10 < 1.0D)
{
for (int local_y = i2; local_y > i1; local_y--)
{
double d11 = ((local_y - 1) + 0.5D - y) / d4;
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D))
{
LocalMaterialData material = generatingChunkBuffer.getBlock(local_x, local_y, local_z);
LocalMaterialData materialAbove = generatingChunkBuffer.getBlock(local_x, local_y + 1, local_z);
if (material.isMaterial(DefaultMaterial.GRASS) || material.isMaterial(DefaultMaterial.MYCEL))
grassFound = true;
if (this.isSuitableBlock(material, materialAbove, biome))
{
if (local_y - 1 < 10)
{
generatingChunkBuffer.setBlock(local_x, local_y, local_z, lava);
} else
{
generatingChunkBuffer.setBlock(local_x, local_y, local_z, air);
// Replace supporting sand with
// sandstone. TODO: support red
// sand(stone) in Minecraft 1.8
if (materialAbove.isMaterial(DefaultMaterial.SAND) && materialAbove.getBlockData() == 0)
{
generatingChunkBuffer.setBlock(local_x, local_y + 1, local_z, sandstone);
}
// If grass was just deleted, try to