mojira.dev
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

[media]

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")

Linked issues

Attachments

Comments 5

Still in 1.14.1 Release

Still in 1.14.2 Pre-Release 1 and 1.14.2 Pre-Release 2

It happens because the success of each command in the function is stored.

Fixed in 23w41a. When testing, note that func2 now requires a /return command due to MC-265782.

It seems that this is actually the same as MC-262027, that was was a lot more clear what's going on, and should be the parent report.

Simon816

(Unassigned)

Confirmed

Commands

/execute-store, command

Minecraft 18w06a, Minecraft 1.13-pre4, Minecraft 1.14, Minecraft 1.14.1, Minecraft 1.14.2 Pre-Release 1, ..., 21w05b, 21w06a, 21w07a, 21w11a, 1.17 Pre-release 2

Retrieved