0

I've tried using command blocks only.

I googled but couldn't find anything.

1
  • It seems not at the moment. I'm looking into a 'hack' that may make it possible, but honestly, I seem to be barking up the wrong tree and at the wrong time.
    – ydobonebi
    Aug 4, 2015 at 1:06

1 Answer 1

4

I see two main ways to do this, neither of which are that great. If it's not necessary, I'd recommend not doing this.


First way would be to set the score individually for each level, like this:

/scoreboard players set @a[l=0,lm=0] XPScore 0
/scoreboard players set @a[l=1,lm=1] XPScore 1
/scoreboard players set @a[l=2,lm=2] XPScore 2
...

The main problem with this method is that you'll need a ton of command blocks. I'd probably go with supporting 127 levels if this is just vanilla/survival.


Next method is a bit more complicated, but would cut down the command blocks needed from 127 to around 30 whilst still supporting the same max level.

First, you'd set everyone's XP score to 0:

/scoreboard players set @a XPScore 0

Then, in this exact order, run these commands:

/scoreboard players add @a[lm=64] XPScore 64
/xp -64L @a[lm=64] 
/scoreboard players add @a[lm=32] XPScore 32
/xp -32L @a[lm=32]
/scoreboard players add @a[lm=16] XPScore 16
/xp -16L @a[lm=16] 
/scoreboard players add @a[lm=8] XPScore 8
/xp -8L @a[lm=8] 
/scoreboard players add @a[lm=4] XPScore 4
/xp -4L @a[lm=4] 
/scoreboard players add @a[lm=2] XPScore 2
/xp -2L @a[lm=2] 
/scoreboard players add @a[lm=1] XPScore 1
/xp -1L @a[lm=1] 

This should set everyone's XPScore to their XP. Problem is that it also sets their XP to 0, so afterwards you need to clone their XPScore to another objective, I'll call mine "XPTemp":

/execute @a ~ ~ ~ /scoreboard players operation @p XPTemp = @p XPScore

Then you need to set their XP level back to what it was before using pretty much the reverse of what was above.

/xp 64L @a[score_XPTemp_min=64] 
/scoreboard players remove @a[score_XPTemp_min=64] XPTemp 64
/xp 32L @a[score_XPTemp_min=32] 
/scoreboard players remove @a[score_XPTemp_min=32] XPTemp 32
/xp 16L @a[score_XPTemp_min=16] 
/scoreboard players remove @a[score_XPTemp_min=16] XPTemp 16
...
3
  • While I really hope that this is not the best solution, I can't think of a better one. It is also easily expandable to higher levels.
    – MrLemon
    Aug 4, 2015 at 12:34
  • Have you tried this? I am a little concerned about the level up sound effects, even though the game might not even register the changes when run on a fill clock.
    – MrLemon
    Aug 4, 2015 at 12:37
  • @MrLemon I have used a similar system before, although it was a minigame in which the players XP was only changed with command blocks, thus I could have this only run when their XP changed. Can't really think of a way to check if the player's XP has changed in survival (without doing this to set a score).
    – SirBenet
    Aug 4, 2015 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .