use of net.glowstone.generator.objects.trees.GenericTree in project Glowstone by GlowstoneMC.
the class TreeDecorator 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);
Block sourceBlock = world.getBlockAt(sourceX, world.getHighestBlockYAt(sourceX, sourceZ), sourceZ);
Class<? extends GenericTree> clazz = getRandomTree(random, trees);
if (clazz != null) {
BlockStateDelegate delegate = new BlockStateDelegate();
GenericTree tree;
try {
Constructor<? extends GenericTree> c = clazz.getConstructor(Random.class, Location.class, BlockStateDelegate.class);
tree = c.newInstance(random, sourceBlock.getLocation(), delegate);
} catch (Exception ex) {
tree = new GenericTree(random, sourceBlock.getLocation(), delegate);
}
if (tree.generate()) {
delegate.updateBlockStates();
}
}
}
Aggregations