mojira.dev
MC-69826

CommandStats entity selectors will only work as long as they don't return multiple entities

How to reproduce:

Spawn two villagers whose scores we want to affect (run this command twice):

/summon Villager ~ ~ ~ {CustomName:Max}

Set up the scoreboard and start tracking the two villagers:

/scoreboard objectives add testObj dummy
/scoreboard objectives setdisplay sidebar testObj
/scoreboard players set @e[name=Max] testObj 10

Spawn a villager which we will use to run commands from and give him appropriate CommandStats tags:

/summon Villager ~ ~ ~ {CustomName:Dave}
/stats entity @e[name=Dave] set AffectedItems @e[name=Max] testObj

Give yourself some stone which Dave can /clear later on:

/give @p stone 64

Let Dave clear your stone:

/execute @e[name=Dave] ~ ~ ~ /clear @p minecraft:stone

Notice how the scoreboard stats for the villagers named Max did not update. Kill one of the villagers named Max so there is only one entity named Max in your world, then give yourself some more stone and run the /execute command again. Notice how the scoreboard stat for the remaining villager Max did update this time.

Linked issues

Comments 4

Not sure if this helps, but under the stats command where it has @e[name=Max], try adding c= (number > 1). I have not used the stats command nor do I know what the actions under the command do, so I'm not sure if the command isn't set up properly or if the issue is WAI.

I will give this a try in a few days, but your comment made me realize the report was titled wrongly (AffectedItems instead of CommandStats) so thanks for that!

Tried, does not work. Thanks for the idea regardless!

Selectors only work if they resolve to a single entity. That's by design and won't be changed. The solution is almost always using /stats on entities.

[Mod] redstonehelper

michael

Unconfirmed

Minecraft 1.8-pre3, Minecraft 1.8

Retrieved