Jump to content

Add tooltip to existing ItemStack


Koenn

Recommended Posts

So I have a device in my mod that adds special properties to vanilla tools. I also want it to show a custom tooltip on the items, so you can see what properties the item has. I know there's a method in Item you can override to add information, but I can't do that for vanilla items. Do I need to add information to the ItemStacks? I can't seem to find a method in there to do that.

I'm a plugin developer, and I just started modding. Don't blame me for doing things wrong, Forge is not the same as Bukkit.

Link to comment
Share on other sites

According to the Forge event list page: "Fired to check whether the advanced information on item tooltips is being shown, toggled by F3+H". I want my tooltip to show all the time, not just toggled by F3+H, similair to the information on potions or weapons showing their effects/damage.

I'm a plugin developer, and I just started modding. Don't blame me for doing things wrong, Forge is not the same as Bukkit.

Link to comment
Share on other sites

PRE-Edit:

Wow ninja'd twice

 

ItemTooltipEvent

(extends PlayerEvent, LivingEvent, EntityEvent) Fired to check whether the advanced information on item tooltips is being shown, toggled by F3+H

 

I use this for my mod to display "Stats" since I deal quite a bit with vanilla items, and if they are the correct extended class, other modded items too.

 

You can probably still get away with using the itemStacks NBT data to store your values, and read them when that event fires.

 

it's suggested to use Capabilities now for ItemStacks, which I had a grand time trying to figure out how to sync them correctly from server to client. I chose a more clunky way, another person went ahead and got some IContainerListeners working which works 100% better than what I did. Choonster posted that thread in mine as well.

Link to comment
Share on other sites

According to the Forge event list page: "Fired to check whether the advanced information on item tooltips is being shown, toggled by F3+H". I want my tooltip to show all the time, not just toggled by F3+H, similair to the information on potions or weapons showing their effects/damage.

 

That page is incorrect, the event is always fired when an item tooltip is displayed; regardless of the advanced tooltip setting.

 

The doc comments in the event class explain this.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

According to the Forge event list page: "Fired to check whether the advanced information on item tooltips is being shown, toggled by F3+H". I want my tooltip to show all the time, not just toggled by F3+H, similair to the information on potions or weapons showing their effects/damage.

 

That page is incorrect, the event is always fired when an item tooltip is displayed; regardless of the advanced tooltip setting.

 

The doc comments in the event class explain this.

 

Allright, let me test that, would be awesome if that's true

I'm a plugin developer, and I just started modding. Don't blame me for doing things wrong, Forge is not the same as Bukkit.

Link to comment
Share on other sites

According to the Forge event list page: "Fired to check whether the advanced information on item tooltips is being shown, toggled by F3+H". I want my tooltip to show all the time, not just toggled by F3+H, similair to the information on potions or weapons showing their effects/damage.

 

That page is incorrect, the event is always fired when an item tooltip is displayed; regardless of the advanced tooltip setting.

 

The doc comments in the event class explain this.

 

Oh, that worked, thanks a lot for the help!

I'm a plugin developer, and I just started modding. Don't blame me for doing things wrong, Forge is not the same as Bukkit.

Link to comment
Share on other sites

  • 1 year later...
1 hour ago, Blu_Nighttime said:

I assume this is still the case for 1.12.2, could someone link me the forge doc for this. Or at least an example and where this should be located.

Thanks.

This topic is almost 2 years old. Please don’t comment on old threads. I don’t know where the docs for the event.

In the event just check it the item is the one you want to add the tooltip to and add the tooltip if it is. If you have any questions please make your own new topic 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.