I once played a vanilla Minecraft adventure map (called “Herobrine’s Mansion”) that prevented the player from losing their items on death. Which commands can be used to prevent the player from losing their items on death (in vanilla Minecraft)?
You can use the command
/gamerule keepInventory true (case sensitive) to prevent the player from losing items on death. This command will work in Vanilla Minecraft, without using any mods (as long as cheats are enabled). You can also do this on a server as long as you have operator status.
Source : Link , Question Author : Anderson Green , Answer Author : kotekzot