Minecraft – make players have constantly full health

minecraft-commandsminecraft-java-edition

In a map I'm building, I want players to always have full health, no matter what damages them, as long as it doesn't kill them. That is, when they get 19.5 hearts worth of damage, their health will instantly refill, but when they get 20 hearts damage at once, they die. I already tried doing

/effect @p minecraft:regeneration 100000 255

This only regenerates the health fast, not instantly. How can I do this?

Best Answer

Never thought it could be so easy, just do this:

/effect @p minecraft:instant_health 100000 1

This will give you instant health regeneration for 100000 seconds (only for 27 hours and 46 minutes) - it will give you instant health as a potion effect until you drink milk or die. You heal instantly, without even seeing the health go down. A clock can be used to re-apply the effect.