Search in sources :

Example 1 with WorldGenBase

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);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBreedingTracker(forestry.api.genetics.IBreedingTracker) ITree(forestry.api.arboriculture.ITree) WorldGenBase(forestry.core.worldgen.WorldGenBase)

Example 2 with WorldGenBase

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;
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenBase(forestry.core.worldgen.WorldGenBase)

Aggregations

WorldGenBase (forestry.core.worldgen.WorldGenBase)2 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)2 ITree (forestry.api.arboriculture.ITree)1 IBreedingTracker (forestry.api.genetics.IBreedingTracker)1 IBlockState (net.minecraft.block.state.IBlockState)1