Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey!

 

So I'm creating an event that adds advanced tooltips, however, I can't really figure out how to register or apply my event to items..

 

Here is the event:

 

package com.lambda.PlentifulMisc.event;
import java.util.List;


import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderGlobal;


@SideOnly(Side.CLIENT)
public class ItemInfoEvent 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 ItemInfoEvent(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    {
       this.itemstack = par1ItemStack;
       this.player = par2EntityPlayer;
       this.list = par3List;
       this.extrainfo = par4;
       this.shifting = GuiScreen.isShiftKeyDown();
    }

}

Not new to java >> New to modding.

Are you sure you want to create an event yourself rather than subscribe to an event that's already fired by Forge? If creating an event is really what you want, you need to figure out where to fire it from, who's going to subscribe to it and what you're going to do with the results.

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.

  • Author

Oh I was told that this event didnt exist! So how would I 'subscribe' to the function on an item?

Not new to java >> New to modding.

Oh I was told that this event didnt exist! So how would I 'subscribe' to the function on an item?

 

If it's your own

Item

, override

Item#addInformation

to add the tooltip. If it's an

Item

added by vanilla or another mod, subscribe to

ItemTooltipEvent

to add the tooltip.

 

Forge's documentation has an introduction to events here.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.