OSDN Git Service

パッケージ変更
[chemicraft/ChemiCraftNext.git] / src / asia / tcrs / ccnp / chemicraftnext / base / item / ItemOreSerarcher.java
1 package asia.tcrs.ccnp.chemicraftnext.base.item;
2
3 import asia.tcrs.ccnp.chemicraftnext.ChemiCraft;
4 import asia.tcrs.ccnp.chemicraftnext.base.ChemiCraftBase;
5 import asia.tcrs.ccnp.chemicraftnext.core.ChemiCraftCore;
6 import cpw.mods.fml.relauncher.Side;
7 import cpw.mods.fml.relauncher.SideOnly;
8 import net.minecraft.block.Block;
9 import net.minecraft.client.renderer.texture.IconRegister;
10 import net.minecraft.entity.player.EntityPlayer;
11 import net.minecraft.item.Item;
12 import net.minecraft.item.ItemStack;
13 import net.minecraft.nbt.NBTTagCompound;
14 import net.minecraft.world.World;
15
16 public class ItemOreSerarcher extends Item {
17
18         public ItemOreSerarcher(int par1) {
19                 super(par1);
20                 this.setHasSubtypes(true);
21                 this.setMaxStackSize(1);
22                 this.setMaxDamage(0);
23                 this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
24         }
25
26         @Override
27         public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
28                 for (int i = 0; i < ChemiCraftBase.instance.atomOresID.length; i++) {
29                         if (par3World.getBlockId(par4, par5, par6) == ChemiCraftBase.instance.atomOresID[i]) {
30                                 if (par1ItemStack.getTagCompound() == null) {
31                                         par1ItemStack.stackTagCompound = new NBTTagCompound();
32                                 }
33                                 if (par3World.isRemote) {
34                                         this.changeItem(par2EntityPlayer);
35                                 }
36                                 String blockName = new ItemStack(
37                                                 Block.blocksList[par3World.getBlockId(par4, par5, par6)],
38                                                 1,
39                                                 par3World.getBlockMetadata(par4, par5, par6)).getDisplayName();
40                                 par1ItemStack.getTagCompound().setString("OreName", blockName);
41                         }
42                 }
43                 return true;
44         }
45
46         public void changeItem(EntityPlayer par1EntityPlayer) {
47                 par1EntityPlayer.inventory.inventoryChanged = true;
48         }
49
50         @Override
51         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
52                 this.changeItem(par3EntityPlayer);
53                 return par1ItemStack;
54         }
55
56         @Override
57         public String getItemDisplayName(ItemStack par1ItemStack) {
58                 if (par1ItemStack.getTagCompound() != null) {
59                         return super.getItemDisplayName(par1ItemStack) + ":" + par1ItemStack.getTagCompound().getString("OreName");
60                 }
61                 return super.getItemDisplayName(par1ItemStack);
62         }
63
64         @Override
65         public boolean getShareTag() {
66                 return true;
67         }
68
69         @Override
70         @SideOnly(Side.CLIENT)
71     public void registerIcons(IconRegister par1IconRegister){
72                 this.itemIcon = par1IconRegister.registerIcon(ChemiCraft.TEXTURE + "ore_searcher");
73         }
74
75 }