mojira.dev
MC-123270

Inconsistent xp and level value

When the player has 2920 xp, he is supposed to just reach lvl 40, but depending on how you get the amount of xp, you can end up being lvl 39 with a maxed out xp bar.

Use these commands to set up and reset the xp value :

/xp set @p 0 levels
/xp set @p 0
/gamemode survival @p

Commands in this order result with lvl 40 :

/xp add @s 2000
/xp add @s 920

Commands in this order result with lvl 39 and maxed out xp bar :

/xp add @p 920
/xp add @p 2000

This is caused by the experience value still being stored as float and used in calculation, sometimes the condition while(this.experience >= 1.0) is failing when this.experience is barely equals to 1.0 due to float precision error.
Note that no experience points are ever lost in either process.

Linked issues

Comments 9

Confirmed for 18w30b

Confirmed for 18w31a

Confirmed for 18w32a

Confirmed for 18w33a

Confirmed for 1.13.1-pre1

Can confirm in 20w49a.

Can confirm in 21w03a.

Can confirm in 21w05b.

Still there in 1.21, as long as the float value is not replaced by an integer, the issue will remain. This creates (small yes but still) loss of experience

mrpingouin1

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.12.2, Minecraft 17w50a, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, ..., 20w27a, 1.16.4, 20w49a, 21w03a, 21w05b

Retrieved