use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class DTBYGRegistries method setupConnectables.
private static void setupConnectables() {
BranchConnectables.makeBlockConnectable(BYGBlocks.POLLEN_BLOCK, (state, world, pos, side) -> {
if (side == Direction.DOWN)
return 1;
return 0;
});
BranchConnectables.makeBlockConnectable(BYGBlocks.PURPLE_SHROOMLIGHT, (state, world, pos, side) -> {
if (side == Direction.DOWN) {
BlockState branchState = world.getBlockState(pos.relative(Direction.UP));
BranchBlock branch = TreeHelper.getBranch(branchState);
if (branch != null)
return MathHelper.clamp(branch.getRadius(branchState) - 1, 1, 8);
else
return 8;
}
return 0;
});
BranchConnectables.makeBlockConnectable(ARISIAN_BLOOM_BRANCH, (state, world, pos, side) -> {
if (state.hasProperty(HorizontalBlock.FACING)) {
return state.getValue(HorizontalBlock.FACING) == side ? 1 : 0;
}
return 0;
});
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class AlternativeBranchGenFeature method postGenerate.
@Override
protected boolean postGenerate(GenFeatureConfiguration configuration, PostGenerationContext context) {
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)) {
placeAltBranches(true, configuration, world, rootPos, context.species().getFamily());
}
return true;
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class AlternativeBranchGenFeature 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)) {
placeAltBranches(false, configuration, world, rootPos, context.species().getFamily());
}
}
return true;
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class BranchSproutsGenFeature method postGenerate.
@Override
protected boolean postGenerate(GenFeatureConfiguration configuration, PostGenerationContext context) {
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)) {
int count = 1 + world.getRandom().nextInt(configuration.get(MAX_COUNT));
placeSprouts(count, configuration, world, rootPos);
}
return true;
}
use of com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock in project DynamicTrees-BYG by DynamicTreesTeam.
the class BaobabLogic method populateDirectionProbabilityMap.
@Override
public int[] populateDirectionProbabilityMap(GrowthLogicKitConfiguration configuration, DirectionManipulationContext context) {
final World world = context.world();
final GrowSignal signal = context.signal();
final int[] probMap = context.probMap();
final BlockPos pos = context.pos();
Direction originDir = signal.dir.getOpposite();
if (!signal.isInTrunk()) {
Direction relativePosToRoot = Direction.fromNormal(signal.delta.getX(), 0, signal.delta.getY());
if (relativePosToRoot != null) {
if (signal.energy > 2) {
// Flaring at end points, higher min energy means more flaring
probMap[Direction.DOWN.ordinal()] = 0;
for (Direction dir : CoordUtils.HORIZONTALS) {
probMap[dir.ordinal()] = 0;
}
}
boolean isBranchUp = world.getBlockState(pos.offset(relativePosToRoot.getNormal())).getBlock() instanceof BranchBlock;
boolean isBranchSide = world.getBlockState(pos.above()).getBlock() instanceof BranchBlock;
probMap[Direction.UP.ordinal()] = isBranchUp && !isBranchSide ? 0 : 2;
probMap[relativePosToRoot.ordinal()] = isBranchSide && !isBranchUp ? 0 : 3;
}
}
probMap[originDir.ordinal()] = 0;
return probMap;
}
Aggregations