1 package asia.tcrs.ccnp.chemicraftnext.base.item;
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;
16 public class ItemOreSerarcher extends Item {
18 public ItemOreSerarcher(int par1) {
20 this.setHasSubtypes(true);
21 this.setMaxStackSize(1);
23 this.setCreativeTab(ChemiCraftCore.creativeTabChemiCraft);
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();
33 if (par3World.isRemote) {
34 this.changeItem(par2EntityPlayer);
36 String blockName = new ItemStack(
37 Block.blocksList[par3World.getBlockId(par4, par5, par6)],
39 par3World.getBlockMetadata(par4, par5, par6)).getDisplayName();
40 par1ItemStack.getTagCompound().setString("OreName", blockName);
46 public void changeItem(EntityPlayer par1EntityPlayer) {
47 par1EntityPlayer.inventory.inventoryChanged = true;
51 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
52 this.changeItem(par3EntityPlayer);
57 public String getItemDisplayName(ItemStack par1ItemStack) {
58 if (par1ItemStack.getTagCompound() != null) {
59 return super.getItemDisplayName(par1ItemStack) + ":" + par1ItemStack.getTagCompound().getString("OreName");
61 return super.getItemDisplayName(par1ItemStack);
65 public boolean getShareTag() {
70 @SideOnly(Side.CLIENT)
71 public void registerIcons(IconRegister par1IconRegister){
72 this.itemIcon = par1IconRegister.registerIcon(ChemiCraft.TEXTURE + "ore_searcher");