001    package net.minecraft.item;
002    
003    import net.minecraft.creativetab.CreativeTabs;
004    import net.minecraft.entity.item.EntityEnderPearl;
005    import net.minecraft.entity.player.EntityPlayer;
006    import net.minecraft.world.World;
007    
008    public class ItemEnderPearl extends Item
009    {
010        public ItemEnderPearl(int par1)
011        {
012            super(par1);
013            this.maxStackSize = 16;
014            this.setCreativeTab(CreativeTabs.tabMisc);
015        }
016    
017        /**
018         * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
019         */
020        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
021        {
022            if (par3EntityPlayer.capabilities.isCreativeMode)
023            {
024                return par1ItemStack;
025            }
026            else if (par3EntityPlayer.ridingEntity != null)
027            {
028                return par1ItemStack;
029            }
030            else
031            {
032                --par1ItemStack.stackSize;
033                par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
034    
035                if (!par2World.isRemote)
036                {
037                    par2World.spawnEntityInWorld(new EntityEnderPearl(par2World, par3EntityPlayer));
038                }
039    
040                return par1ItemStack;
041            }
042        }
043    }