use of com.ferreusveritas.dynamictrees.systems.nodemappers.NodeShrinker in project DynamicTrees by DynamicTreesTeam.
the class Species method grow.
/**
* The grow handler.
*
* @param world The world
* @param rootyDirt The {@link BlockRooty} that is supporting this tree
* @param rootPos The {@link BlockPos} of the {@link BlockRooty} type in the world
* @param soilLife The life of the soil. 0: Depleted -> 15: Full
* @param treePos The {@link BlockPos} of the {@link TreeFamily} trunk base.
* @param random A random number generator
* @param natural If true then this member is being used to grow the tree naturally(create drops or fruit). If
* false then this member is being used to grow a tree with a growth accelerant like bonemeal or
* the potion of burgeoning
* @return true if network is viable. false if network is not viable(will destroy the {@link BlockRooty} this tree
* is on)
*/
public boolean grow(World world, BlockRooty rootyDirt, BlockPos rootPos, int soilLife, ITreePart treeBase, BlockPos treePos, Random random, boolean natural) {
float growthRate = getGrowthRate(world, rootPos) * ModConfigs.treeGrowthMultiplier * ModConfigs.treeGrowthFolding;
do {
if (soilLife > 0) {
if (growthRate > random.nextFloat()) {
GrowSignal signal = new GrowSignal(this, rootPos, getEnergy(world, rootPos));
boolean success = treeBase.growSignal(world, treePos, signal).success;
int soilLongevity = getSoilLongevity(world, rootPos) * // Don't deplete the soil as much if the grow operation failed
(success ? 1 : 16);
if (soilLongevity <= 0 || random.nextInt(soilLongevity) == 0) {
// 1 in X(soilLongevity) chance to draw nutrients from soil
// decrement soil life
rootyDirt.setSoilLife(world, rootPos, soilLife - 1);
}
if (signal.choked) {
soilLife = 0;
rootyDirt.setSoilLife(world, rootPos, soilLife);
TreeHelper.startAnalysisFromRoot(world, rootPos, new MapSignal(new NodeShrinker(signal.getSpecies())));
}
}
}
} while (--growthRate > 0.0f);
return postGrow(world, rootPos, treePos, soilLife, natural);
}
Aggregations