package common.entity.item;

import common.entity.types.EntityLiving;
import common.entity.types.EntityThrowable;
import common.util.BlockPos;
import common.util.HitPosition;
import common.world.World;

public class EntityXpBottle extends EntityThrowable
{
    public EntityXpBottle(World worldIn)
    {
        super(worldIn);
    }

    public EntityXpBottle(World worldIn, EntityLiving p_i1786_2_)
    {
        super(worldIn, p_i1786_2_);
    }

    public EntityXpBottle(World worldIn, double x, double y, double z)
    {
        super(worldIn, x, y, z);
    }

    /**
     * Gets the amount of gravity to apply to the thrown entity with each tick.
     */
    protected float getGravityVelocity()
    {
        return 0.07F;
    }

    protected float getVelocity()
    {
        return 0.7F;
    }

    protected float getInaccuracy()
    {
        return -20.0F;
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(HitPosition p_70184_1_)
    {
        if (!this.worldObj.client)
        {
            this.worldObj.playAuxSFX(2002, new BlockPos(this), 0);
            int i = this.worldObj.rand.rangeBonus(3, 7, 4);

            while (i > 0)
            {
                int j = EntityXp.getXPSplit(i);
                i -= j;
                this.worldObj.spawnEntityInWorld(new EntityXp(this.worldObj, this.posX, this.posY, this.posZ, j));
            }

            this.setDead();
        }
    }
}
