OSDN Git Service

ソース参照
[chemicraft/chemicraft.git] / common / pcc / chemicraft / core / item / ItemCompounds.java
index d6220d2..436e5c2 100644 (file)
@@ -2,11 +2,13 @@ package pcc.chemicraft.core.item;
 
 import java.util.List;
 
+import net.minecraft.client.renderer.texture.IconRegister;
 import net.minecraft.creativetab.CreativeTabs;
 import net.minecraft.entity.Entity;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
 import net.minecraft.world.World;
 import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.core.ChemiCraftAPI;
@@ -16,6 +18,8 @@ import cpw.mods.fml.relauncher.SideOnly;
 
 public class ItemCompounds extends Item {
 
+       public Icon[] icons;
+
        public ItemCompounds(int par1){
                super(par1);
                this.setHasSubtypes(true);
@@ -77,44 +81,34 @@ public class ItemCompounds extends Item {
        public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
                for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().get("en_US").size(); type++) {
                        par3List.add(new ItemStack(par1, 1, type));
-                       this.setIconIndex(type);
                }
        }
 
 
 
        @Override
-       public String getItemNameIS(ItemStack par1ItemStack){
-               try {
-                       return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
-               } catch (ArrayIndexOutOfBoundsException e) {
-                       par1ItemStack.stackSize = 0;
-               }
-               return null;
+       @SideOnly(Side.CLIENT)
+       public Icon getIconFromDamage(int par1) {
+               return this.icons[par1];
        }
 
 
 
        @Override
-       public String getTextureFile(){
-               return ChemiCraft.ITEM_COMPOUNDS_TEXTURE;
+       public String getUnlocalizedName(ItemStack par1ItemStack){
+               return super.getUnlocalizedName() + "." + ChemiCraftCore.instance.api.getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
        }
 
 
 
-       @SideOnly(Side.CLIENT)
        @Override
-       public int getIconFromDamage(int par1){
-               try {
-                       for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
-                               if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
-                                       return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
-                               }
-                       }
-               } catch (IndexOutOfBoundsException e) {
-                       return 0;
+       @SideOnly(Side.CLIENT)
+       public void updateIcons(IconRegister par1IconRegister) {
+               this.icons = new Icon[ChemiCraftCore.instance.api.getCompoundsName().sizeElementsList("en_US")];
+
+               for (int i = 0; i < ChemiCraftCore.instance.api.getCompoundsName().sizeElementsList("en_US"); i++) {
+                       this.icons[i] = par1IconRegister.registerIcon(ChemiCraft.TEXTURE + "compounds_" + ChemiCraftCore.instance.api.getCompoundsName().get("en_US", i));
                }
-               return 0;
        }
 
 }