How do I set XP levels to a scoreboard objective?

How do I set XP levels to a scoreboard objective? - High angle of various wall dowels on while fabric during process of repair

I want to set the XP levels to a scoreboard objective. I tried getting the two variables and then changing it based on their difference, but the result increases when it is supposed to decrease and vice-versa. Edit: Commands come from



Best Answer

I'm not aware of an easy way to do this (there may be a trick I'm missing), but it's somewhat possible with a number of command blocks and a binary-search-like method. I'll use a dummy objective called "ExpController" for this example.

After you've changed the scoreboard objective, to set your experience to the objective, run the following commands in this order:

/xp -1000000000l @a
/xp 512l @a[score_ExpController_min=512]
/scoreboard players remove @a[score_ExpController_min=512] ExpController 512
/xp 256l @a[score_ExpController_min=256]
/scoreboard players remove @a[score_ExpController_min=256] ExpController 256
/xp 128l @a[score_ExpController_min=128]
/scoreboard players remove @a[score_ExpController_min=128] ExpController 128
/xp 64l @a[score_ExpController_min=64]
/scoreboard players remove @a[score_ExpController_min=64] ExpController 64
/xp 32l @a[score_ExpController_min=32]
/scoreboard players remove @a[score_ExpController_min=32] ExpController 32
/xp 16l @a[score_ExpController_min=16]
/scoreboard players remove @a[score_ExpController_min=16] ExpController 16
/xp 8l @a[score_ExpController_min=8]
/scoreboard players remove @a[score_ExpController_min=8] ExpController 8
/xp 4l @a[score_ExpController_min=4]
/scoreboard players remove @a[score_ExpController_min=4] ExpController 4
/xp 2l @a[score_ExpController_min=2]
/scoreboard players remove @a[score_ExpController_min=2] ExpController 2
/xp 1l @a[score_ExpController_min=1]
/scoreboard players remove @a[score_ExpController_min=1] ExpController 1

If you want to use numbers higher than 1023, which is the maximum the commands above will go currently, continue on the pattern (e.g: 1024, 2048, doubling each time, placing the new commands just after the first command).

All players' ExpController scores will be 0 after this. If you want to keep your EXP score as it is, you should clone it to a temp objective right before you do this, and use the temp objective for the above commands:

/execute @a ~ ~ ~ /scoreboard players operation @a[c=1] ExpTemp = @a[c=1] ExpMain



Pictures about "How do I set XP levels to a scoreboard objective?"

How do I set XP levels to a scoreboard objective? - From above of boxes with different metal nails and plastic dowels in workshop
How do I set XP levels to a scoreboard objective? - Various tool bits on white background
How do I set XP levels to a scoreboard objective? - Set of various metal hex keys



How do you set your xp level in Minecraft?

When you use the L attribute with the /xp command, you add experience levels to a player. An experience level is one entire bar filled. When you add an experience level, you will see the experience level counter for the player increase. Type the command in the chat window and press the Enter key to run the command.

How do you add scoreboard objectives?

Scoreboard Command
  • To add an objective: /scoreboard objectives add <objective> <criteria> [displayName]
  • To remove an objective: /scoreboard objectives remove <objective>
  • To list all objectives: /scoreboard objectives list.
  • To set how the objectives are displayed: /scoreboard objectives setdisplay <slot> [objective]




  • Minecraft - Set XP to Scoreboard




    More answers regarding how do I set XP levels to a scoreboard objective?

    Answer 2

    check this formula calculator out http://pernsteiner.org/minecraft/levelcalc.html copy down the formulas to command blocks.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Ksenia Chernaya, Ksenia Chernaya, Ksenia Chernaya, Ksenia Chernaya