In Minecraft and in the answers I see stuff like this:

/testfor @a[x=X,y=Y,z=-Z,r=R]

Then the people say to hook it up to a /setblock command or a /fill command or etc.

What do people mean when they say "hook up to"? How do you hook up a /testfor command block to another /setblock command? I understand the whole /testfor thing except the part on how to hook it up to another command block.


2 Answers 2


To use a /testfor command block, simply hook it up to your circuit with a redstone comparator.

Arrangement of Command Block and Comparator

When the testfor condition is met, the comparator will output a signal (out of the end facing away from the block). Simply place another command block or a redstone circuit there and it will do what you want when you want.


You can set Command-Blocks in your world and put a command in it. The command get executed every time a redstone starts powering the block.

In case of the testfor-command the block itself will emit a redstone signal which you are able to catch with a Comparator.
If the state you test for is true the Comparator will return a signal. It will not return a signal (or disable the current active signal) if the statement is false.

In your case: When you power a commandblock and a Player is nearby thoose cooridantes you will get a signal from the Comparator you can hook up to other contraptions such as a door or another commandblock. You could use this to open/close a hidden door only when you or one of your friends is nearby. You would have a door thats closed to everyone the command doesnt look for. Or when a player goes into your store you could whisper to them what you're currently selling.

I can recommend working with redstones to anyone. Working with redstone is much fun and if you ever need help again feel free to just ask the community :)

  • Please don't link elsewhere for answers. Summarize the relevant information here, so that if ever the page goes down, your answer is still valid. Besides, it saves people a click!
    – Frank
    Commented Apr 10, 2015 at 14:20
  • Thank you for pointing this out :) I did edited my post. I hope it's better now
    – BlueWizard
    Commented Apr 10, 2015 at 14:30
  • Very much appreciated.
    – Frank
    Commented Apr 10, 2015 at 14:31
  • Please tell me what I could improve further. I'm a beginner and this really helps me^^
    – BlueWizard
    Commented Apr 10, 2015 at 14:31
  • The biggest thing is to make sure all the relevant information to answer the question is here. You can link elsewhere for supplemental information, or use pictures, but your answer should be able to stand on it's own without them. So long as you do that, and you properly attribute where you got the information from, you'll do fine here!
    – Frank
    Commented Apr 10, 2015 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .