package common.item.tool;

import common.entity.item.EntityXpBottle;
import common.entity.npc.EntityNPC;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Vec3;
import common.world.World;

public class ItemExpBottle extends Item
{
    public ItemExpBottle()
    {
        this.setTab(CheatTab.TOOLS);
    }

    public boolean hasEffect(ItemStack stack)
    {
        return true;
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
    {
//        if (!playerIn.creative)
//        {
        --itemStackIn.size;
//        }

        worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

        if (!worldIn.client)
        {
            worldIn.spawnEntityInWorld(new EntityXpBottle(worldIn, playerIn));
        }

//        playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
        return itemStackIn;
    }
    
	public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) {
		return this.dispenseProjectile(world, facing, stack, new EntityXpBottle(world, position.xCoord, position.yCoord, position.zCoord), 1.375f, 3.0f);
	}

	public int getDispenseSoundId() {
		return 1002;
	}
}
