use of net.minecraft.world.level.block.BeehiveBlock in project ResourcefulBees by Resourceful-Bees.
the class ApiaryUpgradeRecipe method getRemainingItems.
@Override
@NotNull
public NonNullList<ItemStack> getRemainingItems(@NotNull CraftingContainer inventory) {
NonNullList<ItemStack> remainingItems = super.getRemainingItems(inventory);
for (int i = 0; i < inventory.getContainerSize(); i++) {
ItemStack item = inventory.getItem(i);
Block block = Block.byItem(item.getItem());
if (block instanceof ApiaryBlock || block instanceof BeehiveBlock) {
ItemStack box = getBeeBoxFromHive(item);
if (box == null)
continue;
remainingItems.set(i, box);
}
}
return remainingItems;
}
use of net.minecraft.world.level.block.BeehiveBlock 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;
}
use of net.minecraft.world.level.block.BeehiveBlock in project Create by Creators-of-Create.
the class DeployerHandler method safeOnBeehiveUse.
protected static InteractionResult safeOnBeehiveUse(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand) {
// <> BeehiveBlock#onUse
BeehiveBlock block = (BeehiveBlock) state.getBlock();
ItemStack prevHeldItem = player.getItemInHand(hand);
int honeyLevel = state.getValue(BeehiveBlock.HONEY_LEVEL);
boolean success = false;
if (honeyLevel < 5)
return InteractionResult.PASS;
if (prevHeldItem.getItem() == Items.SHEARS) {
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.NEUTRAL, 1.0F, 1.0F);
// <> BeehiveBlock#dropHoneycomb
player.getInventory().placeItemBackInInventory(new ItemStack(Items.HONEYCOMB, 3));
prevHeldItem.hurtAndBreak(1, player, s -> s.broadcastBreakEvent(hand));
success = true;
}
if (prevHeldItem.getItem() == Items.GLASS_BOTTLE) {
prevHeldItem.shrink(1);
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F);
ItemStack honeyBottle = new ItemStack(Items.HONEY_BOTTLE);
if (prevHeldItem.isEmpty())
player.setItemInHand(hand, honeyBottle);
else
player.getInventory().placeItemBackInInventory(honeyBottle);
success = true;
}
if (!success)
return InteractionResult.PASS;
block.resetHoneyLevel(world, state, pos);
return InteractionResult.SUCCESS;
}
Aggregations