How we use the /testfor command to detect if there's a block missing (or a new block) in an area with only one command block and comparator?
2 Answers
If you want to detect blocks, then /testforblocks is what you're looking for. /testfor is used to find entities, such as players, mobs or items. /testforblocks is used as follows:
testforblocks <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [mode]
from Minecraft Wiki:
Arguments:
x1 y1 z1
andx2 y2 z2
:Specifies two opposing corners of the region to use as the pattern to test for (the "source region"). x1,
z1, x2,
andz2
must all be between -30,000,000 and 30,000,000 (inclusive, without the commas), and y1 and y2 must be between 0 and 255 (inclusive). May use tilde notation to specify coordinates relative to the command's position. The number of blocks in the source region must not exceed 524,288.
x y z
Specifies the lower northwestern corner (the corner with the most-negative values) of the region to be checked (the "destination region"). x and z must both be between -30,000,000 and 30,000,000 (inclusive, without the commas), and y must be between 0 and 255 (inclusive). May use tilde notation to specify coordinates relative to the command's position. Source and destination regions may overlap.
mode
(optional)Specifies how to match blocks. Must be one of:
all
— every block in the source and destination regions must match exactly.masked
— air blocks in the source region will match any block in the destination region. If not specified, defaults to all.
To use testforblocks, you will need an area on your map to compare against - this will need to be in a loaded chunk, so I would put it underground and out of sight somewhere.
-
I think that we can also put it in the "mother chunk", or if I said wrong it is the chunk where the player spawn. This chunk will always be active, even if the player is far away from it. By doing this, we can make sure that the command will always be run.– KimatuyApr 1, 2016 at 12:33
-
Sorry about this little detail, but I just tried the command. I don't understand what's the x y z are for because there is already the x1 y2 z3 x2 y2 z2. Thank you for reply.– KimatuyApr 6, 2016 at 0:12
-
You can answer this question here: gaming.stackexchange.com/questions/261627/…– KimatuyApr 6, 2016 at 18:13
Testfor is a command used to detect entities, which can be a player, a mob, item frame, item, etc. If using testfor you can hook another command block up to it, or use the execute command, which however, does not support data tags.
testfor
! It's already one if the most useless commands (especially for novice command blockers), and more to the point, it was never designed to do what you're asking.testfor
in that instance. It's often hard to tell iftestfor
really is the best option, so you might as well stick to the other options.