package net.minecraft.core.dispenser;

import net.minecraft.world.level.block.state.AbstractStateHolder;
import java.util.Iterator;
import java.util.List;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.entity.animal.Sheep;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.BeehiveBlock;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.ShulkerBoxBlock;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.CarvedPumpkinBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.level.block.SkullBlock;
import net.minecraft.world.level.block.WitherSkullBlock;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.item.FlintAndSteelItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.entity.vehicle.Boat;
import java.util.Random;
import net.minecraft.world.entity.projectile.SmallFireball;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
import net.minecraft.world.entity.projectile.Snowball;
import net.minecraft.Util;
import net.minecraft.world.entity.projectile.ThrownEgg;
import net.minecraft.world.entity.projectile.SpectralArrow;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.core.Position;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockSource;

public interface DispenseItemBehavior {
    public static final DispenseItemBehavior NOOP = (fl, ben) -> ben;
    
    ItemStack dispense(final BlockSource fl, final ItemStack ben);
    
    default void bootStrap() {
        DispenserBlock.registerBehavior(Items.ARROW, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                final Arrow ayp5 = new Arrow(bjw, fz.x(), fz.y(), fz.z());
                ayp5.pickup = AbstractArrow.Pickup.ALLOWED;
                return ayp5;
            }
        });
        DispenserBlock.registerBehavior(Items.TIPPED_ARROW, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                final Arrow ayp5 = new Arrow(bjw, fz.x(), fz.y(), fz.z());
                ayp5.setEffectsFromItem(ben);
                ayp5.pickup = AbstractArrow.Pickup.ALLOWED;
                return ayp5;
            }
        });
        DispenserBlock.registerBehavior(Items.SPECTRAL_ARROW, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                final AbstractArrow ayn5 = new SpectralArrow(bjw, fz.x(), fz.y(), fz.z());
                ayn5.pickup = AbstractArrow.Pickup.ALLOWED;
                return ayn5;
            }
        });
        DispenserBlock.registerBehavior(Items.EGG, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                return Util.<ThrownEgg>make(new ThrownEgg(bjw, fz.x(), fz.y(), fz.z()), azg -> azg.setItem(ben));
            }
        });
        DispenserBlock.registerBehavior(Items.SNOWBALL, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                return Util.<Snowball>make(new Snowball(bjw, fz.x(), fz.y(), fz.z()), azc -> azc.setItem(ben));
            }
        });
        DispenserBlock.registerBehavior(Items.EXPERIENCE_BOTTLE, new AbstractProjectileDispenseBehavior() {
            @Override
            protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                return Util.<ThrownExperienceBottle>make(new ThrownExperienceBottle(bjw, fz.x(), fz.y(), fz.z()), azi -> azi.setItem(ben));
            }
            
            @Override
            protected float getUncertainty() {
                return super.getUncertainty() * 0.5f;
            }
            
            @Override
            protected float getPower() {
                return super.getPower() * 1.25f;
            }
        });
        DispenserBlock.registerBehavior(Items.SPLASH_POTION, new DispenseItemBehavior() {
            @Override
            public ItemStack dispense(final BlockSource fl, final ItemStack ben) {
                return new AbstractProjectileDispenseBehavior() {
                    @Override
                    protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                        return Util.<ThrownPotion>make(new ThrownPotion(bjw, fz.x(), fz.y(), fz.z()), azj -> azj.setItem(ben));
                    }
                    
                    @Override
                    protected float getUncertainty() {
                        return super.getUncertainty() * 0.5f;
                    }
                    
                    @Override
                    protected float getPower() {
                        return super.getPower() * 1.25f;
                    }
                }.dispense(fl, ben);
            }
        });
        DispenserBlock.registerBehavior(Items.LINGERING_POTION, new DispenseItemBehavior() {
            @Override
            public ItemStack dispense(final BlockSource fl, final ItemStack ben) {
                return new AbstractProjectileDispenseBehavior() {
                    @Override
                    protected Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben) {
                        return Util.<ThrownPotion>make(new ThrownPotion(bjw, fz.x(), fz.y(), fz.z()), azj -> azj.setItem(ben));
                    }
                    
                    @Override
                    protected float getUncertainty() {
                        return super.getUncertainty() * 0.5f;
                    }
                    
                    @Override
                    protected float getPower() {
                        return super.getPower() * 1.25f;
                    }
                }.dispense(fl, ben);
            }
        });
        final DefaultDispenseItemBehavior gk1 = new DefaultDispenseItemBehavior() {
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Direction fp4 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
                final EntityType<?> aku5 = ((SpawnEggItem)ben.getItem()).getType(ben.getTag());
                aku5.spawn(fl.getLevel(), ben, null, fl.getPos().relative(fp4), MobSpawnType.DISPENSER, fp4 != Direction.UP, false);
                ben.shrink(1);
                return ben;
            }
        };
        for (final SpawnEggItem bfl3 : SpawnEggItem.eggs()) {
            DispenserBlock.registerBehavior(bfl3, gk1);
        }
        DispenserBlock.registerBehavior(Items.ARMOR_STAND, new DefaultDispenseItemBehavior() {
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Direction fp4 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
                final BlockPos fk5 = fl.getPos().relative(fp4);
                final Level bjw6 = fl.getLevel();
                final ArmorStand avp7 = new ArmorStand(bjw6, fk5.getX() + 0.5, fk5.getY(), fk5.getZ() + 0.5);
                EntityType.updateCustomEntityTag(bjw6, null, avp7, ben.getTag());
                avp7.yRot = fp4.toYRot();
                bjw6.addFreshEntity(avp7);
                ben.shrink(1);
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Items.FIREWORK_ROCKET, new DefaultDispenseItemBehavior() {
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Direction fp4 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
                final double double5 = fp4.getStepX();
                final double double6 = fp4.getStepY();
                final double double7 = fp4.getStepZ();
                final double double8 = fl.x() + double5;
                final double double9 = fl.getPos().getY() + 0.2f;
                final double double10 = fl.z() + double7;
                final FireworkRocketEntity ayu17 = new FireworkRocketEntity(fl.getLevel(), ben, double8, double9, double10, true);
                ayu17.shoot(double5, double6, double7, 0.5f, 1.0f);
                fl.getLevel().addFreshEntity(ayu17);
                ben.shrink(1);
                return ben;
            }
            
            @Override
            protected void playSound(final BlockSource fl) {
                fl.getLevel().levelEvent(1004, fl.getPos(), 0);
            }
        });
        DispenserBlock.registerBehavior(Items.FIRE_CHARGE, new DefaultDispenseItemBehavior() {
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Direction fp4 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
                final Position fz5 = DispenserBlock.getDispensePosition(fl);
                final double double6 = fz5.x() + fp4.getStepX() * 0.3f;
                final double double7 = fz5.y() + fp4.getStepY() * 0.3f;
                final double double8 = fz5.z() + fp4.getStepZ() * 0.3f;
                final Level bjw12 = fl.getLevel();
                final Random random13 = bjw12.random;
                final double double9 = random13.nextGaussian() * 0.05 + fp4.getStepX();
                final double double10 = random13.nextGaussian() * 0.05 + fp4.getStepY();
                final double double11 = random13.nextGaussian() * 0.05 + fp4.getStepZ();
                bjw12.addFreshEntity(Util.<SmallFireball>make(new SmallFireball(bjw12, double6, double7, double8, double9, double10, double11), azb -> azb.setItem(ben)));
                ben.shrink(1);
                return ben;
            }
            
            @Override
            protected void playSound(final BlockSource fl) {
                fl.getLevel().levelEvent(1018, fl.getPos(), 0);
            }
        });
        DispenserBlock.registerBehavior(Items.OAK_BOAT, new BoatDispenseItemBehavior(Boat.Type.OAK));
        DispenserBlock.registerBehavior(Items.SPRUCE_BOAT, new BoatDispenseItemBehavior(Boat.Type.SPRUCE));
        DispenserBlock.registerBehavior(Items.BIRCH_BOAT, new BoatDispenseItemBehavior(Boat.Type.BIRCH));
        DispenserBlock.registerBehavior(Items.JUNGLE_BOAT, new BoatDispenseItemBehavior(Boat.Type.JUNGLE));
        DispenserBlock.registerBehavior(Items.DARK_OAK_BOAT, new BoatDispenseItemBehavior(Boat.Type.DARK_OAK));
        DispenserBlock.registerBehavior(Items.ACACIA_BOAT, new BoatDispenseItemBehavior(Boat.Type.ACACIA));
        final DispenseItemBehavior gl2 = new DefaultDispenseItemBehavior() {
            private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior();
            
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final BucketItem bcx4 = (BucketItem)ben.getItem();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final Level bjw6 = fl.getLevel();
                if (bcx4.emptyBucket(null, bjw6, fk5, null)) {
                    bcx4.checkExtraContent(bjw6, ben, fk5);
                    return new ItemStack(Items.BUCKET);
                }
                return this.defaultDispenseItemBehavior.dispense(fl, ben);
            }
        };
        DispenserBlock.registerBehavior(Items.LAVA_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.WATER_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.SALMON_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.COD_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.PUFFERFISH_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.TROPICAL_FISH_BUCKET, gl2);
        DispenserBlock.registerBehavior(Items.BUCKET, new DefaultDispenseItemBehavior() {
            private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior();
            
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final LevelAccessor bjx4 = fl.getLevel();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final BlockState byj6 = bjx4.getBlockState(fk5);
                final Block bph7 = byj6.getBlock();
                if (!(bph7 instanceof BucketPickup)) {
                    return super.execute(fl, ben);
                }
                final Fluid coi9 = ((BucketPickup)bph7).takeLiquid(bjx4, fk5, byj6);
                if (!(coi9 instanceof FlowingFluid)) {
                    return super.execute(fl, ben);
                }
                final Item bei8 = coi9.getBucket();
                ben.shrink(1);
                if (ben.isEmpty()) {
                    return new ItemStack(bei8);
                }
                if (fl.<DispenserBlockEntity>getEntity().addItem(new ItemStack(bei8)) < 0) {
                    this.defaultDispenseItemBehavior.dispense(fl, new ItemStack(bei8));
                }
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Items.FLINT_AND_STEEL, new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Level bjw4 = fl.getLevel();
                this.success = true;
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final BlockState byj6 = bjw4.getBlockState(fk5);
                if (FlintAndSteelItem.canUse(byj6, bjw4, fk5)) {
                    bjw4.setBlockAndUpdate(fk5, Blocks.FIRE.defaultBlockState());
                }
                else if (FlintAndSteelItem.canLightCampFire(byj6)) {
                    bjw4.setBlockAndUpdate(fk5, ((AbstractStateHolder<O, BlockState>)byj6).<Comparable, Boolean>setValue((Property<Comparable>)BlockStateProperties.LIT, true));
                }
                else if (byj6.getBlock() instanceof TntBlock) {
                    TntBlock.explode(bjw4, fk5);
                    bjw4.removeBlock(fk5, false);
                }
                else {
                    this.success = false;
                }
                if (this.success && ben.hurt(1, bjw4.random, null)) {
                    ben.setCount(0);
                }
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Items.BONE_MEAL, new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                this.success = true;
                final Level bjw4 = fl.getLevel();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                if (BoneMealItem.growCrop(ben, bjw4, fk5) || BoneMealItem.growWaterPlant(ben, bjw4, fk5, null)) {
                    if (!bjw4.isClientSide) {
                        bjw4.levelEvent(2005, fk5, 0);
                    }
                }
                else {
                    this.success = false;
                }
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Blocks.TNT, new DefaultDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Level bjw4 = fl.getLevel();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final PrimedTnt awc6 = new PrimedTnt(bjw4, fk5.getX() + 0.5, fk5.getY(), fk5.getZ() + 0.5, null);
                bjw4.addFreshEntity(awc6);
                bjw4.playSound(null, awc6.getX(), awc6.getY(), awc6.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0f, 1.0f);
                ben.shrink(1);
                return ben;
            }
        });
        final DispenseItemBehavior gl3 = new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                this.success = ArmorItem.dispenseArmor(fl, ben);
                return ben;
            }
        };
        DispenserBlock.registerBehavior(Items.CREEPER_HEAD, gl3);
        DispenserBlock.registerBehavior(Items.ZOMBIE_HEAD, gl3);
        DispenserBlock.registerBehavior(Items.DRAGON_HEAD, gl3);
        DispenserBlock.registerBehavior(Items.SKELETON_SKULL, gl3);
        DispenserBlock.registerBehavior(Items.PLAYER_HEAD, gl3);
        DispenserBlock.registerBehavior(Items.WITHER_SKELETON_SKULL, new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Level bjw4 = fl.getLevel();
                final Direction fp5 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
                final BlockPos fk6 = fl.getPos().relative(fp5);
                if (bjw4.isEmptyBlock(fk6) && WitherSkullBlock.canSpawnMob(bjw4, fk6, ben)) {
                    bjw4.setBlock(fk6, ((AbstractStateHolder<O, BlockState>)Blocks.WITHER_SKELETON_SKULL.defaultBlockState()).<Comparable, Integer>setValue((Property<Comparable>)SkullBlock.ROTATION, (fp5.getAxis() == Direction.Axis.Y) ? 0 : (fp5.getOpposite().get2DDataValue() * 4)), 3);
                    final BlockEntity bwl7 = bjw4.getBlockEntity(fk6);
                    if (bwl7 instanceof SkullBlockEntity) {
                        WitherSkullBlock.checkSpawn(bjw4, fk6, (SkullBlockEntity)bwl7);
                    }
                    ben.shrink(1);
                    this.success = true;
                }
                else {
                    this.success = ArmorItem.dispenseArmor(fl, ben);
                }
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Blocks.CARVED_PUMPKIN, new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Level bjw4 = fl.getLevel();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final CarvedPumpkinBlock bpu6 = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN;
                if (bjw4.isEmptyBlock(fk5) && bpu6.canSpawnGolem(bjw4, fk5)) {
                    if (!bjw4.isClientSide) {
                        bjw4.setBlock(fk5, bpu6.defaultBlockState(), 3);
                    }
                    ben.shrink(1);
                    this.success = true;
                }
                else {
                    this.success = ArmorItem.dispenseArmor(fl, ben);
                }
                return ben;
            }
        });
        DispenserBlock.registerBehavior(Blocks.SHULKER_BOX.asItem(), new ShulkerBoxDispenseBehavior());
        for (final DyeColor bdj7 : DyeColor.values()) {
            DispenserBlock.registerBehavior(ShulkerBoxBlock.getBlockByColor(bdj7).asItem(), new ShulkerBoxDispenseBehavior());
        }
        DispenserBlock.registerBehavior(Items.GLASS_BOTTLE.asItem(), new OptionalDispenseItemBehavior() {
            private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior();
            
            private ItemStack takeLiquid(final BlockSource fl, final ItemStack ben2, final ItemStack ben3) {
                ben2.shrink(1);
                if (ben2.isEmpty()) {
                    return ben3.copy();
                }
                if (fl.<DispenserBlockEntity>getEntity().addItem(ben3.copy()) < 0) {
                    this.defaultDispenseItemBehavior.dispense(fl, ben3.copy());
                }
                return ben2;
            }
            
            public ItemStack execute(final BlockSource fl, final ItemStack ben) {
                this.success = false;
                final LevelAccessor bjx4 = fl.getLevel();
                final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                final BlockState byj6 = bjx4.getBlockState(fk5);
                final Block bph7 = byj6.getBlock();
                if (bph7.is(BlockTags.BEEHIVES) && byj6.<Integer>getValue((Property<Integer>)BeehiveBlock.HONEY_LEVEL) >= 5) {
                    ((BeehiveBlock)byj6.getBlock()).releaseBeesAndResetHoneyLevel(bjx4.getLevel(), byj6, fk5, null, BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
                    this.success = true;
                    return this.takeLiquid(fl, ben, new ItemStack(Items.HONEY_BOTTLE));
                }
                if (bjx4.getFluidState(fk5).is(FluidTags.WATER)) {
                    this.success = true;
                    return this.takeLiquid(fl, ben, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER));
                }
                return super.execute(fl, ben);
            }
        });
        DispenserBlock.registerBehavior(Items.SHEARS.asItem(), new OptionalDispenseItemBehavior() {
            @Override
            protected ItemStack execute(final BlockSource fl, final ItemStack ben) {
                final Level bjw4 = fl.getLevel();
                if (!bjw4.isClientSide()) {
                    this.success = false;
                    final BlockPos fk5 = fl.getPos().relative(fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING));
                    final List<Sheep> list6 = bjw4.<Sheep>getEntitiesOfClass(Sheep.class, new AABB(fk5));
                    for (final Sheep atv8 : list6) {
                        if (atv8.isAlive() && !atv8.isSheared() && !atv8.isBaby()) {
                            atv8.shear();
                            if (ben.hurt(1, bjw4.random, null)) {
                                ben.setCount(0);
                            }
                            this.success = true;
                            break;
                        }
                    }
                    if (!this.success) {
                        final BlockState byj7 = bjw4.getBlockState(fk5);
                        if (byj7.is(BlockTags.BEEHIVES)) {
                            final int integer8 = byj7.<Integer>getValue((Property<Integer>)BeehiveBlock.HONEY_LEVEL);
                            if (integer8 >= 5) {
                                if (ben.hurt(1, bjw4.random, null)) {
                                    ben.setCount(0);
                                }
                                BeehiveBlock.dropHoneycomb(bjw4, fk5);
                                ((BeehiveBlock)byj7.getBlock()).releaseBeesAndResetHoneyLevel(bjw4, byj7, fk5, null, BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
                                this.success = true;
                            }
                        }
                    }
                }
                return ben;
            }
        });
    }
}
