3

how do I testfor blocks? like if I put down stone near a command block with a comparator attached to it and it will activate a piston connected by the comparator on the command block? please answer.

4

The command you want is /testforblock. The syntax of it is:

testforblock <x> <y> <z> <TileName> [dataValue] [dataTag]

So to test for a stone block at X=10, Y=64, Z=10, the command would be:

testforblock 10 64 10 stone
  • Could you also test for a block relative for the command block, say, like this: /testforblock ~ ~-1 ~ stone – DatEpicCoderGuyWhoPrograms Jun 1 '14 at 3:09
  • @DatEpicCoderGuyWhoPrograms Yep. – SirBenet Jun 1 '14 at 11:03
  • Note that /testforblock is an upcoming feature and not yet in the latest stable version (1.7.9). – L3viathan Jun 3 '14 at 14:38

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.