I am Working on Something some of you may like some of you may not like, But i need to testfor if a player is wearing a chestplate called "BackPack", Could anyone help?
Rollback Post to RevisionRollBack
Creator of "Spawncube" Click here to go to forum thread! - THEGamingninja
If an inventory slot doesn't contain an item, there will simply be no record to detect at all. As such, you'd have to give the player a label as if they didn't have the item, and then change their score if they actually did via positive NBT detection.
For example, the following would have to be run in the presented order:
1. Remove the "WearingChest" tag from the player by default. This indicates they do not have the item, even if they do at this point.
/scoreboard players tag @a[tag=WearingChest] remove WearingChest
2. Add the "WearingChest" tag to the player if they actually do have that chest. If the player is not wearing a chest, they will simply remain without the "WearingChest" tag as was removed from the previous command. You can change the NBT data as needed.
/scoreboard players tag @a[tag=!WearingChest] add WearingChest {Inventory:[{id:"minecraft:diamond_chestplate",Slot:103b}]}
After that point, players that have a "WearingChest" tag would be those wearing the chest. You can then target those particular players with the 'tag' target selector parameter:
I am Working on Something some of you may like some of you may not like, But i need to testfor if a player is wearing a chestplate called "BackPack", Could anyone help?
Creator of "Spawncube" Click here to go to forum thread! - THEGamingninja
My Youtube Channel: https://www.youtube.com/c/THEGamingninjaGamingPC Remember to Subscribe!
If an inventory slot doesn't contain an item, there will simply be no record to detect at all. As such, you'd have to give the player a label as if they didn't have the item, and then change their score if they actually did via positive NBT detection.
For example, the following would have to be run in the presented order:
1. Remove the "WearingChest" tag from the player by default. This indicates they do not have the item, even if they do at this point.
2. Add the "WearingChest" tag to the player if they actually do have that chest. If the player is not wearing a chest, they will simply remain without the "WearingChest" tag as was removed from the previous command. You can change the NBT data as needed.
After that point, players that have a "WearingChest" tag would be those wearing the chest. You can then target those particular players with the 'tag' target selector parameter:
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/