Experience orbs operate on integer values, and players can use vanilla commands to spawn an exp orb with an exact value.
Spawning an orb at 100k is valid, however if that orb is unloaded, the NBT data saves it as a short, corrupting the value.
Fixing is as trivial as changing the NBT set/get calls to Int for Value instead of Short
Related issues
relates to
Comments


have I mentioned how much I hate that environment is a text field above description?....

Tested in 20w07a, spawning in experience orbs beyond the 16 bit integer limit seems to spawn orbs with negative values, implying that orbs now use shorts for storing values all the time.

Is this truly invalid? Or was the resolution based on my potentially incorrect comment judging by the other ticket?

In 20w07a (and probably earlier) the value is both serialized and deserialized as short
, additionally it is also serialized as short
for the ClientboundAddExperienceOrbPacket
packet (Mojang name).

As reported by Connor, that wasn't what was needed to fix it. It needed to be made an int instead to solve the overflow issue.
there is no benefit to try to be conservative on 2 bytes here. This isn't a heavy packet.

Commands read the value as short
as well and there appears to be no case where it is possible that during vanilla gameplay an XP orb with an overflowing experience amount is created.
Do you have a way to create such XP orbs (without calling the ExperienceOrb
constructor directly)?
Otherwise you could question in general why certain NBT fields are (de-)serialized as something other than int
.

Is it not possible to spawn an entity and supply its nbt data, passing a large int?
Connors comment implies they did.

I haven't tested in 1.13 or earlier.

While it is possible to write an int
in the NBT string, the same methods used for deserialization are called so the int
is read as short
(this applies to all entities and block entities).
/summon minecraft:experience_orb ~5 ~ ~ {Value:32768}
Summons an XP orb with value -32768s
.
I will therefore resolve this report as "Invalid". Please let us know if you find a way to create an XP orb with a value higher than 32767 (short
max value) without directly calling its constructor.
Please attach the crash report (
[minecraft|http://hopper.minecraft.net/help/finding-minecraft-data-folder]/crash-reports/crash-<DATE>-client.txt
), otherwise we can not diagnose this issue.For technical support please use the Mojang Support Center.
-- I am a bot. This action was performed automagically!