public boolean genIsland(World world, int radius, int xIn, int yIn, int zIn)
{
FloatingRuins.baseDepth = Math.max(2, Math.min(50, FloatingRuins.baseDepth));
FloatingRuins.depthVariation = Math.max(0, Math.min(50, FloatingRuins.depthVariation));
int specialOre = getSpecialOre();
Random random = new Random();
float depthRatio = random.nextInt(5) == 0 ? random.nextFloat() * 0.5F + 2.0F : random.nextFloat() * 0.2F + 0.4F;
int height = (int)Math.ceil((float)radius * depthRatio);
int yg = CommonUtils.getLowestGroundBlock(world, xIn, yIn - height, zIn);
for(int x = -radius; x <= radius; x++)
for(int y = 15; y >= -height; y--)
for(int z = -radius; z <= radius; z++)
{
float dist = Math.round(Math.sqrt(Math.pow(x, 2D) + Math.pow(z, 2D) + (y > 0 ? 0.0D : Math.pow((float)y / depthRatio, 2D))));
int block = world.getBlockId(x + xIn, yg + y, z + zIn);
if(dist <= (float)radius)
{
int metadata = world.getBlockMetadata(x + xIn, yg + y, z + zIn);
if((y <= 0) || (block != Block.waterStill.blockID && block != Block.waterMoving.blockID
&& (world.isBlockNormalCube(x + xIn, yg + y, z + zIn) || block == Block.leaves.blockID)
&& !CommonUtils.isItemInList(block, metadata, FloatingRuins.blockIDBlacklist)))
{
world.setBlockAndMetadata(x + xIn, y + yIn, z + zIn, block, metadata);
world.setBlockWithNotify(x + xIn, yg + y, z + zIn, 0);
}
}
if(random.nextInt(3) == 0 && world.getBlockId(x + xIn, y + yIn, z + zIn) == Block.stone.blockID && Math.abs(x) <= 1 && Math.abs(z) <= 1 &&
Math.abs(y + height / 2) <= 2)
world.setBlock(x + xIn, y + yIn, z + zIn, specialOre);
}
if(depthRatio < 1.0F)
for(int x = -radius; x <= radius; x++)
for(int y = 5; y >= -height; y--)
for(int z = -radius; z <= radius; z++)
{
int block = world.getBlockId(x + xIn, y + yIn, z + zIn);
if(block != 0 && world.isAirBlock(x + xIn, (y + yIn) - 1, z + zIn))
if(block == Block.gravel.blockID)
world.setBlock(x + xIn, y + yIn, z + zIn, Block.stone.blockID);
else if(block == Block.sand.blockID)
world.setBlock(x + xIn, y + yIn, z + zIn, Block.sandStone.blockID);
}
return true;
}
Comments