Minecraft – Keep items in inventory on death in Minecraft

minecraft-commandsminecraft-java-edition

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)?

Best Answer

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.