Arqade Asked by DreamingInsanity on February 2, 2021
I have a an area with lots of armour stands. Under each one is a dispenser with 1 – 54 items in the first slot, which is its sort of ‘id’.
I need to temporarily save the number of items in each of those dispensers to a scoreboard which I am doing like so:
execute as @e[tag=char] at @e[tag=char] store result score @s temp run data get block ~ ~-1 ~ Items[0].Count
however, no matter the number of items inside or anything, it will always store a 0.
I run one similar command before which is:
execute as @e[tag=getblock] at @e[tag=getblock] unless block ~ ~-1 ~ minecraft:air store result score blockCount load run data get block ~ ~-1 ~ Items[0].Count
and this runs perfectly. There is only one amour stand with that tag but that shouldn’t matter because I am running the other command using @s
which will just use the UUID of the entity.
What could be the reason for this?
If there is more than one armour stand, your at
argument should be @s
instead of @e[tag=char]
.
It's a complicated explanation why.
Place down two armour stands in your test world, name them One
and Two
respectively, and tag them test
. Let's run a few commands on them (paste them into your chat):
/execute as @e[tag=test] run say Hello, World!
Result:
[Armour Stand] Hello, World!
[Armour Stand] Hello, World!
Now let's try using at
instead of as
:
/execute at @e[tag=test] run say Hello, World!
Result:
[ExpertCoder14] Hello, World!
[ExpertCoder14] Hello, World!
It looks like the command is executed twice, by your player, once at each position.à
Now let's combine them. Try the following:
/execute as @e[tag=test] at @e[tag=test] run say Hello, World!
... and you get 4 messages, 2 from each armour stand.
What is happening with your old command is that each armour stand is executing the /data get
with each armour stand, not with itself. So armour stand 1 will execute /data get
with all the other armour stands, not just itself.
Fixed command:
execute as @e[tag=char] at @s store result score @s temp run data get block ~ ~-1 ~ Items[0].Count
Answered by ExpertCoder14 on February 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP