@Override public boolean setMode(World world, String modeName) { ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName); if (mode != null) { TreeManager.treeRoot.setTreekeepingMode(world, mode); return true; } return false; }
@Override public Iterable<String> getDescription(String modeName) { ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName); if (mode == null) { return Collections.emptyList(); } return mode.getDescription(); }
@Override public String getModeName(World world) { return TreeManager.treeRoot.getTreekeepingMode(world).getName(); }
private int determineHeight(World world, Random rand, int required, int variation) { ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); int baseHeight = required + rand.nextInt(variation); int height = Math.round(baseHeight * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); return height < minHeight ? minHeight : height > maxHeight ? maxHeight : height; } }
private int determineHeight(World world, Random rand, int required, int variation) { ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); int baseHeight = required + rand.nextInt(variation); int height = Math.round(baseHeight * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); return height < minHeight ? minHeight : height > maxHeight ? maxHeight : height; } }
private static int getRequiredMaturity(World world, ITree tree) { ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world); float maturationModifier = treekeepingMode.getMaturationModifier(tree.getGenome(), 1f); return Math.round(tree.getRequiredMaturity() * maturationModifier); }
/** * The chance that this leaves contains fruits or the chance that a pod block spawns. * * @param genome The genome of the tree of the pod / leaves block. * @return The chance that this leaves contains fruits or the chance that a pod block spawns. */ default float getFruitChance(ITreeGenome genome, World world, BlockPos pos) { ITreeRoot treeRoot = TreeManager.treeRoot; if (treeRoot == null) { return 0.0F; } float yieldModifier = treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1.0F); return genome.getYield() * yieldModifier * 2.5F; }
@Override public NonNullList<ItemStack> getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) { NonNullList<ItemStack> product = NonNullList.create(); float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f); for (Map.Entry<ItemStack, Float> entry : products.entrySet()) { if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue()) { product.add(entry.getKey().copy()); } } return product; }
protected int modifyByHeight(World world, int val, int min, int max) { ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); int determined = Math.round(val * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); return determined < min ? min : determined > max ? max : determined; }
@Override public float getChance(World world, BlockPos pos, IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, ITreeGenome genome0, ITreeGenome genome1) { float processedChance = super.getChance(world, pos, allele0, allele1, genome0, genome1, ForestryAPI.climateManager.getDefaultClimate(world, pos)); if (processedChance <= 0) { return 0; } processedChance *= getRoot().getTreekeepingMode(world).getMutationModifier(genome0, genome1, 1f); return processedChance; }
ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world); float sappinessModifier = treekeepingMode.getSappinessModifier(genome, 1f); float sappiness = genome.getSappiness() * sappinessModifier;