Jump to content

Adding a onFoodEaten event


Geert4321

Recommended Posts

Hello I am Geert4321,

 

I am creating a mod at the moment which semi - requires an onFoodEaten event. It is not neccesary because it is just for a temporary hold and for an optional feature, but I would highly appreciate it to have that event. It might also be helpful for other modders.

 

It would make my christmas merry if you were to implement this feature. I was originally going to add it through ASM, but soon realised that I was unable to do that (as myself, so I couldnt do it, maybe others can) as when I edited the base files directley, the event wouldnt even trigger. So yeah, that is pretty much it :)

 

Greetings, Geert4321

Link to comment
Share on other sites

Yes but if you look even further, the method is protected. So I cannot access it, also it does not tell me which food the player is eating. I could go check every tick if the player is using something and then get the ItemStack but really that is a pain in the ***. So an event would be MUCH easier

Link to comment
Share on other sites

  • 2 weeks later...

Try using the net.minecraftforge.event.entity.player.PlayerDestroyItemEvent. It's given an EntityPlayer (the player) and an ItemStack (the stack consumed or destroyed). It's called whenever an item is eaten or when destroyed after a rightclick event (there may be other conditions, but it's basically just called when an temstack is destroyed (size<=0)). Just check to see if the itemstack was the food you are looking for and tell it to do something.

Link to comment
Share on other sites

  • 2 weeks later...

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

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

Announcements



×
×
  • Create New...

Important Information

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