use of net.glowstone.generator.objects.FlowerType in project Glowstone by GlowstoneMC.
the class BlockGrass method grow.
@Override
public void grow(GlowPlayer player, GlowBlock block) {
GlowWorld world = block.getWorld();
int i = 0;
do {
int j = 0;
while (true) {
// if there's available space
if (block.getRelative(BlockFace.UP).getType() == Material.AIR) {
GlowBlock b = block.getRelative(BlockFace.UP);
GlowBlockState blockState = b.getState();
if (random.nextFloat() < 0.125D) {
// sometimes grow random flower
// would be better to call a method that choose a random
// flower depending on the biome
FlowerType[] flowers = FlowerForestPopulator.FLOWERS;
Material flower = flowers[random.nextInt(flowers.length)].getType();
if (ItemTable.instance().getBlock(flower).canPlaceAt(b, BlockFace.DOWN)) {
blockState.setType(flower);
}
} else {
Material tallGrass = Material.LONG_GRASS;
if (ItemTable.instance().getBlock(tallGrass).canPlaceAt(b, BlockFace.DOWN)) {
// grow tall grass if possible
blockState.setType(tallGrass);
blockState.setData(new LongGrass(GrassSpecies.NORMAL));
}
}
BlockGrowEvent growEvent = new BlockGrowEvent(b, blockState);
EventFactory.callEvent(growEvent);
if (!growEvent.isCancelled()) {
blockState.update(true);
}
} else if (j < i / 16) {
// look around for grass block
int x = block.getX();
int y = block.getY();
int z = block.getZ();
x += random.nextInt(3) - 1;
y += random.nextInt(3) * random.nextInt(3) / 2;
z += random.nextInt(3) - 1;
if (world.getBlockAt(x, y, z).getType() == Material.GRASS) {
j++;
continue;
}
}
i++;
break;
}
} while (i < 128);
}
use of net.glowstone.generator.objects.FlowerType in project Glowstone by GlowstoneMC.
the class FlowerForestPopulator method populateOnGround.
@Override
public void populateOnGround(World world, Random random, Chunk chunk) {
super.populateOnGround(world, random, chunk);
int sourceX = chunk.getX() << 4;
int sourceZ = chunk.getZ() << 4;
for (int i = 0; i < 100; i++) {
int x = sourceX + random.nextInt(16);
int z = sourceZ + random.nextInt(16);
int y = random.nextInt(world.getHighestBlockYAt(x, z) + 32);
double noise = (noiseGen.noise(x, z, 0.5D, 2.0D) + 1.0D) / 2.0D;
noise = noise < 0 ? 0 : noise > 0.9999D ? 0.9999D : noise;
FlowerType flower = FLOWERS[(int) (noise * FLOWERS.length)];
new Flower(flower).generate(world, random, x, y, z);
}
}
use of net.glowstone.generator.objects.FlowerType in project Glowstone by GlowstoneMC.
the class FlowerDecorator method decorate.
@Override
public void decorate(World world, Random random, Chunk source) {
int sourceX = (source.getX() << 4) + random.nextInt(16);
int sourceZ = (source.getZ() << 4) + random.nextInt(16);
int sourceY = random.nextInt(world.getHighestBlockYAt(sourceX, sourceZ) + 32);
// the flower can change on each decoration pass
FlowerType flower = getRandomFlower(random, flowers);
if (flower != null) {
new Flower(flower).generate(world, random, sourceX, sourceY, sourceZ);
}
}
use of net.glowstone.generator.objects.FlowerType in project Glowstone by GlowstoneMC.
the class PlainsPopulator method populateOnGround.
@Override
public void populateOnGround(World world, Random random, Chunk chunk) {
int sourceX = chunk.getX() << 4;
int sourceZ = chunk.getZ() << 4;
int flowerAmount = 15;
int tallGrassAmount = 5;
if (noiseGen.noise(sourceX + 8, sourceZ + 8, 0.5D, 2.0D) >= -0.8D) {
flowerAmount = 4;
tallGrassAmount = 10;
for (int i = 0; i < 7; i++) {
int x = sourceX + random.nextInt(16);
int z = sourceZ + random.nextInt(16);
int y = random.nextInt(world.getHighestBlockYAt(x, z) + 32);
new DoubleTallPlant(DoublePlantSpecies.DOUBLE_TALLGRASS).generate(world, random, x, y, z);
}
}
FlowerType flower = FlowerType.DANDELION;
if (noiseGen.noise(sourceX + 8, sourceZ + 8, 0.5D, 2.0D) < -0.8D) {
flower = TULIPS[random.nextInt(TULIPS.length)];
} else if (random.nextInt(3) > 0) {
flower = FLOWERS[random.nextInt(FLOWERS.length)];
}
for (int i = 0; i < flowerAmount; i++) {
int x = sourceX + random.nextInt(16);
int z = sourceZ + random.nextInt(16);
int y = random.nextInt(world.getHighestBlockYAt(x, z) + 32);
new Flower(flower).generate(world, random, x, y, z);
}
for (int i = 0; i < tallGrassAmount; i++) {
int x = sourceX + random.nextInt(16);
int z = sourceZ + random.nextInt(16);
int y = random.nextInt(world.getHighestBlockYAt(x, z) << 1);
new TallGrass(new LongGrass(GrassSpecies.NORMAL)).generate(world, random, x, y, z);
}
super.populateOnGround(world, random, chunk);
}
Aggregations