Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Item tooltip hook


Recommended Posts

To make adding tooltips to items that already exist easier, adding a hook or event that is called whenever the items addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) method is called so that mods like mine can add tooltips to the vanilla minecraft items, or other mod items.


Thanks in advance, EJ.


Example of an event for this that could be added:


package net.minecraftforge.client.event;


import java.util.List;


import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;


import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.src.ModLoader;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.client.renderer.RenderGlobal;

import net.minecraftforge.event.Cancelable;

import net.minecraftforge.event.Event;




* Allows mods using this event to add information to the items tooltip


public class ItemInformationEvent extends Event



* The ItemStack that is having its tooltip


    public final ItemStack itemstack;


    * The player that owns the inventory with the item stack in


    public final EntityPlayer player;


    * The list of tooltips, Add information to this to add info to the tooltip (list.add())


    public final List list;


    * Whether or not F3+H is active


    public final boolean extrainfo;


    * Whether or not the player is holding shift


    public final boolean shifting;


    public ItemInformationEvent(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)


    this.itemstack = par1ItemStack;

    this.player = par2EntityPlayer;

    this.list = par3List;

    this.extrainfo = par4;

    this.shifting = ModLoader.getMinecraftInstance().currentScreen.isShiftKeyDown();






Link to comment
Share on other sites

  • 3 months later...
  • 4 months later...
  • 1 month later...

This looks great! How do I implement this now? Is it ok to just copy and paste all the green code? (and remove the red code I guess)

Will this work when I reobuscate and export the code? Will it work on a server?


As you might have guessed, I'm not so familiar with this ForgeHookFactory. Can I make additions like this in there?



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.

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.


  • Create New...

Important Information

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