use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class AlternativeBranchGenFeature method shouldApply.
@Override
public boolean shouldApply(Species species, GenFeatureConfiguration configuration) {
Block branch = configuration.get(ALT_BRANCH_BLOCK);
if (TreeHelper.isBranch(branch) && species.getFamily().isValidBranchBlock((BranchBlock) branch)) {
return true;
}
LogManager.getLogger().warn("Failed to find branch block for the alternative branch feature on species {}", species);
return false;
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class AlternativeBranchGenFeature method placeBranch.
private void placeBranch(GenFeatureConfiguration configuration, IWorld world, BlockPos pos) {
BranchBlock branchToPlace = (BranchBlock) configuration.get(ALT_BRANCH_BLOCK);
int radius = TreeHelper.getRadius(world, pos);
branchToPlace.setRadius(world, pos, radius, null);
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class BranchSproutsGenFeature method postGrow.
@Override
protected boolean postGrow(GenFeatureConfiguration configuration, PostGrowContext context) {
if (context.fertility() == 0)
return false;
IWorld world = context.world();
BlockPos rootPos = context.pos();
final BlockState blockState = world.getBlockState(rootPos.above());
final BranchBlock branch = TreeHelper.getBranch(blockState);
if (branch != null && branch.getRadius(blockState) >= configuration.get(FRUITING_RADIUS) && context.natural()) {
if (world.getRandom().nextFloat() < configuration.get(PLACE_CHANCE)) {
placeSprouts(1, configuration, world, rootPos);
}
}
return true;
}
Aggregations