OSDN Git Service

ファイルパス色々変更。
[chemicraft/chemicraft.git] / common / pcc / chemicraft / base / item / ItemOreSerarcher.java
index d7ca81a..ca38707 100644 (file)
@@ -1,50 +1,73 @@
 package pcc.chemicraft.base.item;
 
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.SideOnly;
+import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.base.ChemiCraftBase;
+import pcc.chemicraft.core.ChemiCraftCore;
+import net.minecraft.client.renderer.texture.IconRegister;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StringTranslate;
 import net.minecraft.world.World;
 
 public class ItemOreSerarcher extends Item {
 
        public ItemOreSerarcher(int par1) {
                super(par1);
+               this.setHasSubtypes(true);
                this.setMaxStackSize(1);
+               this.setMaxDamage(0);
+               this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
        }
 
        @Override
        public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
                for (int i = 0; i < ChemiCraftBase.instance.atomOresID.length; i++) {
                        if (par3World.getBlockId(par4, par5, par6) == ChemiCraftBase.instance.atomOresID[i]) {
-                               if (par1ItemStack.getTagCompound() == null) par1ItemStack.stackTagCompound = new NBTTagCompound();
-                               par1ItemStack.getTagCompound().setString("OreName", ChemiCraftBase.instance.blockAtomOres[i].getBlockName());
+                               if (par1ItemStack.getTagCompound() == null) {
+                                       par1ItemStack.stackTagCompound = new NBTTagCompound();
+                               }
+                               if (par3World.isRemote) {
+                                       this.changeItem(par2EntityPlayer);
+                               }
+                               String blockName = ChemiCraftBase.instance.apiBase.getAtomOreEnglishName(
+                                               (Math.abs(ChemiCraftBase.instance.atomOresID[ChemiCraftBase.instance.atomOresID.length-1] -
+                                                               (par3World.getBlockId(par4, par5, par6) + 3))) * 16 +
+                                                               par3World.getBlockMetadata(par4, par5, par6));
+                               par1ItemStack.getTagCompound().setString("OreName", blockName);
                        }
                }
                return true;
        }
 
+       public void changeItem(EntityPlayer par1EntityPlayer) {
+               par1EntityPlayer.inventory.inventoryChanged = true;
+       }
+
        @Override
        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+               this.changeItem(par3EntityPlayer);
                return par1ItemStack;
        }
 
-
-
-       @Override
-       public String getItemNameIS(ItemStack par1ItemStack) {
+       public String getItemDisplayName(ItemStack par1ItemStack) {
                if (par1ItemStack.getTagCompound() != null) {
-                       return super.getItemName() + "." + par1ItemStack.getTagCompound().getString("OreName");
+                       return "OreSearcher:" + par1ItemStack.getTagCompound().getString("OreName");
                }
-               return super.getItemName();
+               return "OreSearcher";
        }
 
        @Override
        public boolean getShareTag() {
-               return super.getShareTag();
+               return true;
        }
 
-
+       @Override
+       public void updateIcons(IconRegister par1IconRegister){
+               this.iconIndex = par1IconRegister.registerIcon(ChemiCraft.ITEM_TEXTURE + "ItemOreSearcher");
+       }
 
 }