Testing for items in player inventory in Minecraft 1.8
Why Arqade Stack Exchange recommends it
Gaming Stack Exchange (Arqade) answerers link it when users ask how to check a player's inventory, held item or named gear with command blocks.
Recommended by 3 people across 4 different months, 2015 to 2017.
What it is
A short Minecraft command-block tutorial by Dragnoz on using /testfor to detect items in a player's inventory, in a specific slot, in the active hotbar slot, or with a custom name. The description lists the exact commands for each case, written for the 1.8 data-tag syntax.
What people said
Recommends Dorian Dore · 2015-03 · Arqade Stack Exchange · on “Minecraft Inventory Saving”
This video here might be able to help you [this video] . The only way I can think of is to have 36 command blocks to test for what item is in your inventory, and have the command blocks run simultaneously once the save command is executed. Then, when the player dies, it gives back all items that the 36 command blocks checked for.
Recommends Jason_ · 2016-02 · Arqade Stack Exchange · on “How do I apply potion effects to a player wearing armor with a special name with command blocks”
What you could do is /testfor a player with a helmet with a custom name scuba . Test for the slot number they have it in, (helmets are 103) This command should do all that: /testfor @p[r=2] {Inventory:[{Slot:103b,tag:{display:{Name:"scuba"}}}]} Hook it up to a clock of your choice and if the /testfor command reads true then have a comparator ready to activate a sticky piston that pushes a redstone block to activate the command /effect @p minecraft:water_breathing When they leave your set radius or remove there helmet the sticky piston will deactivate pulling the redstone block activating the command /effect @p clear [LINK] This is a list of the inventory slot numbers. [LINK] The Youtuber Dra
Recommends Jason_ · 2016-03 · Arqade Stack Exchange · on “How do i testfor a item a player is holding?”
If it has a custom name you may not need to test for the diamond sword just the custom name: You could use a command like this: /testfor @p[r=1000] {SelectedItemSlot:0,Inventory:[{Slot:0b,tag:{display:{Name:"Notch's Legendary Sword"}}}]} This will testfor the the player holding the custom named item in slot 0. You may choose to have the radius if you would like. If you wish to know more watch this video on testfor: By Dragnoz This is a picture of the numbered slots you can use for reference when testing for an item in that slot: [LINK]
Recommends Angelsofty · 2017-03 · Arqade Stack Exchange · on “How to testfor somebody that does not have a item in their inventory in minecraft?”
You would need to set up a /testfor command in a command block that searches for an item in a players inventory (see video) then put another command block that has this command kill@e[type=player] connected to it. This command will kill every player entity and because of the testfor command, it will only activate when someone has the item in their inventory. even though the video says 1.8 I tried it myself yesterday in 1.11.2 and it works just fine Disclaimer: This video is not owned by me, please visit Dragnoz's youtube channel to see more videos like this video tutorial here [this video]