The bug
The command
execute store (result|success) score <target> <objective> run advancement (grant|revoke) <target> only <advancement>
does not update <objective> for the objective target when the advancement command fails.
This bug might be related to MC-123068.
Setup
Run these commands:
scoreboard objectives add test dummy
scoreboard players set @s test 100
advancement revoke @s only minecraft:recipes/decorations/chest
advancement grant @s only minecraft:recipes/decorations/torch
scoreboard objectives setdisplay sidebar test
Reproduction
Run the commands
execute store success score @s test run advancement revoke @s only minecraft:recipes/decorations/chest
execute store success score @s test run advancement grant @s only minecraft:recipes/decorations/torch
Your score for the test objective is expected to update to 0 after each command, because the commands fail, however your score remains 100 in both cases.
Note that you can use either "execute store success" or "execute store result" in the two commands above and the effect is the same: you would expect the score to be set to 0, but it remains unchanged.
Why care?
This is the only way I could figure how to detect whether a player has received an advancement. If there is a better way, someone please let me know. If there isn't, an updated command like
advancement query <selector> <advancement>
would be very useful.
Comments 5
Confirmed for 19w40a. The cause of this issue is that AdvancementCommands
throws CommandRuntimeException
on failure. CommandRuntimeException
will not be caught in CommandDispatcher#execute
because it is not a subclass of CommandSyntaxException
.
confirmed in 1.19.
and related to MC-253333
To select players with advancements, use: