Search in sources :

Example 1 with DynamicLeavesBlock

use of com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock in project minecolonies by Minecolonies.

the class DynamicTreeCompat method getDropsForLeaf.

/**
 * Returns drops of a dynamic seed as List
 *
 * @param world      world the Leaf is in
 * @param pos        position of the Leaf
 * @param blockState Blockstate of the Leaf
 * @param fortune    amount of fortune to use
 * @param leaf       The leaf to check
 */
@Override
public NonNullList<ItemStack> getDropsForLeaf(@NotNull final IWorld world, @NotNull final BlockPos pos, @NotNull final BlockState blockState, final int fortune, @NotNull final Block leaf) {
    if (isDynamicLeavesBlock(leaf)) {
        ItemStack stack = ((DynamicLeavesBlock) leaf).getFamily(blockState, world, pos).getCommonSpecies().getSeedStack(1);
        final NonNullList<ItemStack> list = NonNullList.create();
        list.add(stack);
        return list;
    }
    return NonNullList.create();
}
Also used : DynamicLeavesBlock(com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock) ItemStack(net.minecraft.item.ItemStack)

Example 2 with DynamicLeavesBlock

use of com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock in project DynamicTrees-BYG by DynamicTreesTeam.

the class DiagonalPalmFamily method createBranchBlock.

@Override
protected BranchBlock createBranchBlock() {
    final BasicBranchBlock branch = new BasicBranchBlock(this.getProperties()) {

        @Override
        public GrowSignal growIntoAir(World world, BlockPos pos, GrowSignal signal, int fromRadius) {
            final Species species = signal.getSpecies();
            final DynamicLeavesBlock leaves = species.getLeavesBlock().orElse(null);
            if (leaves != null) {
                if (fromRadius == getFamily().getPrimaryThickness()) {
                    // If we came from a twig (and we're not a stripped branch) then just make some leaves
                    if (isNextToBranch(world, pos, signal.dir.getOpposite())) {
                        signal.success = false;
                        return signal;
                    }
                    signal.success = leaves.growLeavesIfLocationIsSuitable(world, species.getLeavesProperties(), pos.above(), 0);
                    if (signal.success)
                        return leaves.branchOut(world, pos, signal);
                } else {
                    // Otherwise make a proper branch
                    return leaves.branchOut(world, pos, signal);
                }
            } else {
                // If the leaves block is null, the branch grows directly without checking for leaves requirements
                if (isNextToBranch(world, pos, signal.dir.getOpposite())) {
                    signal.success = false;
                    return signal;
                }
                setRadius(world, pos, getFamily().getPrimaryThickness(), null);
                signal.radius = getFamily().getSecondaryThickness();
                signal.success = true;
            }
            return signal;
        }
    };
    if (this.isFireProof())
        branch.setFireSpreadSpeed(0).setFlammability(0);
    return branch;
}
Also used : GrowSignal(com.ferreusveritas.dynamictrees.systems.GrowSignal) BlockPos(net.minecraft.util.math.BlockPos) DynamicLeavesBlock(com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock) World(net.minecraft.world.World) BasicBranchBlock(com.ferreusveritas.dynamictrees.blocks.branches.BasicBranchBlock) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 3 with DynamicLeavesBlock

use of com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock in project minecolonies by ldtteam.

the class DynamicTreeCompat method getDropsForLeaf.

/**
 * Returns drops of a dynamic seed as List
 *
 * @param world      world the Leaf is in
 * @param pos        position of the Leaf
 * @param blockState Blockstate of the Leaf
 * @param fortune    amount of fortune to use
 * @param leaf       The leaf to check
 */
@Override
public NonNullList<ItemStack> getDropsForLeaf(@NotNull final IWorld world, @NotNull final BlockPos pos, @NotNull final BlockState blockState, final int fortune, @NotNull final Block leaf) {
    if (isDynamicLeavesBlock(leaf)) {
        ItemStack stack = ((DynamicLeavesBlock) leaf).getFamily(blockState, world, pos).getCommonSpecies().getSeedStack(1);
        final NonNullList<ItemStack> list = NonNullList.create();
        list.add(stack);
        return list;
    }
    return NonNullList.create();
}
Also used : DynamicLeavesBlock(com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DynamicLeavesBlock (com.ferreusveritas.dynamictrees.blocks.leaves.DynamicLeavesBlock)3 ItemStack (net.minecraft.item.ItemStack)2 BasicBranchBlock (com.ferreusveritas.dynamictrees.blocks.branches.BasicBranchBlock)1 GrowSignal (com.ferreusveritas.dynamictrees.systems.GrowSignal)1 Species (com.ferreusveritas.dynamictrees.trees.Species)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1