mojira.dev
MC-136904

"execute store score" does not store 0 when subcommand is "advancement" and fails

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

To select players with advancements, use:

@a[advancements={my_advancement=true}]

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

Confirmed for 23w04a.

Fixed in 23w45a. Unhandled {{CommandRuntimeException}}s are now gone.

Ryan Cheatham

(Unassigned)

Confirmed

Commands

/advancement, /execute-store

Minecraft 1.13.1, 1.15.2, 20w06a, 20w20b, 1.19, 23w04a, 1.20.2, 23w43b

23w45a

Retrieved