Doing a cheeky little necro post to show a new command creation i whipped up over night.
It's a sort of spin on hardcore where if you die, you drop an enchanted golden apple along with your items. So as long as you don't fall in lava, or the void, if you can make it back to where died and eat the apple without dying, you basically have infinite lives.
Here are the commands:
SCOREBOARDS
-Life counter, Adds a life when a player eats an enchanted golden apple
/scoreboard objectives add Lives minecraft.used:minecraft.enchanted_golden_apple
-Death tracker
/scoreboard objectives add Deathtick deathCount
COMMAND BLOCKS
-A repeat command block removes a players life when they die
/scoreboard players remove @a[scores={Deathtick=1..}] Lives 1
-Another repeat command block adds permadeath, setting a player gamemode to spectator when they run out off lives
/gamemode spectator @a[scores={Lives=-1}]
-Drops an Enchanted Apple where ever a player dies
/execute if entity @a[scores={Deathtick=1..}] at @a[scores={Deathtick=1..}] run summon item ~ ~ ~ {Age:-32768,Item:{id:"minecraft:enchanted_golden_apple",count:1}}
-Resets the death tracker
/scoreboard players set @a Deathtick 0
You can put these in your world now if you want! 🙂
I play with a datapack that lets me craft Enchanted apples with diamonds lol.