This is a feature on the all versions of MineCraft unless otherwise configured: When you die, your inventory drops.
You are able to disable this feature in singleplayer by typing /gamerule keepInventory true
Please note that this only works if cheats are enabled.