Search in sources :

Example 1 with TieredBeehiveBlock

use of com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock in project ResourcefulBees by Resourceful-Bees.

the class ShearsDispenserBehavior method execute.

@NotNull
@Override
protected ItemStack execute(@NotNull BlockSource source, @NotNull ItemStack stack) {
    ServerLevel world = source.getLevel();
    BlockPos blockpos = source.getPos().relative(source.getBlockState().getValue(DispenserBlock.FACING));
    BlockState blockstate = world.getBlockState(blockpos);
    if (blockstate.getBlock() instanceof TieredBeehiveBlock) {
        if (Config.ALLOW_SHEARS.get()) {
            int i = blockstate.getValue(BeehiveBlock.HONEY_LEVEL);
            if (i >= 5) {
                if (stack.hurt(1, world.random, null)) {
                    stack.setCount(0);
                }
                TieredBeehiveBlock.dropResourceHoneycomb((TieredBeehiveBlock) blockstate.getBlock(), world, blockpos, false);
                ((BeehiveBlock) blockstate.getBlock()).releaseBeesAndResetHoneyLevel(world, blockstate, blockpos, null, BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
            }
        }
    } else {
        return getDefaultShearsDispenseBehavior().dispense(source, stack);
    }
    return stack;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) BeehiveBlock(net.minecraft.world.level.block.BeehiveBlock) TieredBeehiveBlock(com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock) TieredBeehiveBlock(com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TieredBeehiveBlock

use of com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock in project ResourcefulBees by Resourceful-Bees.

the class ScraperDispenserBehavior method execute.

@NotNull
@Override
protected ItemStack execute(@NotNull BlockSource source, @NotNull ItemStack stack) {
    ServerLevel world = source.getLevel();
    BlockPos blockpos = source.getPos().relative(source.getBlockState().getValue(DispenserBlock.FACING));
    BlockState blockstate = world.getBlockState(blockpos);
    if (blockstate.getBlock() instanceof TieredBeehiveBlock) {
        int i = blockstate.getValue(BeehiveBlock.HONEY_LEVEL);
        if (i >= 5) {
            if (stack.hurt(1, world.random, null)) {
                stack.setCount(0);
            }
            if (TieredBeehiveBlock.dropResourceHoneycomb((TieredBeehiveBlock) blockstate.getBlock(), world, blockpos, true)) {
                ((BeehiveBlock) blockstate.getBlock()).releaseBeesAndResetHoneyLevel(world, blockstate, blockpos, null, BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
            }
        }
    }
    return stack;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) TieredBeehiveBlock(com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock) BeehiveBlock(net.minecraft.world.level.block.BeehiveBlock) TieredBeehiveBlock(com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TieredBeehiveBlock (com.teamresourceful.resourcefulbees.block.TieredBeehiveBlock)2 BlockPos (net.minecraft.core.BlockPos)2 ServerLevel (net.minecraft.server.level.ServerLevel)2 BeehiveBlock (net.minecraft.world.level.block.BeehiveBlock)2 BlockState (net.minecraft.world.level.block.state.BlockState)2 NotNull (org.jetbrains.annotations.NotNull)2