Ms_Raven Posted December 24, 2014 Posted December 24, 2014 I know you can add lore to an item with the addInformation method in the item's class but I want to be able to do that with all my items without creating a new class for each of them. I tried this, but the item still doesn't have any extra information when hovering. Can someone tell me what I'm doing wrong?: Custom Item class "LItem" public class LItem extends Item { public static String lore; public LItem(String lore) { super(); this.lore = lore; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean aBoolean) { if(lore != "") { list.add(lore); } } } Registering a new LItem helm_of_darkness = new LItem("Grants invisibility when worn.") .setUnlocalizedName("helm_of_darkness") .setCreativeTab(LegendaryCreative.tabArmour) .setTextureName(LegendaryMod.modid + ":" + "helm_of_darkness"); GameRegistry.registerItem(helm_of_darkness, "helm_of_darkness"); Quote
shieldbug1 Posted December 24, 2014 Posted December 24, 2014 Also: You can't compare strings with == . Quote BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
brandon3055 Posted December 24, 2014 Posted December 24, 2014 Pro tip: Vanilla already has a way to add lore to items. I dont use it because addInformation works better for my purpose but the advantage to the vanillla way is that you can also use it to add lore to vanilla items. Here is an example of how to use it. ItemStack stack = (any ItemStack) NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) nbt = new NBTTagCompound(); NBTTagList lore = new NBTTagList(); lore.appendTag(new NBTTagString("lore line 1")); lore.appendTag(new NBTTagString("lore line 2")); lore.appendTag(new NBTTagString("lore line 3")); //etc NBTTagCompound display = new NBTTagCompound(); display.setTag("Lore", lore); nbt.setTag("display", display); stack.setTagCompound(nbt); Quote I am the author of Draconic Evolution
Recommended Posts
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.