The bug
Both score holder arguments in /scoreboard players operation accept multiple score holders. For the target, this always makes sense, since the operation is applied separately to each target. For the source, this does not make sense for =, since a score cannot be assigned multiple values.
How to reproduce
Set up a scoreboard objective and some entities with different scores:
/scoreboard objectives add test dummy /scoreboard objectives setdisplay below_name test /scoreboard objectives setdisplay sidebar test /summon mannequin ~3 ~ ~ {CustomNameVisible:1b,NoAI:1b} /scoreboard players set @n[type=mannequin] test 3 /summon mannequin ~2 ~ ~ {CustomNameVisible:1b,NoAI:1b} /scoreboard players set @n[type=mannequin] test 2 /summon mannequin ~1 ~ ~ {CustomNameVisible:1b,NoAI:1b} /scoreboard players set @n[type=mannequin] test 1Run
/scoreboard players operation @s test = @e[type=mannequin,sort=nearest] test
Expected result
The final command should be a syntax error until you add limit=1.
Observed result
Your score gets set to 3, that of the furthest mannequin.
Notes
Operations are basically a fold over the source scores, seeded with the target score. Since some operations are non-associative (-=, /=, %=), a left-fold is performed. This produces the same result regardless of the order of the source scores, provided that the operation is “medial” (satisfies (A•B)•C = (A•C)•B). All scoreboard operations are medial except for =! That operation (snd) always takes the second operand, so its result after folding depends on the order of the source scores. The only way for it to produce a reliable result is if there is only one source score.
The sort argument in a selector can be used to sort the sources in a preferred way, but every entity found except for the last one will be ignored. This kind of confusion was why amount-limited selectors were added to commands in the first place. Additionally, * is accepted here, and its order is completely undefined, so it’s impossible to say what the semantics of /scoreboard players operation @s test = * test are.
Comments 0
No comments.