Can command blocks look for a block in an area
Can a command block look for a block in an area and not a specific pattern of this block but weither its there or not? I whould assume that you could use /testforblocks for this but I couldent figure it out.
Best Answer
You can use the /fill command to detect whether a certain block is present.
Assuming you can create a redstone clock to suit your needs, attach a command block to it that has the command /fill <x1> <y1> <z1> <x2> <y2> <z2> sponge 0 replace <block>. (Fill in the coordinates with the coordinates you need, and fill in with the type of block you're testing for.) You can take a comparator output from that command block to know whether the block was present. You also need to put a command block that's activated IMMEDIATELY after that that has the command /fill <x1> <y1> <z1> <x2> <y2> <z2> <block> 0 replace sponge. This will reset the sponges that were created by the previous command block to be .
Notice I used sponge as the temporary block. If there are other sponges in the area that you're testing, you will want to pick a different block to use as a temporary block (one that's not in the selected area).
I hope this helped.
Pictures about "Can command blocks look for a block in an area"



How do you find a block with a command block?
The reason I want this in the game is that, say, you have a lost structure in your world with a particular type of block that is not naturrally generated, you could use the command: /locateblock ____. The blank is for the particular block you are looking for.How To Use /Tickingarea - Make Command Blocks Work Anywhere!
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Meruyert Gonullu, Olga Lioncat, Ruslan Alekso, Andreea Ch
