1 package pcc.chemicraft.item;
5 import net.minecraft.creativetab.CreativeTabs;
6 import net.minecraft.entity.Entity;
7 import net.minecraft.entity.player.EntityPlayer;
8 import net.minecraft.item.Item;
9 import net.minecraft.item.ItemStack;
10 import net.minecraft.world.World;
11 import pcc.chemicraft.ChemiCraft;
12 import pcc.chemicraft.ChemiCraftAPI;
13 import cpw.mods.fml.relauncher.Side;
14 import cpw.mods.fml.relauncher.SideOnly;
16 public class ItemCompounds extends Item {
18 public ItemCompounds(int par1){
20 this.setHasSubtypes(true);
22 this.setCreativeTab(ChemiCraft.instance.creativeTab);
26 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
28 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
29 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
30 return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
33 } catch (IndexOutOfBoundsException e) {
34 par1ItemStack.stackSize = 0;
41 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
44 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
45 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
46 ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
49 } catch (IndexOutOfBoundsException e) {
50 par1ItemStack.stackSize = 0;
58 public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
60 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
61 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
62 ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
65 } catch (IndexOutOfBoundsException e) {
66 par1ItemStack.stackSize = 0;
73 @SuppressWarnings({ "unchecked", "rawtypes" })
74 @SideOnly(Side.CLIENT)
76 public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
77 for(int type = 0; type < ChemiCraftAPI.getInstance().getCompoundsName().toArray().length; type++)
79 par3List.add(new ItemStack(par1, 1, type));
80 this.setIconIndex(type);
87 public String getItemNameIS(ItemStack par1ItemStack){
89 return super.getItemName() + "." + ChemiCraftAPI.getInstance().getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
90 } catch (ArrayIndexOutOfBoundsException e) {
91 par1ItemStack.stackSize = 0;
99 public String getTextureFile(){
100 return ChemiCraft.instance.ITEMCOMPOUNDSTEXTURE;
105 @SideOnly(Side.CLIENT)
107 public int getIconFromDamage(int par1){
109 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
110 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
111 return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).getIconIndexHandler();
114 } catch (IndexOutOfBoundsException e) {