Search in sources :

Example 1 with BranchBlock

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;
    });
}
Also used : BranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock)

Example 2 with BranchBlock

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;
}
Also used : BlockState(net.minecraft.block.BlockState) BranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock) IWorld(net.minecraft.world.IWorld) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with BranchBlock

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;
}
Also used : BlockState(net.minecraft.block.BlockState) BranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock) IWorld(net.minecraft.world.IWorld) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with BranchBlock

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;
}
Also used : BlockState(net.minecraft.block.BlockState) BranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock) IWorld(net.minecraft.world.IWorld) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with BranchBlock

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;
}
Also used : GrowSignal(com.ferreusveritas.dynamictrees.systems.GrowSignal) BranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Direction(net.minecraft.util.Direction)

Aggregations

BranchBlock (com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock)8 BlockPos (net.minecraft.util.math.BlockPos)5 BlockState (net.minecraft.block.BlockState)4 IWorld (net.minecraft.world.IWorld)4 GrowSignal (com.ferreusveritas.dynamictrees.systems.GrowSignal)1 Block (net.minecraft.block.Block)1 Direction (net.minecraft.util.Direction)1 World (net.minecraft.world.World)1