1

I am trying to make a custom crafting table using a dropper. I use this command to detect a shovel that is placed in the dropper:

testforblock 193 58 -314 minecraft:dropper 0 {Items:[0:{id:minecraft:stone_shovel,Count:1b,Damage:0s,Slot:4b}]}

And it works, it detects the shovel in the middle as it is supposed to. So the shovel is in the middle right now, and the comparator activates. If I keep the shovel there, and put another item into a different slot, the redstone comparator still activates. I want it to only activate when there is 1 item in the table.

My idea is to detect air for the other 8 slots, but it is not working, is minecraft:air invalid? How do I make /testforblock detect air (blank slot) inside the container (dropper)?

  • First, if you're not using 1.9, you probably should be. The fact that you have a comparator suggests that you're using 1.8, unless it's just to provide an indicator. Second, it isn't air that's in those slots, they're just empty, nothing more. – MBraedley Dec 20 '15 at 1:10
  • I am not using a comparator to detect the contents of the dropper, I am using it as an output for the command block that detects the contents. – Exus Dec 20 '15 at 1:21
  • An empty block in minecraft is minecraft:air now are you going to help me or just correct my statements? – Exus Dec 20 '15 at 1:28
  • Whoa, take it easy, I'm just trying to give some helpful advice and correct a misconception. It's not hard to see why you had that misconception, but it's important for you to understand your misconception before you get a full answer. You still seem to be holding onto that misconception, and it seems you misunderstood the first part of my previous comment. You have to be patient, as you're not going to get an answer instantly (although you have a good one now). – MBraedley Dec 20 '15 at 18:12
  • Sorry about that, I was just looking for the answer for a long time. I signed up just to ask this question. – Exus Dec 21 '15 at 22:13
2

"air" is indeed not a valid inventory item. Slots without items will simply not exist whatsoever, so you cannot directly detect them through NBT.

What you'll need to do instead is use multiple /testforblock commands: one to detect the shovel and others to detect slots having any items in them. You'd only allow a signal to pass if the first succeeds while the others fail:

Must succeed:

/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{id:"minecraft:stone_shovel",Count:1b,Damage:0s,Slot:4b}]}

Must all fail:

/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:0b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:1b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:2b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:3b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:5b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:6b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:7b}]}
/testforblock 193 58 -314 minecraft:dropper -1 {Items:[{Slot:8b}]}

What you cannot do is combine all of the failure commands into one, because then it's looking for an item in every one of those slots rather than any one.

| improve this answer | |
  • Thanks for your help, I was worried my map wouldn't be safe. :) – Exus Dec 21 '15 at 22:17

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.