public static WorldGenerator getWorldGen(String treeName, EntityPlayer player, BlockPos pos) throws SpeciesNotFoundException { ITreeGenome treeGenome = getTreeGenome(treeName); ITree tree = TreeManager.treeRoot.getTree(player.world, treeGenome); return tree.getTreeGenerator(player.world, pos, true); }
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; }
public boolean canAcceptBoneMeal(Random rand) { ITree tree = getTree(); if (tree == null) { return false; } int maturity = getRequiredMaturity(world, tree); if (timesTicked < maturity) { return true; } WorldGenerator generator = tree.getTreeGenerator(world, getPos(), true); if (generator instanceof WorldGenArboriculture) { WorldGenArboriculture arboricultureGenerator = (WorldGenArboriculture) generator; arboricultureGenerator.preGenerate(world, rand, getPos()); return arboricultureGenerator.getValidGrowthPos(world, getPos()) != null; } else { return true; } }
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); } }