-
Bug
-
Resolution: Fixed
-
1.14.4, 19w42a, 19w44a, 1.15 Pre-release 5, 1.15.2, 20w06a, 20w07a, 20w08a, 20w09a, 20w10a, 20w11a, 20w12a, 20w14a, 20w16a, 20w17a, 20w18a, 20w20b, 1.16 Pre-release 5, 1.16.1, 1.16.2 Pre-release 1, 1.16.2, 1.16.3, 1.16.4 Pre-release 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w10a, 21w11a, 21w13a, 21w15a, 21w16a, 21w19a, 1.17 Pre-release 1, 1.17, 1.17.1, 21w37a, 1.18.1, 1.18.2, 22w11a, 22w12a, 1.19.1, 1.19.2, 1.19.3 Release Candidate 1, 1.19.4, 23w18a, 1.20.1, 23w31a, 1.20.2, 23w42a
-
Confirmed
-
Commands
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 score value in the objective readonly 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); }