How do I make food not consumed upon being eaten?

Started by Lapisor on

Topic category: Help with modding (Java Edition)

Last seen on 05:05, 7. Jan 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make food not consumed upon being eaten?

Hi!
I'm trying to make a food which can be eaten multiple times. I've done all the code to be able to make this happen, but I am unable to remove the vanilla way of eating (eating once per item). How can I stop the item being removed when eaten once?

Last seen on 11:35, 27. Mar 2023
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There are two pretty simple…
Fri, 01/06/2023 - 23:13

There are two pretty simple ways to do it.

1. Create your item and add whatever food properties to it you want. Now on the food properties page set the item eating result to that same item (you'll have to finish the item and then re-enter it's editing menu to do that).

2. Create your item and add whatever food properties to it you want. Then create a new procedure. Place an if block that checks if the player is not in creative mode. Put the procedure block "Grow provided itemstack by 1" into it and save your procedure. Afterwards open your item's editor and select the procedure in "When player finishes using item".

The difference between the two is actually minuscule. If you use the first way you'll get a sound and a different animation sort of thing while with the second one you just finish eating the food as you normally would.

Last seen on 05:05, 7. Jan 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks!I'd already tried the…
Sat, 01/07/2023 - 05:05

Thanks!
I'd already tried the first method, and it didn't carry over NBT data. The second method works perfectly though!

Last seen on 11:35, 27. Mar 2023
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're welcome! :>
Sat, 01/07/2023 - 10:06

You're welcome! :>