package emasher.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import emasher.EngineersToolbox;
import emasher.entities.EntitySmokeBomb;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSmokeGrenade extends Item {
public ItemSmokeGrenade() {
super();
this.maxStackSize = 16;
this.setCreativeTab( EngineersToolbox.tabItems() );
this.setUnlocalizedName( "smokeGrenade" );
}
@Override
@SideOnly( Side.CLIENT )
public void registerIcons( IIconRegister registry ) {
this.itemIcon = registry.registerIcon( "eng_toolbox:smokeGrenade" );
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick( ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer ) {
if( !par3EntityPlayer.capabilities.isCreativeMode ) {
--par1ItemStack.stackSize;
}
par2World.playSoundAtEntity( par3EntityPlayer, "random.bow", 0.5F, 0.4F / ( itemRand.nextFloat() * 0.4F + 0.8F ) );
if( !par2World.isRemote ) {
par2World.spawnEntityInWorld( new EntitySmokeBomb( par2World, par3EntityPlayer ) );
}
return par1ItemStack;
}
}