Posted January 10, 20214 yr How would I go about adding lore to an ItemStack? Here is my current code: CompoundNBT nbt = item.getTag(); CompoundNBT display; ListNBT lore; if (nbt.get("display") != null) { display = (CompoundNBT) nbt.get("display"); if (display.get("Lore") != null) { lore = (ListNBT) display.get("Lore"); } else { lore = new ListNBT(); } } else { lore = new ListNBT(); display = new CompoundNBT(); } CompoundNBT tagRawJson = new CompoundNBT(); tagRawJson.putString("tag", "{'text': '[tag]', 'italic': false, 'color': 'white'}".replace("[tag]", tag)); lore.add(tagRawJson.get("tag")); display.put("Lore", lore); nbt.put("display", display); item.setTag(nbt); I would like to add the contents of the String variable named tag to the lore. Edited January 10, 20214 yr by DoctorC
January 10, 20214 yr Item#addInformation if you own the item or RenderTooltipEvent if its not. I'm assuming that this is present on the ItemStack itself.
January 10, 20214 yr Author 19 minutes ago, ChampionAsh5357 said: Item#addInformation if you own the item or RenderTooltipEvent if its not. I'm assuming that this is present on the ItemStack itself. I want to add it on the Itemstack, not the item (I've tried Item.addInformation), but I'll look into RenderTooltipEvent. Thanks!
January 10, 20214 yr 25 minutes ago, DoctorC said: I want to add it on the Itemstack, not the item (I've tried Item.addInformation), but I'll look into RenderTooltipEvent. Thanks! ItemStacks are Stacks of an Item. addInformation in the ItemClass is passed the relevant ItemStack for you to make any determinations based on other data. But only works for your own items. RenderTooltipEvent would be if you need to add information to an Item you don't control (and gets the same parameters addInformation does). Edited January 10, 20214 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 10, 20214 yr Author 33 minutes ago, Draco18s said: addInformation in the ItemClass is passed the relevant ItemStack for you to make any determinations based on other data. But only works for your own items. I'm using GuiScreenEvent.KeyboardKeyPressedEvent to get a keybind being pressed, and then change the item under cursor, so I don't think Item#addInformation would work (well I can't get it to at least). Edited January 10, 20214 yr by DoctorC
January 11, 20214 yr Author 2 hours ago, ChampionAsh5357 said: RenderTooltipEvent Okay, how do I change the tooltip rendered?
January 11, 20214 yr It gives you the coordinate.... you need to render the extra information yourself. Edited January 11, 20214 yr by poopoodice
January 11, 20214 yr Author 12 minutes ago, poopoodice said: It gives you the coordinate.... you need to render the extra information yourself. Yes, but how. As in, I have a FontRenderer and I can render in a string, but it doesn't add lore, rather it adds text rendered underneath the item. I don't have any experience rendering things in Forge, which is why I am asking.
January 11, 20214 yr If you just want to add some simple text to the item use ItemTooltipEvent. Edited January 11, 20214 yr by poopoodice
January 11, 20214 yr Author 2 minutes ago, poopoodice said: If you just want to add some simple text to the item use ItemTooltipEvent. There don't seem to be any functions to change the tooltip.
January 11, 20214 yr There's a list of tooltips provided, you can do whatever you want to it (remove them all, add your custom ones, or even flip them all around...).
January 11, 20214 yr Author 4 minutes ago, poopoodice said: There's a list of tooltips provided, you can do whatever you want to it (remove them all, add your custom ones, or even flip them all around...). Thanks! I didn't realise that adding to the list would update it in-game without having to set it.
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.