[MC-3266] Your experience level overflows once it exceeds the integer limit Created: 17/Nov/12  Updated: 26/Jun/24  Resolved: 26/Jun/24

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.4.4, Minecraft 1.4.5, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w02a, Snapshot 13w02b, Snapshot 13w03a, Minecraft 1.5.1, Minecraft 1.7.4, Minecraft 14w03b, Minecraft 1.8, Minecraft 1.8.1-pre3, Minecraft 1.8.4, Minecraft 1.8.7, Minecraft 1.8.9, Minecraft 16w05b, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w35a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w41a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 1.11.1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13a, Minecraft 17w13b, Minecraft 17w14a, Minecraft 17w15a, Minecraft 17w16a, Minecraft 17w17b, Minecraft 17w18a, Minecraft 17w18b, Minecraft 1.12 Pre-Release 1, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 3, Minecraft 1.12 Pre-Release 4, Minecraft 1.12 Pre-Release 5, Minecraft 1.12 Pre-Release 6, Minecraft 1.12 Pre-Release 7, Minecraft 1.12, Minecraft 17w31a, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, Minecraft 1.12.2 Pre-Release 2, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45a, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w03b, Minecraft 18w06a, Minecraft 18w09a, Minecraft 18w14b, Minecraft 18w16a, Minecraft 18w19b, Minecraft 18w20c, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre6, Minecraft 1.13-pre7, Minecraft 1.13-pre8, Minecraft 1.13-pre9, Minecraft 1.13-pre10, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 18w32a, Minecraft 1.13.1-pre1, Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2-pre1, Minecraft 1.13.2-pre2, Minecraft 1.13.2, Minecraft 18w43a, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03a, Minecraft 19w03c, Minecraft 19w04b, Minecraft 19w07a, Minecraft 19w12b, Minecraft 19w13b, Minecraft 19w14a, Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 3, Minecraft 1.14.3, Minecraft 1.14.4 Pre-Release 5, Minecraft 1.14.4 Pre-Release 6, 1.14.4, 19w39a, 19w40a, 1.15 Pre-release 6, 1.15, 1.15.1, 1.15.1 Pre-release 1, 1.15.2 Pre-release 2, 1.15.2, 20w11a, 20w17a, 20w20b, 20w21a, 20w22a, 1.16 Pre-release 2, 1.16.1, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Release Candidate 1, 1.16.2, 1.16.3, 1.16.4, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w11a, 21w13a, 21w14a, 21w15a, 21w17a, 21w18a, 1.17, 1.17.1, 21w39a, 1.18.1, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4, 23w14a, 1.20 Release Candidate 1, 1.20, 1.20.1, 1.20.2, 1.20.4, 1.21
Fix Version/s: 24w33a

Type: Bug
Reporter: [Helper] Lord_Quadrato Assignee: [Mojang] etanaratsastaja
Resolution: Fixed Votes: 50
Labels: experience, overflow

Attachments: File MC-3266.mp4     PNG File MC-3266.png    
Issue Links:
Duplicate
is duplicated by MC-5667 After 10 digits on the levels it glic... Resolved
is duplicated by MC-7832 /xp <number>L <player> command Resolved
is duplicated by MC-80399 Variable overflow Resolved
is duplicated by MC-105942 XP Bar Glitches in and out of GUI at ... Resolved
is duplicated by MC-119095 The Xp bar disappers when the player ... Resolved
Relates
relates to MC-79545 The experience bar disappears when to... Open
relates to MC-15876 Negative Score on Death Resolved
CHK:
Confirmation Status: Confirmed
Category:
Player
Mojang Priority: Low
Area: Platform

 Description   

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 mustek) is to cap maximum level.



 Comments   
Comment by [Mod] Avoma [ 06/Aug/22 ]

Can confirm in 1.19.2.

Comment by Fabian Röling [ 23/Jul/22 ]

HubbiGamingTV 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…

Comment by HubbiGamingTV [ 22/Jul/22 ]

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

 

Comment by [Mod] Avoma [ 08/Jun/22 ]

Can confirm in 1.19.

Comment by [Mod] Avoma [ 02/Mar/22 ]

Can confirm in 1.18.2.

Comment by [Mod] Avoma [ 14/Dec/21 ]

Can confirm in 1.18.1.

Comment by [Mod] Avoma [ 04/Oct/21 ]

Can confirm in 21w39a.

Comment by [Mod] ampolive [ 15/Jul/21 ]

Can confirm in 1.17.1.

Comment by [Mod] Avoma [ 08/May/21 ]

Can confirm in 1.16.5 and 21w18a.

Comment by [Mod] Avoma [ 30/Apr/21 ]

Can confirm in 21w17a.

Comment by [Mod] Avoma [ 19/Apr/21 ]

Can confirm in 21w15a.

Comment by [Mod] Avoma [ 11/Apr/21 ]

Can confirm in 21w14a.

Comment by [Mod] Avoma [ 06/Apr/21 ]

Can confirm in 21w13a.

Comment by [Mod] Avoma [ 27/Mar/21 ]

Can confirm in 21w11a.

Comment by [Mod] Avoma [ 18/Feb/21 ]

Can confirm in 21w07a. Video attached.

Comment by [Mod] Avoma [ 12/Feb/21 ]

Can confirm in 21w06a.

Comment by [Mod] Avoma [ 04/Feb/21 ]

Can confirm in 21w05b.

Comment by [Mod] Avoma [ 22/Jan/21 ]

Can confirm in 21w03a.

Comment by [Mod] Avoma [ 24/Dec/20 ]

Can confirm in 20w51a.

Comment by [Mod] Avoma [ 25/Nov/20 ]

Can confirm in 20w48a.

Comment by ouroya [ 18/Nov/20 ]

@Marcono1234, In survival, the maximum level is much less than 2^31-1, as the amount of xp points (not levels) is capped at the 32-bit limit, restricting you to level 21863. Rays Works on youtube has demonstrated this in vanilla survival on the ProtoTech server, using a very powerful XP farm which he ran for multiple weeks.

Comment by pulpetti [ 19/Jul/20 ]

In 1.16.1 and 20w29a.

Comment by Marcono1234 [ 28/May/20 ]

@FaRo1, Math.addExact throws an exception on overflow which would not be helpful here. Capping the value at the maximum positive value sounds reasonable especially since such high XP levels can likely not be obtained in Survival anyways.

Comment by Fabian Röling [ 26/May/20 ]

Java already has Math.addExact, which doesn't allow overflows. The fix is just to use that. Using a bigger number type would not fix the problem, just postpone it.

Comment by Robin Lindner [ 26/May/20 ]

You could turn the signed 32-bit integer into a signed 64-bit integer, but this requires 4 bytes more per player in the player data. Sure, this might be a bit small-minded, but is it really necessary to have such a high-level number? This is hardly playable in Survival? A solution would be a BigInt which is then saved as a string in the world file. Unfortunately Java does not support unsigned integer, so you would have to write a wrapper around the integer to only cut the negative range.

Comment by W_V [ 14/Dec/19 ]

Happening in 1.15 and its snapshots. And in 1.15.1 Pre-Release 1.

Comment by [Mod] Pokechu22 [ 25/Apr/18 ]

Thanks. I'd updated my setup in my world for this with the new commands, but never updated the ticket.

Comment by [Helper] Lord_Quadrato [ 25/Apr/18 ]

Still present in 18w16a.
Might want to update the Steps to reproduce to 1.13-format, this renders the first point useless (as with the new command you can set the level)
Here's the updated version:
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.

Comment by Ktoś Ktosiowski [ 30/Jun/17 ]

Confirmed for 1.12

Comment by user33 [ 28/Apr/17 ]

Confirmed for 17w17b.

Comment by . [ 12/Apr/17 ]

Confirmed for 17w15a.

Comment by . [ 08/Feb/17 ]

Confirmed for 17w06a.

Comment by . [ 14/Nov/16 ]

Confirmed for 1.11.

Comment by . [ 08/Nov/16 ]

Confirmed for 1.11-pre1.

Comment by [Mod] Pokechu22 [ 29/Jun/16 ]

FYI: the term is "overflow", not "overfloat".

Comment by Marcono1234 [ 05/Feb/16 ]

Confirmed for

  • 16w05b
Comment by Itouch2 [ 13/Jul/15 ]

confirmed for 1.8.7

Comment by Marcono1234 [ 17/May/15 ]

Confirmed for

  • 1.8.4 relates to MC-79954 and MC-79944
    I guess you can create one general report for this as it seems to affect all variables
Comment by [Mod] Ezekiel (ezfe) [ 26/Jul/14 ]

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

Comment by Tails [ 15/Mar/13 ]

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.

Comment by Jonathan Haas [ 14/Dec/12 ]

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

Comment by Jonathan Haas [ 17/Nov/12 ]

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

Comment by Norrius [ 17/Nov/12 ]

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

Comment by Mustek [ 17/Nov/12 ]

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.

Generated at Sun Jan 12 12:00:39 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.