Posted September 26, 201510 yr 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
September 26, 201510 yr 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. http://i.imgur.com/NdrFdld.png[/img]
September 26, 201510 yr 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()); } }
September 26, 201510 yr #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 http://i.imgur.com/NdrFdld.png[/img]
September 26, 201510 yr 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()); } }
September 26, 201510 yr 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. http://i.imgur.com/NdrFdld.png[/img]
September 26, 201510 yr Author Tried all of that still doesn't work also yes my event handler is registered
September 26, 201510 yr Tried all of that still doesn't work also yes my event handler is registered If you 'tried all of that' and nothing is printing, your event handler registration is wrong. Show it - it should be registered to the MinecraftForge.EVENT_BUS. http://i.imgur.com/NdrFdld.png[/img]
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.