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 ben, final Level bjw, final LivingEntity akz) {
        if (akz instanceof ServerPlayer) {
            final ServerPlayer xe5 = (ServerPlayer)akz;
            CriteriaTriggers.CONSUME_ITEM.trigger(xe5, ben);
            xe5.awardStat(Stats.ITEM_USED.get(this));
        }
        if (akz instanceof Player && !((Player)akz).abilities.instabuild) {
            ben.shrink(1);
        }
        if (!bjw.isClientSide) {
            akz.removeAllEffects();
        }
        if (ben.isEmpty()) {
            return new ItemStack(Items.BUCKET);
        }
        return ben;
    }
    
    @Override
    public int getUseDuration(final ItemStack ben) {
        return 32;
    }
    
    @Override
    public UseAnim getUseAnimation(final ItemStack ben) {
        return UseAnim.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));
    }
}
