1 package pcc.chemicraft.core.item;
3 import java.util.ArrayList;
6 import net.minecraft.client.renderer.texture.IconRegister;
7 import net.minecraft.creativetab.CreativeTabs;
8 import net.minecraft.entity.Entity;
9 import net.minecraft.entity.player.EntityPlayer;
10 import net.minecraft.item.Item;
11 import net.minecraft.item.ItemStack;
12 import net.minecraft.util.Icon;
13 import net.minecraft.world.World;
14 import pcc.chemicraft.core.ChemiCraftAPI;
15 import pcc.chemicraft.core.ChemiCraftCore;
16 import cpw.mods.fml.relauncher.Side;
17 import cpw.mods.fml.relauncher.SideOnly;
19 public class ItemCompounds extends Item {
23 public ItemCompounds(int par1){
25 this.setHasSubtypes(true);
27 this.setCreativeTab(ChemiCraftCore.instance.creativeTabChemiCraft);
31 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
33 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
34 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
35 return ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
38 } catch (IndexOutOfBoundsException e) {
39 par1ItemStack.stackSize = 0;
46 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
48 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
49 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
50 ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
53 } catch (IndexOutOfBoundsException e) {
54 par1ItemStack.stackSize = 0;
62 public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
64 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
65 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
66 ChemiCraftAPI.instance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
69 } catch (IndexOutOfBoundsException e) {
70 par1ItemStack.stackSize = 0;
77 @SuppressWarnings({ "unchecked", "rawtypes" })
78 @SideOnly(Side.CLIENT)
80 public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
81 for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().get("en_US").size(); type++) {
82 par3List.add(new ItemStack(par1, 1, type));
89 public String getUnlocalizedName(ItemStack par1ItemStack){
90 return super.getUnlocalizedName() + "." + ChemiCraftCore.instance.api.getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
96 @SideOnly(Side.CLIENT)
97 public void updateIcons(IconRegister par1IconRegister) {
98 ArrayList<String> textures = ChemiCraftAPI.getCompoundsTexture();
99 this.icons = new Icon[textures.size()];
100 for (int i = 0; i < textures.size(); i++) {
101 this.icons[i] = par1IconRegister.registerIcon(textures.get(i));
106 @SideOnly(Side.CLIENT)
107 public Icon getIconFromDamage(int par1) {
108 return this.icons[par1];