0

My friends and I are playing a Hardcore style playthrough of Minecraft. We want instead of death being permanent, teleport the player to a challenge area that gets harder the more you die. The commands I've tried already haven't seemed to work.

1 Answer 1

0

Because Minecraft commands have no event system, you cannot just say: 'run when someone dies'. Instead, you need to keep track of a separate deathCount variable that constantly get set back to zero. The purpose of this is to detect when a player dies. If they die, their score goes up by one, your commands run, then it goes back to zero. If they don't die, nothing happens. Therefore, you use this temporary variable to detect when they die, because if they are to die, their score goes up by one for one, and only one iteration of a command block chain.

To summarize, you keep track of two deathCount variables. One is the normal one, to tell you how many times they have died in total, so you know which platform to teleport them to. The other is a Temp variable, which serves only to tell you when they die, so you are not constantly teleporting them to a specific spot, but only when and if they die.

Setup

scoreboard objectives add totalDeaths deathCount {"text":"Number of Times Died"}
scoreboard objectives add tempDeaths deathCount

An example loop

execute as @e[scores={totalDeaths=..0,tempDeaths=1}] in minecraft:the_overworld run tp @s 0 64 0   #If they die without dying, they spawn at spawn
execute as @e[scores={totalDeaths=1,tempDeaths=1}] in minecraft:the_nether run tp @s 64 64 64      #Where I assume your first platform are. You can also add datapack dimensions here
execute as @e[scores={totalDeaths=2,tempDeaths=1}] in minecraft:the_nether run tp @s 64 64 -64     #The second platform? All of these are subject to change, this is an example
...                                          # However many more platforms you want

scoreboard players set @a tempDeaths 0       # So that once they die, they do not then constantly get teleported back to that one spot on the platform. If you mess up and create a teleporting loop, there are lots of great answers on Arqade to get you out of it
7
  • should i put these in command blocks Commented Feb 16, 2021 at 0:29
  • I used a datapack function file as an example, but you can easily use command blocks, with one per line. Keep in mind that these need to be in a command block chain, and that you need to remove my comments Commented Feb 16, 2021 at 0:33
  • I apologies all the commands work except that its clears the temp death to fast in a chain block. so they do not get teleported. If I take away the clear tempdeaths command then they get stuck in a teleport loop. How should I fix this Commented Feb 16, 2021 at 2:07
  • Either put back the tempDeaths, or you will need to look at this answer: gaming.stackexchange.com/a/230213/265096 Commented Feb 16, 2021 at 2:40
  • I can gladly put back the temp deaths. but i if add it to the the chain it goes to fast so that it clears the temp death before they are teleported Commented Feb 16, 2021 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .