Hey there guys, I need some help on using command blocks to test if any players have a certain item in their armor slot.
This is going to be used in a multiplayer server of mine (4 people max) so I need it to be multiplayer compatable.
Rollback Post to RevisionRollBack
eDark Pony ftw? Click the little plus sign over there ---> if I helped you or made you laugh?
Hey there guys, I need some help on using command blocks to test if any players have a certain item in their armor slot.
This is going to be used in a multiplayer server of mine (4 people max) so I need it to be multiplayer compatable.
If players can have other items in their inventory, you will not be able to do this. In order to /testfor player inventories, you have to label every single item in the inventory, where the item is, how much of that item, the damage value, and every single tag associated with that item.
So if you want to detect worn armor, you will also have to detect all of the above, which is simply not feasible. If still interested, I have a pastebin that goes into some detail about detecting worn armor: http://pastebin.com/BuRm7jqZ
Otherwise, you can try out the updated /clear command, which does not allow you to check for slots. However, you will have an issue with the Damage value, as it will increase when the player takes damage and durability on the armor decreases:
A maximum amount of 0 will prevent the player from having the item removed, but will still produce a signal.
Note that in neither case will you be able to specifically target this player for future commands. Meaning that it's not multiplayer-friendly, which is unfortunately the running theme so far for the 1.8 snapshots. Hopefully this is changed, although the existence of 'dataTags' in the /testfor command hints that this won't.
Currently, checking the player's inventory need you to know the entire items in the inventory.
For example if you want to check if the player is wearing a diamond helmet. You can do that, but you also need to define what the other slot of armor will be. If you leave it blank, it'll be considered empty.
In this case, a player wearing only diamond helmet will be detected. But a player with a diamond helmet and armor, will not be detected.
You can have countless commandblocks in total to check for each one of the combination.
If players can have other items in their inventory, you will not be able to do this. In order to /testfor player inventories, you have to label every single item in the inventory, where the item is, how much of that item, the damage value, and every single tag associated with that item.
So if you want to detect worn armor, you will also have to detect all of the above, which is simply not feasible. If still interested, I have a pastebin that goes into some detail about detecting worn armor: http://pastebin.com/BuRm7jqZ
Otherwise, you can try out the updated /clear command, which does not allow you to check for slots. However, you will have an issue with the Damage value, as it will increase when the player takes damage and durability on the armor decreases:
A maximum amount of 0 will prevent the player from having the item removed, but will still produce a signal.
Note that in neither case will you be able to specifically target this player for future commands. Meaning that it's not multiplayer-friendly, which is unfortunately the running theme so far for the 1.8 snapshots. Hopefully this is changed, although the existence of 'dataTags' in the /testfor command hints that this won't.
After seeing how often you Ninja help people, myself included, with accurate and easy to understand info, I am very impressed
It says the objective is read only and this is the command I used to add the scoreboard:armor
/scoreboard objectives add armor health
Is there something else I should add to the command? Because I have an OP leather Armor set and I want to have it give you speed and resistance when you have it on. Thanks!
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
It says the objective is read only and this is the command I used to add the scoreboard:armor
/scoreboard objectives add armor health
Is there something else I should add to the command? Because I have an OP leather Armor set and I want to have it give you speed and resistance when you have it on. Thanks!
Btw i'm new here on the forums, sooooooo....
Your command is wrong. Your criteria type should be "dummy".
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
/effect @p 8 0
I Hope This helps!
Thanks! I prefer using your AND gate method. I'm making my map and I'm a still learning redstone machines and commands. I'll just change the tags and hope it works.
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
/effect @p 8 0
I Hope This helps!
Would it still work if the armor was edited to have special characters(§)/formatting codes?
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
/effect @p 8 0
I Hope This helps!
Lol yeah that works too, but when people are trying to make "Only One Command" creations, they cannot use any other material other than redstone blocks and command blocks, so hoppers, comparators, and all of those stuff don't work. Also your way isn't MULTIPLAYER compatible, so...
I am trying to make an only one command creation, but I am running into the same problems. When I remove the item, nothing changes the scoreboard value back to 0. Sorry if I am necroposting/bumping this thread but I don't know how to fix this. One idea was to use the exclamation mark to make it target everything but a certain item, except I don't know where to put it.
scoreboard players set @a armor 2 {Inventory:[{Slot:102b,id:"minecraft:diamond_chestplate",tag:{display:{Name:"Resistance Chestplate"}}}]}
scoreboard players remove @a armor 1
effect @a[score_armor_min=1] 5 1 1
Note the second command set the score of armor to 2. Every tick (if on a 20 tick per second clock) its getting decreased to 1 and set back to 2 but never reaching.
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
This is going to be used in a multiplayer server of mine (4 people max) so I need it to be multiplayer compatable.
eDark Pony ftw? Click the little plus sign over there ---> if I helped you or made you laugh?

