BiomesOPlenty/common/biomesoplenty/worldgen/WorldGenCattail.java

40 lines
1.3 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.worldgen;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
2013-05-03 13:00:44 +00:00
public class WorldGenCattail extends WorldGenerator
{
2013-05-31 10:34:02 +00:00
@Override
public boolean generate(World world, Random par2Random, int par3, int par4, int par5)
{
int var11;
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
for (boolean var6 = false; ((var11 = world.getBlockId(par3, par4, par5)) == 0 || var11 == Block.leaves.blockID) && par4 > 0; --par4)
{
;
}
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
for (int var7 = 0; var7 < 128; ++var7)
{
int x = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
int y = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
int z = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
if (world.isAirBlock(x, y, z) && Blocks.plants.get().canBlockStay(world, x, y, z))
{
if ((world.getBlockMaterial(x - 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x + 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x, y - 1, z - 1) == Material.water ? true : world.getBlockMaterial(x, y - 1, z + 1) == Material.water)))) {
world.setBlock(x, y, z, Blocks.plants.get().blockID, 7, 2);
}
}
}
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
return true;
}
2013-05-03 13:00:44 +00:00
}