Posted July 28, 201411 yr I created a custom Irecipe that adds a tier upon a succesfull recipe. But then comes the problem. Now I created a the AddInformation(things) methode to display more information. It just does not display. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } the wierd part is, "info" is not even displayed! Coding, Testing, Smiling, Publishing!
July 28, 201411 yr Author I'm sorry? Minecraft will get the methode as an overwritten methode. In the ItemStack class the methode is called int the getToolTip mothode. It will then get the addinformation methode from the item in the itemstack. if the custom item does not have this methode, it will use the empty methode in the Item class. btw, it did not work? I have no clue why not? look at the first and the second methode! the first one will display the information and de second not! //nothing fancy here, no override, no sideonly, nothing public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { String info = EnumChatFormatting.DARK_GRAY + "A very effective melee weapon"; String info2 = EnumChatFormatting.DARK_GRAY + "Shift-Right-Click a door to instantly smash it"; par3List.add(info); par3List.add(info2); } //Works great @Override //<= just this! public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } //does not display! Coding, Testing, Smiling, Publishing!
July 28, 201411 yr Author Java.util.List This is also used by the first set of code from my previous post. This is not the problem. Coding, Testing, Smiling, Publishing!
July 28, 201411 yr Author I did not say that, I was just saying that you don't need it, it is usefull to see if the methode corresponds to the methode called by the extended class. With or without the @Override annotation, it does not work and I hace copied the methode over and over again from various other classes. Here is the Item class: nothing strange, no errors, registered just like other items. I just have no clue package mefa.Items; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ItemBackpack extends Item{ public ItemBackpack() { super(); this.setMaxStackSize(1); } @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } } Coding, Testing, Smiling, Publishing!
July 28, 201411 yr Author I'm sorry, I'm just being stupid. The item was a New Item instead of a New ItemBackPack That is the reason. next time I will double check every option before posting here. gawd, I feel dumb! Coding, Testing, Smiling, Publishing!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.