package common.item.tool;

import common.entity.npc.EntityNPC;
import common.entity.projectile.EntitySnowball;
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 ItemSnowball extends Item
{
    public ItemSnowball()
    {
        this.setTab(CheatTab.TOOLS);
    }

    /**
     * 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 EntitySnowball(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 EntitySnowball(world, position.xCoord, position.yCoord, position.zCoord));
	}

	public int getDispenseSoundId() {
		return 1002;
	}
}
