Mojira Archive
MC-125145

Cannot change scoreboard value within "execute store"

Note: This seems related to MC-123628, but not quite the same.

The bug

When running a function within an execute that stores the success value to a scoreboard objective, said objective cannot be changed.

Setup

scoreboard objectives add my_objective dummy

How to reproduce

Use the attached datapack MC-125145 datapack.zip or create the following functions within the namespace bug_test:

func1.mcfunction

scoreboard players set @s my_objective 0
tellraw @a {"text": "value before calling func2: ", "extra": [{"score":{"name":"@s","objective":"my_objective"}}]}
execute store success score @s my_objective run function bug_test:func2
tellraw @a {"text": "value after calling func2: ", "extra": [{"score":{"name":"@s","objective":"my_objective"}}]}

func2.mcfunction

tellraw @a {"text": "value once inside func2: ", "extra": [{"score":{"name":"@s","objective":"my_objective"}}]}
scoreboard players set @s my_objective 10
tellraw @a {"text": "value reset to 10: ", "extra": [{"score":{"name":"@s","objective":"my_objective"}}]}

Run bug_test:func1 as a player

Expected output

value before calling func2: 0
value once inside func2: 0
value reset to 10: 10
value after calling func2: 1

(I think it's also valid for "value once inside func2" to be 1, depends if the "success" value should get set immediately, or after. As long as "value after calling func2" represents whether it called the function or not)

Actual output

value before calling func2: 0
value once inside func2: 1
value reset to 10: 1
value after calling func2: 1
Executed 8 commands from function 'bug_test:func1'

If you remove store success score @s my_objective such that the execute command is

execute run function bug_test:func2

Then the variable is set accordingly. (i.e. "value reset to 10: 10")