Topic category: Help with Minecraft modding (Java Edition)
I am trying to create a mod that will need to track how many times a player has died. I am attempting to use nbt tags to track this, where on player join a value is set, and on each respawn the value is adjusted. But I did not think that an entities data number would be reset when they died. How could I go about saving the deaths counter of the player so it persists through death? I could try and use a global variable to track it, but I am needing this to work in multiplayer with multiple players each with their own death counter. Could I create a "ghost" chest, much like an ender chest that I could assign nbt tags to for each player, but that would create the problem of establishing the name for the tag and it being unique per that player. I am new to mcreator and minecraft modding, so it might be something obvious I could do.
Saving deaths in entity NBT is not possible as NBT is removed upon death. You might need to use global variables for this.
The nbt being removed is what I found out while trying my original idea. But how would I create a global variable that is specific to the player?
You could use global_session variable which is specific per Minecraft client instance.
How would I go about saving the data, so on relog it is not reset?
Use session variable only to transfer variable between deaths, then assign the value back to NBT tag.
If there was some way to get/set scoreboard values then this issue could be solved.