use of forestry.core.worldgen.WorldGenBase in project ForestryMC by ForestryMC.
the class TileSapling method tryGrow.
public void tryGrow(Random random, boolean bonemealed) {
ITree tree = getTree();
if (tree == null) {
return;
}
int maturity = getRequiredMaturity(world, tree);
if (timesTicked < maturity) {
if (bonemealed) {
timesTicked = maturity;
}
return;
}
WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
final boolean generated;
if (generator instanceof WorldGenBase) {
generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
} else {
generated = generator.generate(world, random, getPos());
}
if (generated) {
IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
breedingTracker.registerBirth(tree);
}
}
use of forestry.core.worldgen.WorldGenBase in project ForestryMC by ForestryMC.
the class TreeGenHelper method generateTree.
public static boolean generateTree(ITree tree, World world, BlockPos pos) {
WorldGenerator gen = tree.getTreeGenerator(world, pos, true);
IBlockState blockState = world.getBlockState(pos);
if (BlockUtil.canPlaceTree(blockState, world, pos)) {
if (gen instanceof WorldGenBase) {
return ((WorldGenBase) gen).generate(world, world.rand, pos, true);
} else {
return gen.generate(world, world.rand, pos);
}
}
return false;
}
Aggregations