BiomesOPlenty/common/biomesoplenty/worldgen/WorldGenFlowersMeta.java

46 lines
1.3 KiB
Java
Raw Normal View History

2013-06-01 06:59:56 +00:00
package biomesoplenty.worldgen;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
public class WorldGenFlowersMeta extends WorldGenerator
{
public final int plantID;
public final int metadata;
public int chances = 64;
public WorldGenFlowersMeta(int id, int meta)
{
this.plantID = id;
this.metadata = meta;
}
public WorldGenFlowersMeta(int id, int meta, int count)
{
this.plantID = id;
this.metadata = meta;
this.chances = count;
}
2013-07-01 00:31:34 +00:00
@Override
public boolean generate(World world, Random random, int x, int y, int z)
2013-06-01 06:59:56 +00:00
{
for (int iter = 0; iter < chances; ++iter)
{
int posX = x + random.nextInt(8) - random.nextInt(8);
int posY = y + random.nextInt(4) - random.nextInt(4);
int posZ = z + random.nextInt(8) - random.nextInt(8);
if (world.isAirBlock(posX, posY, posZ) && (!world.provider.hasNoSky || posY < 127) && Block.blocksList[this.plantID].canBlockStay(world, posX, posY, posZ))
{
world.setBlock(posX, posY, posZ, this.plantID, this.metadata, 2);
}
}
return true;
}
}