So I've been working on revamping an old map I enjoyed but got stuck at referencing players with certain items in their inventories. Specifically, I am trying to apply the "glowing" potion effect to players with a golden helmet in their inventory / or equipped for that matter.
I've tried
/effect @a {Inventory:[{id:"minecraft:golden_helmet"}] glowing, which stops me with "{Inventory:[{id:"minecraft:golden_helmet"}]" is not a number"
/effect @a{Inventory:[{id:"minecraft:golden_helmet"}] glowing, which can't find any entities with those specifications.
and
/execute @a {Inventory:[{id:"minecraft:golden_helmet"}]} ~ ~ ~ effect @p glowing, which also stops me with "{Inventory:[{id:"minecraft:golden_helmet"}]" is not a number"
/testfor, with the same specifications finds the player fine, just not when I try to run a command on that group of players. Any help would be greatly appreciated. Thank you!
The Meaning of Life, the Universe, and Everything.
Join Date:
5/24/2015
Posts:
319
Minecraft:
WhiteAutumn
Member Details
I see what you were trying to do and as much as I wish that worked, that's not how selectors work.
Selectors are much more limited than data tags and can only check for a few things:
So, you can not check for what a player has in their inventory using selectors. We can check what players have in their inventory by using a command that has a data tag in its syntax, an example would be the /testfor command which syntax looks like this:
/testfor <player> [dataTag] That's why you were able to check the players inventory using the testfor command.
We can not use /testfor to solve your problem but we can use /scoreboard tags, which syntax looks like this:
/scoreboard players tag <player> <add:remove:list> <tagName> [dataTag]
So I've been working on revamping an old map I enjoyed but got stuck at referencing players with certain items in their inventories. Specifically, I am trying to apply the "glowing" potion effect to players with a golden helmet in their inventory / or equipped for that matter.
I've tried
/effect @a {Inventory:[{id:"minecraft:golden_helmet"}] glowing, which stops me with "{Inventory:[{id:"minecraft:golden_helmet"}]" is not a number"
/effect @a{Inventory:[{id:"minecraft:golden_helmet"}] glowing, which can't find any entities with those specifications.
and
/execute @a {Inventory:[{id:"minecraft:golden_helmet"}]} ~ ~ ~ effect @p glowing, which also stops me with "{Inventory:[{id:"minecraft:golden_helmet"}]" is not a number"
/testfor, with the same specifications finds the player fine, just not when I try to run a command on that group of players. Any help would be greatly appreciated. Thank you!
www.youtube.com/ashtonfearbolt
Join the storm today
I see what you were trying to do and as much as I wish that worked, that's not how selectors work.
Selectors are much more limited than data tags and can only check for a few things:
So, you can not check for what a player has in their inventory using selectors. We can check what players have in their inventory by using a command that has a data tag in its syntax, an example would be the /testfor command which syntax looks like this:
/testfor <player> [dataTag]
That's why you were able to check the players inventory using the testfor command.
We can not use /testfor to solve your problem but we can use /scoreboard tags, which syntax looks like this:
/scoreboard players tag <player> <add:remove:list> <tagName> [dataTag]
I made a simple demo using scoreboard tags
https://streamable.com/92k48
Here's the world download:
https://cdn.discordapp.com/attachments/384031761929338892/384277119640797184/Potion_Effect_Demo.7z
Thank you so much, it worked perfectly!
www.youtube.com/ashtonfearbolt
Join the storm today