-
View User Profile
-
View Posts
-
Send Message
Retired StaffIf players can have other items in their inventory, you will not be able to do this. In order to /testfor player inventories, you have to label every single item in the inventory, where the item is, how much of that item, the damage value, and every single tag associated with that item.
So if you want to detect worn armor, you will also have to detect all of the above, which is simply not feasible. If still interested, I have a pastebin that goes into some detail about detecting worn armor: http://pastebin.com/BuRm7jqZ
Otherwise, you can try out the updated /clear command, which does not allow you to check for slots. However, you will have an issue with the Damage value, as it will increase when the player takes damage and durability on the armor decreases:
/clear <player> <item ID> [Damage] [Maximum Amount] {dataTags}A maximum amount of 0 will prevent the player from having the item removed, but will still produce a signal.
Note that in neither case will you be able to specifically target this player for future commands. Meaning that it's not multiplayer-friendly, which is unfortunately the running theme so far for the 1.8 snapshots. Hopefully this is changed, although the existence of 'dataTags' in the /testfor command hints that this won't.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
For example if you want to check if the player is wearing a diamond helmet. You can do that, but you also need to define what the other slot of armor will be. If you leave it blank, it'll be considered empty.
In this case, a player wearing only diamond helmet will be detected. But a player with a diamond helmet and armor, will not be detected.
You can have countless commandblocks in total to check for each one of the combination.
Other than that, it's not possible.
After seeing how often you Ninja help people, myself included, with accurate and easy to understand info, I am very impressed
{Inventory:[{Slot:#b,tag:{display:{Name:""}}}]}Name can be anything to add more of a specifier (armor must be renamed the same thing to work)
Helmet: 103
Chestplate: 102
Leggings: 101
Boots: 100
You can create a score of lets say, "armor" and if they have a helmet named "cat" on, their armor score becomes 1:
/scoreboard players set @a armor 1 {Inventory:[{Slot:103b,tag:{display:{Name:"cat"}}}]}then you could test for any player that has a armor score of 1:
This is the way I do it, and it works quickly and flawlessly.
www.youtube.com/user/dinodude162
/scoreboard objectives add armor health
Is there something else I should add to the command? Because I have an OP leather Armor set and I want to have it give you speed and resistance when you have it on. Thanks!
Btw i'm new here on the forums, sooooooo....
I built an AND gate That tests for each armor slot. The Photo is below.
Here are the commands:
/testfor @p {Inventory:[{Slot:103b,id:"minecraft:diamond_helmet",tag:{display:{Name:"Death Armor (Helmet)"}}}]}
/testfor @p {Inventory:[{Slot:101b,id:"minecraft:diamond_leggings",tag:{display:{Name:"Death Armor (Leggings)"}}}]}
/testfor @p {Inventory:[{Slot:102b,id:"minecraft:diamond_chestplate",tag:{display:{Name:"Death Armor (Chestplate)"}}}]}
/testfor @p {Inventory:[{Slot:100b,id:"minecraft:diamond_boots",tag:{display:{Name:"Death Armor (Boots)"}}}]}
(PSST. You can change the name of the Armor to testfor at the "{Name:" and the armor material at "Minecraft:_______ Armor)
Then There's a redstone inverter which gives you the effects.
And if you take the armor off, My advice is Don't do this:
/effect @p clear
Hook up different command blocks taking one effect, like for example, I Had Jump boost as one of my effects so one of the effect removal commands is this:
/effect @p 8 0
I Hope This helps!
Your command is wrong. Your criteria type should be "dummy".
Thanks! I prefer using your AND gate method. I'm making my map and I'm a still learning redstone machines and commands. I'll just change the tags and hope it works.
Some CloudClient dude. Also some CloudPack dude.
Would it still work if the armor was edited to have special characters(§)/formatting codes?
If you can get the § in command blocks.
for example...?
Lol yeah that works too, but when people are trying to make "Only One Command" creations, they cannot use any other material other than redstone blocks and command blocks, so hoppers, comparators, and all of those stuff don't work. Also your way isn't MULTIPLAYER compatible, so...
No!
I am trying to make an only one command creation, but I am running into the same problems. When I remove the item, nothing changes the scoreboard value back to 0. Sorry if I am necroposting/bumping this thread but I don't know how to fix this. One idea was to use the exclamation mark to make it target everything but a certain item, except I don't know where to put it.
SUPPORT IF STATEMENTS IN MINECRAFT!!
Thank you so much
All the commands:
scoreboard objectives add armor dummy
scoreboard players set @a armor 2 {Inventory:[{Slot:102b,id:"minecraft:diamond_chestplate",tag:{display:{Name:"Resistance Chestplate"}}}]}
scoreboard players remove @a armor 1
effect @a[score_armor_min=1] 5 1 1
Note the second command set the score of armor to 2. Every tick (if on a 20 tick per second clock) its getting decreased to 1 and set back to 2 but never reaching.
Can I do the same thing with mobs/other entities, like ArmorStands?
Because I tried and it didn't work
I do command blocks for the most part .-.
I LOVE U M8