Started by Lapisor on Fri, 01/06/2023 - 18:50
Topic category: Help with modding (Java Edition)
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?
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.
I'd already tried the first method, and it didn't carry over NBT data. The second method works perfectly though!
You're welcome! :>