Posted November 18, 20168 yr 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.
November 18, 20168 yr 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.
November 18, 20168 yr 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.
November 18, 20168 yr 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.