001 package net.minecraft.item; 002 003 import net.minecraft.creativetab.CreativeTabs; 004 import net.minecraft.entity.player.EntityPlayer; 005 import net.minecraft.entity.projectile.EntitySnowball; 006 import net.minecraft.world.World; 007 008 public class ItemSnowball extends Item 009 { 010 public ItemSnowball(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 --par1ItemStack.stackSize; 025 } 026 027 par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); 028 029 if (!par2World.isRemote) 030 { 031 par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); 032 } 033 034 return par1ItemStack; 035 } 036 }