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 ben, final Level bjw, final LivingEntity akz) {
        super.finishUsingItem(ben, bjw, akz);
        if (akz instanceof ServerPlayer) {
            final ServerPlayer xe5 = (ServerPlayer)akz;
            CriteriaTriggers.CONSUME_ITEM.trigger(xe5, ben);
            xe5.awardStat(Stats.ITEM_USED.get(this));
        }
        if (!bjw.isClientSide) {
            akz.removeEffect(MobEffects.POISON);
        }
        if (ben.isEmpty()) {
            return new ItemStack(Items.GLASS_BOTTLE);
        }
        if (akz instanceof Player && !((Player)akz).abilities.instabuild) {
            final ItemStack ben2 = new ItemStack(Items.GLASS_BOTTLE);
            final Player ayj6 = (Player)akz;
            if (!ayj6.inventory.add(ben2)) {
                ayj6.drop(ben2, false);
            }
        }
        return ben;
    }
    
    @Override
    public int getUseDuration(final ItemStack ben) {
        return 40;
    }
    
    @Override
    public UseAnim getUseAnimation(final ItemStack ben) {
        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 bjw, final Player ayj, final InteractionHand ajk) {
        ayj.startUsingItem(ajk);
        return InteractionResultHolder.<ItemStack>success(ayj.getItemInHand(ajk));
    }
}
