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

Hi I'm just kind of confused on how this event works with it's start, tick, stop, and finish variables could someone please explain to me how to properly use these in the event? thanks

 

Start event fires when the player first begins using the item.

Tick event fires each tick while the item is in use.

Stop event fires when the player stops using the item.

Finish event fires after everything to do with using the item is finished.

 

Most of this is explained in the Java docs for the events, and the rest you can gather from looking at where the events are called via the Call Hierarchy in your IDE, all of which lead to the Item class eventually.

  • Author

So I'm actually still having some trouble with this event, I'm trying to make it so that when a player uses a fishing rod and it's durability goes down a counter will add 2 but it's not working does anyone know why?

 

code:

@SubscribeEvent

public void useItem(Finish event)

{

EMIEEP props = EMIEEP.get(event.entityPlayer);

if (event.entityPlayer.getHeldItem().getItem() == Items.fishing_rod && event.result.getItem().isDamaged(event.entityPlayer.getHeldItem()))

{

props.addToCounter(2.0);

System.out.println(props.getCounter());

}

}

 

 

 

 

 

 

 

 

 

 

 

#isDamaged always returns true after a stack has taken even 1 point of damage, even if it didn't take any damage recently.

 

Is the problem that the println isn't printing, or that the counter from your IEEP is not what you expected, or something else entirely?

 

Show your IEEP code for #addToCounter and #getCounter

  • Author

So basically println() isn't working which means that the if statement isn't working I know for a fact that the IEEP counter works as I have used it for alot of other events and it works just fine here is my code, isDamaged() was like the only thing I found that checked if the item has been damaged if there is a better way to check a fishing rod after using it I'm all ears anyways here is my code:

 

@SubscribeEvent

public void useItem(Finish event)

{

EMIEEP props = EMIEEP.get(event.entityPlayer);

 

if (event.entityPlayer.getHeldItem().getItem() == Items.fishing_rod && event.result.getItem().isDamaged(event.entityPlayer.getHeldItem()))

{

props.addToCounter(2.0);

System.out.println(props.getCounter());

}

}

Did you register the event handler? Try putting a println as the very first line within the method.

 

Also, I personally prefer to use 'PlayerUseItemEvent.Finish' instead of just 'Finish' - it helps prevent any sort of ambiguity when importing, as well as making the event handling method easier to read.

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.