Search in sources :

Example 6 with BranchBlock

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

Example 7 with BranchBlock

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

Example 8 with BranchBlock

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;
}
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)

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