-1

I want to create an adventure map, with healing items, but potions aren't stackable, what isn't very good. So, is there a command in 1.13/1.14 that makes food heal the player?

  • It already does. What's your real problem? – Fabian Röling Feb 2 at 16:00
  • 1
    @Fabian Röling I assume the asked wants to apply an instant health effect on eating – Unionhawk Feb 2 at 16:02
1

I assume you want players to get an effect when eating foods. If you want one kind of food in general to heal, then that's easy.

First, create a scoreboard that tracks players who eat the kind of food you want to heal (in this case, a cookie):

/scoreboard objectives add heal minecraft.used:minecraft.cookie

Then run these commands in a repeating chain:

effect give @a[scores={heal=1..}] instant_health
scoreboard players reset @a heal

This will give players who have used a cookie instant health, and then immediately resets their score so they can do it again.

If you want named foods to give health, you'll need to add some more commands. Put this in a repeating chain instead:

effect give @a[tag=heal,scores={heal=1..}] instant_health
scoreboard players reset @a heal
tag @a remove heal
tag @a[nbt={SelectedItem:{id:"minecraft:cookie",tag:{display:{Name:"\"Health Biscuit\""}}}}] add heal

This tags players who are holding a cookie named "Health Biscuit" with a "heal" tag, then the same thing is done in the first example.

The reason why I put the tag commands below the effect and scoreboard commands is because once you have used the cookie, it would no longer be in your hand, so it would be impossible to tag the player. Putting the tag commands on the bottom will tag the player, then in the next tick, when they have eaten the cookie, will heal the player because he already has that tag.

To change what you want your food to be, just change the objective to minecraft.used:minecraft.foodnamehere.

This is where to change what you want the food's name to be in the tag command:

tag @a[nbt={SelectedItem:{id:"minecraft:cookie",tag:{display:{Name:"\"HERE IS WHERE TO EDIT YOUR FOOD NAME\""}}}}] add heal

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.