mojira.dev
MC-123078

Scoreboard ranges don't work correctly at extreme values

I suspect that this bug comes from the fact that when the ranges are checked the scoreboard value is cast to single precision floating point when checking, which causes the ranges to behave unexpectedly. This is evidented by the fact that

@e[scores={test=1000000000000000000000000}]
@e[scores={test=1000000000000000000000000}]

is not checked.

Interestingly,

@e[scores={play=1.5}]
@e[scores={play=1.5}]

is checked.

To reproduce:

1. Create a new world and create a new dummy scoreboard objective test
2. run:

/scoreboard players set @p test 16777214
/execute as @e[scores={test=16777215}] run say hi
/scoreboard players set @p test 16777215
/execute as @e[scores={test=16777215}] run say hi
/scoreboard players set @p test 16777216
/execute as @e[scores={test=16777215}] run say hi
/scoreboard players set @p test 16777214
/execute as @e[scores={test=16777215}] run say hi
/scoreboard players set @p test 16777215
/execute as @e[scores={test=16777215}] run say hi
/scoreboard players set @p test 16777216
/execute as @e[scores={test=16777215}] run say hi

In this case, the command should only run when your test score is exactly 16777215 (2^24-1), as expected.

3. run:

/scoreboard players set @p test 16777215
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777216
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777217
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777218
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777215
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777216
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777217
/execute as @e[scores={test=16777216}] run say hi
/scoreboard players set @p test 16777218
/execute as @e[scores={test=16777216}] run say hi

In this case, the command should only run when your test score is exactly 16777216 (2^24). However, it also runs when your test score is 16777217 (2^24+1), as (float)16777216==(float)16777217.

Comments 0

No comments.

Ely G

boq

Confirmed

Minecraft 17w49a, Minecraft 17w49b, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w02a, ..., Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5

Minecraft 1.13-pre6

Retrieved