Minecraft Inventory Saving
Solution 1:
In Minecraft 1.14 and later versions, it is possible to copy the player's inventory to a chest without killing the player.
/data modify block <coordinates of chest> Items set from entity <player> Inventory
Note that this only copies the hotbar and the bottom two rows of the player's inventory, since players can carry slightly more stuff than can fit in a chest. If you want to copy the player's entire inventory to a double chest, you need a much more complicated trick.
Solution 2:
I've got a solution, but it's a bit ugly; it involves killing the player and having them reorganize their inventory at each save. You'll also need keepInventory
off.
Whenever you want to save, teleport the player to an enclosed cell with a hopper on the floor and chest below, then kill them; all of their items should go into the chest. If there were already items in the chest from a previous save, you'll need to /setblock
the chest to clear it first. /clone
this chest with their items to another enclosed cell.
When the player dies, teleport them to the cloned chest and break the chest. All of their items in the cloned chest (that they had when they saved) will fall into their inventory. /clone
the chest again form the original one in case they die again. Then you'll just need to teleport the player out of the cell back to where they were when they saved.
Solution 3:
This video here might be able to help you. The only way I can think of is to have 36 command blocks to test for what item is in your inventory, and have the command blocks run simultaneously once the save command is executed. Then, when the player dies, it gives back all items that the 36 command blocks checked for.