This behavior pack uses scoreboards to detect player experience levels. Experience levels are not lost after dying and remain upon respawn.
Add the Keep Levels Add-on to your behavior packs on your world. Behavior packs disable achievements, but editing the world with an NBT editor can re-enable achievements when uploading your world to a realm.
Re-enable achievements on either pc or mobile with the free NBT editor Dovetail
The pack is ready to work after adding to your world. If a player dies, they keep their levels, just like with /gamerule keepinventory true
but still lose their inventory.
You can display a player's levels by setting the scoreboard display.
/scoreboard objectives setdisplay sidebar xp_level
Removing levels from a player, like in an NPC Shop or using abilities, will make the score go down. However, removing scores from xp_level
will not remove experience levels.
/xp -10L @p` \\ Scoreboard objective xp_level goes down.
It works functionally the same as the target selectors l
and lm
. The examples below do the same thing.
/execute as @a[lm=10, l=15] run effect @s strength 0 1 true
/execute as @a[scores={xp_level=10..15}] run effect @s strength 0 1 true
_ _ _ _ _
(_) _ _ | | (_) | | |
____ _ _| |_ _| |_ _____ ____ ___| |_____ _____| | |
| \| (_ _|_ _) ___ | _ \ /___)_____ (____ | | |
| | | | | | |_ | |_| ____| | | |___ | | / ___ | | |
|_|_|_|_| \__) \__)_____)_| |_(___/ |_\_____|\_)_)