The Bug:
Integer overflow of scoreboard.
Steps to Reproduce:
Run the following commands:
/scoreboard objectives add test dummy
/scoreboard objectives setdisplay sidebar test
/scoreboard players set @s test 2147483647
/scoreboard players add @s test 1
โย โ ย Notice how your score is "-2147483648".
Linked issues
Attachments
Comments 26
Confirmed for
1.8.4
Relates to: MC-80096 (mainly to the part with potions and filled_maps)
You can easily reproduce this:
/scoreboard objectives add Test dummy
/scoreboard objectives setdisplay sidebar Test
/scoreboard players set @p 2147483647
/scoreboard players add @p 1
What do you guys expect Mojang to do exactly? Integer overflow is gonna happen no matter what if you input a high enough number.
It should just stop at 2147483647. Alternatively, a bigger number type (like "long") would make it practically impossible to reach the limit, but at the cost of slightly higher network traffic.
This kind of inconsistent arithmetic would honestly be worse IMO. Making it a long (or possibly even a bigint since IIRC the scores are stored as strings anyway) would be a much better solution.
The only fix I can see happening for this is changing it to longs (which is just moving the issue); command contraptions can easily check if it would overflow, and if undesired, prevent it. Throwing an error message only feels like it could prevent some things from working.
Also, correcting the above comment, scores are saved to files as ints, not strings
Yep. I double checked and indeed they are stored as ints. I wonder why I thought they were stored as strings; perhaps at one point they were or perhaps I misremembered. In any case I don't think there is any possible fix besides changing scoreboards to long (which like you said just moves the issue) or bigint (which would work but comes with its own set of problems).
the number becomes too big for an integer, so it goes to the lowest value possible.