package net.minecraft.world.item;

import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.entity.player.Player;
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 MilkBucketItem extends Item {
    public MilkBucketItem(final Properties a) {
        super(a);
    }
    
    @Override
    public ItemStack finishUsingItem(final ItemStack bki, final Level bqb, final LivingEntity aoy) {
        if (aoy instanceof ServerPlayer) {
            final ServerPlayer ze5 = (ServerPlayer)aoy;
            CriteriaTriggers.CONSUME_ITEM.trigger(ze5, bki);
            ze5.awardStat(Stats.ITEM_USED.get(this));
        }
        if (aoy instanceof Player && !((Player)aoy).abilities.instabuild) {
            bki.shrink(1);
        }
        if (!bqb.isClientSide) {
            aoy.removeAllEffects();
        }
        if (bki.isEmpty()) {
            return new ItemStack(Items.BUCKET);
        }
        return bki;
    }
    
    @Override
    public int getUseDuration(final ItemStack bki) {
        return 32;
    }
    
    @Override
    public UseAnim getUseAnimation(final ItemStack bki) {
        return UseAnim.DRINK;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        return ItemUtils.useDrink(bqb, bec, anf);
    }
}
