Drop Drop XP is a datapack that eliminates the hassle of losing your experience when dying. Unlike the gamerule keepInventory, players will drop their items upon death without worrying about losing their levels. It may be annoying to lose your XP when you want to enchant something, so this datapack removes players dropping XP while still losing their items. This datapack also has the option to have XP penalties when players die.
Scoreboard to Point Binary Decomposition by Cloud Wolf.
By default, the datapack's goal is to prevent any levels from being lost on death. However, there are a couple of options to have a penalty be applied upon death. By using the command, /function dont_drop_xp:_change_xp_penalty_type, you can change the type of XP penalty that will be applied when players die. Operators can additionally customize the percent of XP lost with /function dont_drop_xp:_change_xp_percent_lost.
Penalty Type Options:
This datapack can not be easier to install and uninstall.
Simply place the datapack file into the datapacks folder in your singleplayer or multiplayer world. Upon loading the world or by using the /reload command, the datapack will be installed.
To uninstall, use the command, /function #dont_drop_xp:uninstall. This will automatically remove all related objective scoreboards. You can then disable or delete the datapack from there.