-1

Being fairly new to command blocks in general, I am currently in need of a way to make a SINGLE command block check specified x,y,z coords. for "air", and, if AIR is detected at that coord. then send a redstone pulse to a different set of coordinates. This needs to be a SINGLE command block - no chaining!

This can REPEAT for as long as AIR is detected at that location (ie. as often as the command block is run (every tick?).

Can this be done in a single command block? Can it even be done at all?

For clarity, here is my objective: I have created a tree farm, where I ALREADY HAVE a way to "harvest" the fully-grown trees. I have also used a (fairly trivial) set of command blocks to allow a "vanilla" dispenser to "plant" saplings, instead of merely "dropping" them onto the ground. The saplings are planted DIRECTLY IN FRONT of each dispenser(s). Now what I require is a way to "trigger" each dispenser to re-plant a new sapling each time a resulting tree has been harvested. Once the fully-grown tree is cleared, the location is front of each dispenser will have NEITHER a sapling nor a "tree" (wood) block present there, thus, it is "empty", and I need a way to detect this situation, and "fire" a redstone pulse back at the pertinent dispenser!

BTW, I COULD simply re-trigger every dispenser at the SAME TIME using a redstone clock, and, if the spot in front was not "empty" for any specific dispenser, then a normal sapling "toss" would result, (ie. it would NOT get "planted" that time around); I could then absorb and return the sapling back to a "collector" inventory (eg. a chest), which would then re-distribute the un-planted saplings as required. I am simply wondering if a command block could be utilized in this particular way, is all!

Thanks for any help here!

  • Is a comparator output that is powered if the block is empty acceptable? – IronAnvil Jan 27 '18 at 5:00
  • Hey, you know what? Let me give that some thought! I may have just over-complicated this issue! I only want to "trigger" a dispenser if the block directly in FRONT of it is currently EMPTY...it does sound like a comparator just may do the trick! – ZTagre Jan 27 '18 at 6:41
  • Darn, that won't do! I have the various dispensers too close together to be able to "lay out" the required redstone dust and the comparator required! Each dispenser is separated by only a single empty block! So, invariably, one setup for a single dispenser would interfere with the other(s)! – ZTagre Jan 27 '18 at 6:48
  • test for air and invert the signal.. might be the easiest approach – dly Jan 27 '18 at 8:38
  • Why exactly does it need to be in one command block? – Fabian Röling Jan 27 '18 at 10:57
0
/execute @p ~ ~ ~ detect x1 y1 z1 air 0 /setblock x2 y2 z2 redstone_block

Where point "1" is the block you are testing for air, and "2" is the coordinates of the redstone block to be placed, or output.

Additionally, if you don't want the nearest player to be executed, you could place an armor stand on top of the command block and replace @p with @e[type=armor_stand,r=1]

  • 1.13 syntax: /execute if block X Y Z air run setblock X2 Y2 Z2 redstone_block – pppery Jul 12 at 23:32

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.