mojira.dev
MC-96056

Weird behavior with /execute scoreboard on a dead player

So while messing around with some things for a custom map, I tried to execute some operations with dead players and found a weird behavior, to help you visualize said behavior you'll need to do some things first, first you'll need two objectives:

/scoreboard objectives add BugTest dummy
/scoreboard objectives add Health health

Then set the sidebar display to BugTest:

/scoreboard objectives setdisplay sidebar BugTest

Now you'll need 3 armor stands called Test1, Test2 and Test3:

/summon ArmorStand ~ ~1 ~ {CustomName:"Test1",CustomNameVisible:1,NoGravity:1}
/summon ArmorStand ~ ~1 ~ {CustomName:"Test2",CustomNameVisible:1,NoGravity:1}
/summon ArmorStand ~ ~1 ~ {CustomName:"Test3",CustomNameVisible:1,NoGravity:1}

Now in a clock and some chain command blocks do these in this order and make them run:

/scoreboard players add @p BugTest 1
/execute @a[score_Health=0] ~ ~ ~ scoreboard players set @e[type=ArmorStand,name=Test1] BugTest 10
/execute @a[score_Health=0] ~ ~ ~ scoreboard players add @e[type=ArmorStand,name=Test2] BugTest 1
/execute @a[score_Health=0] ~ ~ ~ scoreboard players operation @e[type=ArmorStand,name=Test3] BugTest = @p BugTest

Now execute this command to initialize the armor stand's score:

/scoreboard players set @e[type=ArmorStand] BugTest 0

(The first image should help you understand the setup (The last command block on the right is just to reset the armor stands score to 0))

So now that the setup is done, you should be seeing the BugTest go up on your sidebar, and the armor stands at 0. The way the chained commands are intended to work is that the dead player (health=0) would execute in each tick a command that changed each armor stand's score in a certain way.
The first command is a scoreboard "SET", and while the player is dead he should be setting Test1's score to 10 each tick.
The second command is a scoreboard "ADD", and while the player is dead he should be incrementing Test2's score by 1 each tick.
The third command is a scoreboard "OPERATION", and while the player is dead he should be copying his score to Test3's score every tick.

Now in order to test it, you'll need to kill yourself, and when you do that you will see that while Test1 and Test2 are working as intended, Test3 is not (Second picture), but it is set as soon as I click respawn (when the score Health probably isn't 0 anymore) (Third picture)

I think the issue is because i'm making a dead player execute another command, but still, the other first two commands work, why would the third one not work?

Attachments

Comments 3

The fact that the third command don't get updated is intended when you know that @a or @a[c=x] target dead players, but @p or @a[r=x] don't.

In your case you should change the last command to :

/execute @a[score_Health=0] ~ ~ ~ scoreboard players operation @e[type=ArmorStand,name=Test3] BugTest = @a[c=1] BugTest

The only weird thing is that the following command put on a clock should never increment the player score since @p should never target a dead player, and score_Health=0 should never target a non dead player. But his score is incremented when the respawn button is hit :

/scoreboard players add @p[score_Health=0] BugTest 1

I would arg it's WAI because of the end of the tick order of operation. Even if this order is changed, it may create some other inconsistencies when the player died.

Via Searge on MC-46223:

The @a selector (but only without a radius/area defined via r/rx/ry/rz) will include dead players in the next snapshot. All other selectors work as intended.

Only @a will work for dead players.

Oh, ok, i didn't thought the second selector in the operation could be the problem. In that case, @a[c=1] will yield the expected result while doing the same thing as a @p right?

(And sorry for reporting an already resolved issue :x)

CroshB

(Unassigned)

Unconfirmed

Minecraft 16w03a

Retrieved