3

How can I test for a player that is wearing an iron helmet named "test1" and an iron chestplate named "test2" in Minecraft Version 1.12?

1
  • 2
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
    – Frank
    Commented Jul 21, 2017 at 13:16

2 Answers 2

8

Although you can't set player data with commands, you can test for it, in your example it's like this:

/execute as @p[nbt={Inventory:[{Slot:103b,id:"minecraft:iron_helmet",tag:{display:{Name:"{\"text\":\"test1\"}"}}},{Slot:102b,id:"minecraft:iron_chestplate",tag:{display:{Name:"{\"text\":\"test2\"}"}}}]}] run <command>
3
  • 2
    Wouldn't the correct syntax be /execute as @p[nbt={...}], not /execute as @p{...}
    – pppery
    Commented Jul 10, 2019 at 0:18
  • 1
    @pppery That is correct. I'm suprised that four people upvoted a non-functioning command. It's fixed now. Commented Jul 10, 2019 at 1:51
  • 2
    The original answer functioned and attracted 3 upvotes. The error was introduced with the update to 1.13.
    – pppery
    Commented Jul 10, 2019 at 1:53
0

Here is a solution that adds a scoreboard tag to any player wearing both of those custom items. This tag can then be used to target only those players with other commands. Commands are for 1.12.2.


Use 2 command blocks in a chain.

The first command block is RepeatUnconditionalAlways Active with command:

scoreboard players tag @a remove Wearing

The second command block is ChainUnconditionalAlways Active with command:

scoreboard players tag @a add Wearing {Inventory:[{Slot:103b,id:"minecraft:iron_helmet",tag:{display:{Name:test1}}},{Slot:102b,id:"minecraft:iron_chestplate",tag:{display:{Name:test2}}}]}

Now you can use this tag to target the players who are currently wearing the named armor. The target selector would be:

@a[tag=Wearing]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .