1 package pcc.chemicraft.core.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.core.ChemiCraftAPI;
13 import pcc.chemicraft.core.ChemiCraftCore;
14 import cpw.mods.fml.relauncher.Side;
15 import cpw.mods.fml.relauncher.SideOnly;
17 public class ItemCompounds extends Item {
19 public ItemCompounds(int par1){
21 this.setHasSubtypes(true);
23 this.setCreativeTab(ChemiCraftCore.instance.creativeTabChemiCraft);
27 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
29 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
30 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
31 return ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
34 } catch (IndexOutOfBoundsException e) {
35 par1ItemStack.stackSize = 0;
42 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
45 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
46 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
47 ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
50 } catch (IndexOutOfBoundsException e) {
51 par1ItemStack.stackSize = 0;
59 public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
61 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
62 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
63 ChemiCraftAPI.instance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
66 } catch (IndexOutOfBoundsException e) {
67 par1ItemStack.stackSize = 0;
74 @SuppressWarnings({ "unchecked", "rawtypes" })
75 @SideOnly(Side.CLIENT)
77 public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
78 for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().get("en_US").size(); type++)
80 par3List.add(new ItemStack(par1, 1, type));
81 this.setIconIndex(type);
88 public String getItemNameIS(ItemStack par1ItemStack){
90 return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
91 } catch (ArrayIndexOutOfBoundsException e) {
92 par1ItemStack.stackSize = 0;
100 public String getTextureFile(){
101 return ChemiCraft.ITEM_COMPOUNDS_TEXTURE;
106 @SideOnly(Side.CLIENT)
108 public int getIconFromDamage(int par1){
110 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
111 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
112 return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
115 } catch (IndexOutOfBoundsException e) {