package net.minecraft.world.item;

import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

public class ExperienceBottleItem extends Item {
    public ExperienceBottleItem(final Properties a) {
        super(a);
    }
    
    @Override
    public boolean isFoil(final ItemStack bki) {
        return true;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        final ItemStack bki5 = bec.getItemInHand(anf);
        bqb.playSound(null, bec.getX(), bec.getY(), bec.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5f, 0.4f / (ExperienceBottleItem.random.nextFloat() * 0.4f + 0.8f));
        if (!bqb.isClientSide) {
            final ThrownExperienceBottle bfc6 = new ThrownExperienceBottle(bqb, bec);
            bfc6.setItem(bki5);
            bfc6.shootFromRotation(bec, bec.xRot, bec.yRot, -20.0f, 0.7f, 1.0f);
            bqb.addFreshEntity(bfc6);
        }
        bec.awardStat(Stats.ITEM_USED.get(this));
        if (!bec.abilities.instabuild) {
            bki5.shrink(1);
        }
        return InteractionResultHolder.<ItemStack>sidedSuccess(bki5, bqb.isClientSide());
    }
}
