The bug
It seems that if a condition in the execute
command fails, then the "success" value is not set to 0 when using execute store success
.
How to reproduce
/scoreboard objectives add was_successful dummy
/scoreboard objectives setdisplay sidebar was_successful
Switch to hotbar slot 1
/execute store success score @s was_successful if data entity @s {SelectedItemSlot:0} run say Moo
✔ The score was set to 1 as expected
Switch to a different hotbar slot and run the command in step 4 again
❌ The score is still 1 even though the condition failed
Linked issues
is duplicated by 3
Comments 7
This bug is also present while doing something like /execute store success score @s was_successful run data get entity [<path>]. If no such NBT tag is found, the success stores is 1, while it should be 0.
Affects 1.17.1.
A slightly quicker way to test it uses only these 3 commands:
/scoreboard objectives add was_successful dummy
/scoreboard objectives setdisplay sidebar was_successful
/execute store success score @s was_successful if data entity @s {SelectedItemSlot:0} run say Moo
Observe that the third command only updates your score if your SelectedItemSlot is 0.
Edit: I've updated the description to use this method since it's much more concise.
e.g. /execute store ... run A
Currently, the store subcommand stores the result of command A, rather than the /execute command itself. So, if command A is not executed, there is no success value and result value.
This is reasonable, but sometimes may be counter-intuitive. Though I don't recommend fixing this, it's up to Mojang.
To fix this, brigadier must be changed so that the feedback consumer is called when the /execute command is finished without executing command A.
Affects 18w32a.