TransWikia.com

How can I test for a player wearing specific armor?

Arqade Asked by jajaja123345 on November 28, 2020

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?

2 Answers

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>

Answered by Fabian Röling on November 28, 2020

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]

Answered by IronAnvil on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP