2

Is it possible to testfor players with a specific inventory slot (more specific the 100th/boots slot) if it is empty. I have tried

/testfor @a {Inventory:[{Slot:100b}]}, 

and

/testfor @a {Inventory:[100:{}]}

and

/testfor @a {Inventory:[{Slot:100b,id:"minecraft:air"}]}

but none of them work.

2

We're going to use the fact that you are checking for boots to our advantage, since boots are not stackable and there can normally only be 0 or 1 item in that slot.

Set up a dummy scoreboard objective called boots and run the following two Commands on a setblock/fill clock.

scoreboard players set @a boots 0
scoreboard players set @a boots 1 {Inventory:[{Slot:100b,Count:1b}]}

For example, you can use a setup like this one.

Full setup

This will set the boots score to 1 for everyone having exactly one item in their foot inventory slots. From there, you can use @a[score_boots=0] to detect barefoot players.

A general answer for every inventory slot is more difficult, because checking for Count:0b does not work, since for the game, "no item" is different from "0 items of any kind".

| improve this answer | |
  • This won't work, because when they have the boots, the score keeps changing, and it is do another command when the score is 0. – Jacques Marais Jun 28 '15 at 12:40
  • @CommandFox It works for me when I try /tellraw @p ["",{"score":{"name":"@p","objective":"boots"}}] It's imperative that you use a setblock/fill clock, so that the time delay between the commands is infinitely small (for Minecraft purposes). Also, make sure that the second command is executed second by placing it at a higher x,y or z coordinate. – MrLemon Jun 28 '15 at 12:48
  • @CommandFox no problem. Setblock/Fill clocks are generally thought to be the best possible option for command block contraptions since they produce almost no lag (few block updates, no lighting updates, etc.) and every command is run 20 times a second in a nicely determined order but with 0 time in between. – MrLemon Jun 28 '15 at 13:06
  • Yeah, fill clocks FTW! Resetting everyone's score, then setting specific people's score is quite common. – MBraedley Jun 28 '15 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.