(Java Minecraft 1.15) Tellraw incremental death messages
Recently I have been making a map, I was wondering if an incremental tell raw death message could be applied.
What I mean by this is, if you die, chat will automatically say "Death, 1" Next time you die, chat will automatically change the tellraw command into "Death, 2" And so on.
Is this possible? Also im playing in Snapshot 19w38b
You can use the deathCount
scoreboard criterion.
Create a tempDeaths
objective which will increment automatically when a player dies:
/scoreboard objectives add tempDeaths deathCount
Then create another objective called deaths
that will be incremented manually:
/scoreboard objectives add deaths dummy
The reason for the two objectives is so that a player dying (which will increase tempDeaths
) can be detected by testing if it is at least 1. tempDeaths
will then be reset to 0 so that the tellraw message will not show constantly. deaths
will also be manually incremented, which will be displayed in the message.
Put the following in these command blocks.
Repeating, unconditional, always active: checks each player if they have died 1 or more times and if they have, increment the deaths
objective.
execute as @a[scores={tempDeaths=1..}] run scoreboard players add @s deaths 1
Repeating, unconditional, always active: shows "Death, #" to the player who died.
execute as @a[scores={tempDeaths=1..}] run tellraw @s ["Death, ",{"score":{"name":"@s","objective":"deaths"}}]
Chain, conditional, always active: resets tempDeaths
. This command block needs to be placed so that one of the repeating command blocks is directly behind it (so that this command block is facing away from the repeating one and that the repeating one is facing towards this one).
scoreboard players set @a tempDeaths 0