The bug
The value of the XpTotal tag of a player which is used as value for scoreboard objectives of the criteria type xp and the query result of the /xp command when giving experience (not levels) does not account for level changes.
It is basically the number of experience the player has collected. It only resets to 0 when the player would have a negative experience level.
Affected events:
Enchanting
Using an anvil
Adding or removing levels using
/xp
How to reproduce
Create a scoreboard objective tracking the xp of a player
/scoreboard objectives add xp xp /scoreboard objectives setdisplay sidebar xpUse for example the
/xpcommand/xp add @s 10 levels❌ The score does not update
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The tag XpTotal (field net.minecraft.entity.player.EntityPlayer.experienceTotal) is only increased by the method net.minecraft.entity.player.EntityPlayer.addExperience(int) and additionally never decreased.
Linked issues
is duplicated by 5
relates to 1
Comments 8
This issue is also present when an anvil consumes a player's levels: the levels are removed but the xp on the scoreboard remains unchanged.
Can confirm in 1.16.2.
Get some experience, /xp set @p 0 and /xp set @p 0 levels will keep the score to the old value. This is so annoying for datapacks while dealing with experience.
@@unknown sorry for the many e-mail notifications about changes. I tried to make the report more generic and I hope you are fine with that.