package net.minecraft.world.item;

import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;

public class HoneyBottleItem extends Item {
    public HoneyBottleItem(final Properties a) {
        super(a);
    }
    
    @Override
    public ItemStack finishUsingItem(final ItemStack bki, final Level bqb, final LivingEntity aoy) {
        super.finishUsingItem(bki, bqb, aoy);
        if (aoy instanceof ServerPlayer) {
            final ServerPlayer ze5 = (ServerPlayer)aoy;
            CriteriaTriggers.CONSUME_ITEM.trigger(ze5, bki);
            ze5.awardStat(Stats.ITEM_USED.get(this));
        }
        if (!bqb.isClientSide) {
            aoy.removeEffect(MobEffects.POISON);
        }
        if (bki.isEmpty()) {
            return new ItemStack(Items.GLASS_BOTTLE);
        }
        if (aoy instanceof Player && !((Player)aoy).abilities.instabuild) {
            final ItemStack bki2 = new ItemStack(Items.GLASS_BOTTLE);
            final Player bec6 = (Player)aoy;
            if (!bec6.inventory.add(bki2)) {
                bec6.drop(bki2, false);
            }
        }
        return bki;
    }
    
    @Override
    public int getUseDuration(final ItemStack bki) {
        return 40;
    }
    
    @Override
    public UseAnim getUseAnimation(final ItemStack bki) {
        return UseAnim.DRINK;
    }
    
    @Override
    public SoundEvent getDrinkingSound() {
        return SoundEvents.HONEY_DRINK;
    }
    
    @Override
    public SoundEvent getEatingSound() {
        return SoundEvents.HONEY_DRINK;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        return ItemUtils.useDrink(bqb, bec, anf);
    }
}
