mojira.dev
MC-3266

Your experience level overflows once it exceeds the integer limit

The bug

The XP level can overflow causing the experience bar to disappear.

How to reproduce

  1. Type /xp set @s 2147483647 levels. Now your level is 2147483647.

  2. Type /xp add @s 1 levels. XP disappears from display.

  3. Type /xp add @s 1 levels again. Now your level is 1.

So, maximum player's level is 2^31 - 1, after which the level overflows and is treated as 0. The possible solution (suggested by @unknown) is to cap maximum level.

Linked issues

Attachments

Comments 44

I think the solution here is not to make this an unsigned int, but to simply cap the max level so it doesn't happen.

Well, you're right, Mustek. Capping is much better way.

Also, Java doesn't really support unsigned ints well.

Another option would be to use BigInteger instead of int. But capping seems reasonable.

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

34 more comments

Can confirm in 1.18.2.

Can confirm in 1.19.

this is because of the 32 signed bit integer limit (2,147,483,647) after this number the game automaticly resets your level to 1. this happends because of the way how the xp level is stored

 

@unknown Could you please not go through tons of tickets, making either obvious/redundant (MC-201, MC-1531, MC-3266, MC-1673, …) or incorrect (MC-180, MC-212, MC-2157, MC-2112, MC-2791, MC-1297, …) statements? I got lots of mails from your comments over night, followed by a bunch of mails of people correcting you. Please only contribute if you actually have new and relevant information, not baseless speculation. Also, if you want go through all currently open bugs, prepare some meals first, because you'll need a really long time for 8375 reports…

Can confirm in 1.19.2.

Norrius

lord.quadrato

etanaratsastaja

Confirmed

Platform

Low

Player

experience, overflow

Minecraft 1.4.4, Minecraft 1.4.5, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w02a, ..., 1.20, 1.20.1, 1.20.2, 1.20.4, 1.21

24w33a

Retrieved