OSDN Git Service

1.5.2対応
[chemicraft/ChemiCraftNext.git] / common / pcc / chemicraft / core / item / ItemCompounds.java
index d6220d2..e7b783d 100644 (file)
@@ -1,14 +1,16 @@
 package pcc.chemicraft.core.item;
 
+import java.util.ArrayList;
 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;
 import pcc.chemicraft.core.ChemiCraftCore;
 import cpw.mods.fml.relauncher.Side;
@@ -16,6 +18,8 @@ import cpw.mods.fml.relauncher.SideOnly;
 
 public class ItemCompounds extends Item {
 
+       private Icon[] icons;
+
        public ItemCompounds(int par1){
                super(par1);
                this.setHasSubtypes(true);
@@ -39,8 +43,7 @@ public class ItemCompounds extends Item {
 
 
        @Override
-       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
-       {
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
                try {
                        for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
                                if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
@@ -56,7 +59,7 @@ public class ItemCompounds extends Item {
 
 
        @Override
-       public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
+       public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
                try {
                        for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
                                if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
@@ -77,44 +80,32 @@ 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;
+       public String getUnlocalizedName(ItemStack par1ItemStack){
+               return super.getUnlocalizedName() + "." + ChemiCraftCore.instance.api.getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
        }
 
 
 
        @Override
-       public String getTextureFile(){
-               return ChemiCraft.ITEM_COMPOUNDS_TEXTURE;
+       @SideOnly(Side.CLIENT)
+    public void registerIcons(IconRegister par1IconRegister) {
+               ArrayList<String> textures = ChemiCraftAPI.getCompoundsTexture();
+               this.icons = new Icon[textures.size()];
+               for (int i = 0; i < textures.size(); i++) {
+                       this.icons[i] = par1IconRegister.registerIcon(textures.get(i));
+               }
        }
 
-
-
-       @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;
-               }
-               return 0;
+       @SideOnly(Side.CLIENT)
+       public Icon getIconFromDamage(int par1) {
+               return this.icons[par1];
        }
 
 }