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