If you run a server or SP world, and have keep inventory on, but hate there is no reprecussion for dying.
Well I've found the solution after hours of trying to figure it out for my server.
create a scoreboard for deaths
/scoreboard objectives add deaths deathCount
to get a command block, you need to be OP (if you have cheats off in SP just open LAN and enable cheats before starting), and you need to be in creative mode. /give (playername) minecraft:command_block
You will need two command blocks set up at spawn, Preferably in the bedrock of your world.stack them on top of each other with the arrows point up. I'm sure this would work any direction, but your repeat, unconditional command block, must point into the chain, conditional block. see attached photo.
Repeat, unconditional, always active
execute as @e[type=player,scores={deaths=1}] run experience add @e[type=player,scores={deaths=1}] -1000 levels
*(this will detect if a player has a death score of 1, and then take away all experience up to 1000 levels.)*
If you run a server or SP world, and have keep inventory on, but hate there is no reprecussion for dying.
Well I've found the solution after hours of trying to figure it out for my server.
create a scoreboard for deaths
/scoreboard objectives add deaths deathCount
to get a command block, you need to be OP (if you have cheats off in SP just open LAN and enable cheats before starting), and you need to be in creative mode.
/give (playername) minecraft:command_block
You will need two command blocks set up at spawn, Preferably in the bedrock of your world.stack them on top of each other with the arrows point up. I'm sure this would work any direction, but your repeat, unconditional command block, must point into the chain, conditional block. see attached photo.
Repeat, unconditional, always active
execute as @e[type=player,scores={deaths=1}] run experience add @e[type=player,scores={deaths=1}] -1000 levels
*(this will detect if a player has a death score of 1, and then take away all experience up to 1000 levels.)*
Chain, conditional, always active
scoreboard players reset @e[type=player,scores={deaths=1}] deaths
*(this will reset the players score for deaths to 0 if it is at 1. If this is not done, xp will continuously be taken away even if gaining it.)*
You're welcome!
StonedCraft Server Admin; End0Skeleton
P.S. This works 1.13+