Minecraft – How to testfor blocks not people

minecraft-commandsminecraft-java-edition

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.

Best Answer

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