To keep all of your items when you die is easy in Minecraft, as all you will need to do is use a simple gamerule command.
But before you can use commands in Minecraft such as gamerules, you will need to enable cheats via the option to do so in the main menu or when you go to create a brand new Minecraft world.
Once cheats and commands are enabled, all you need to do to disable fire damage is type or copy and paste the simple game rule /gamerule keepInventory true and hit enter.
Related: How to remove Fire Damage in Minecraft?
Doing so will then allow you to keep everything in your inventory when you die, thus avoiding losing any items to annoying deaths such as falling in lava.
If you want to use this command for a server, just locate your server console and type or copy and paste the same command in and hit enter. The command will then have the same effect, just like with client-side games.
But if you ever want to revert the changes made to your inventory, all you need to do is use the same command but with a slight change. Instead of true at the end of the command, change it to false. So type /gamerule keepInventory false and then hit enter.
Check out some of our other awesome Minecraft guides!