The bug
/scoreboard players <targets> <targetObjective> >< <source> <sourceObjective>
can mutate source scores even though <sourceObjective>
is read-only.
How to reproduce
/scoreboard objectives add writable dummy
/scoreboard objectives add readonly air
/scoreboard players set value writable 42
/scoreboard players operation value writable >< value readonly
/scoreboard players get value readonly
❌
value has 42 [readonly]
, the scorevalue
in the objectivereadonly
is mutated.
Code analysis
net.minecraft.server.commands.ScoreboardCommand
performOperation( commandContext.getSource(), ScoreHolderArgument.getNamesWithDefaultWildcard(commandContext, "targets"), ObjectiveArgument.getWritableObjective(commandContext, "targetObjective"), OperationArgument.getOperation(commandContext, "operation"), ScoreHolderArgument.getNamesWithDefaultWildcard(commandContext, "source"), ObjectiveArgument.getObjective(commandContext, "sourceObjective") // accepts all objectives here (including read-only) );
net.minecraft.commands.arguments.OperationArgument
private static Operation getOperation(String string) throws CommandSyntaxException { return string.equals("><") ? (score1, score2) -> { int integer3 = score1.getScore(); score1.setScore(score2.getScore()); score2.setScore(integer3); // mutated here } : getSimpleOperation(string); }
Can't reproduce, I get the error message as expected. Even doing the tellraw at the same tick with a chain command block reveals, that the score was not mutated in the tick.