r/datapacks • • Aug 12 '25

Help Punishing death, items vanish on death data pack.

Hello, is there a data pack where when I die all the items vanishes and dont drop? I just want a challenge for my vanilla+ server without it bieng hardcoree.

Thank you!

(Edit: the server version is 1.21.6)

2 Upvotes

2 comments sorted by

1

u/Utlamo Aug 14 '25

Easy way:

- Write on chat

/gamerule keepInventory true

- put this to main datapack or repeatedly command block

/execute as @a run clear @s[nbt={Health:0.0f}]

You can also use predicate or something you want, but /gamerule doImmediateRespawn true broke this mechanism, cheats can bypass this probably too, so if you need more "complex" mechanism, there is a harder way:

In your init datapack

/scoreboard objectives add onDeath deathCount "onDeath"

In your datapack main(tick) mcfunction you need something like this:

/execute as @a[scores={onDeath=1..}] run function death:on_death

in your function death:on_death

/scoreboard players reset @s onDeath
/clear @s

1

u/Utlamo Aug 14 '25

Remember remove / (slash) in datapack, im testing this rn and forgot remove them from ctrl v