Commands/testforblocks

From Minecraft Wiki
Jump to: navigation, search
testforblocks
Restrictions

Operator

First introduced

1.8 (14w07a)
PE Alpha 0.16.0 (PE Alpha 0.16.0 build 1)

Removed

1.13

Tests whether the blocks in two regions match.

Syntax
  • Java Edition
testforblocks <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [mode]
  • Pocket Edition
testforblocks <begin: x y z> <end: x y z> <destination: x y z> [mode: string]
Color added to make reading easier.
Arguments
x1 y1 z1 and x2 y2 z2 (PE: <begin: x y z> and <end: x y z>)
Specifies two opposing corners of the region to use as the pattern to test for (the "source region"). x1, z1, x2, and z2 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 (PE: destination: 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 (PE: mode: string) (optional)
Specifies how to match blocks. Must be one of:
  • all — every block in the source and destination regions must match exactly.
  • maskedair blocks in the source region will match any block in the destination region.
If not specified, defaults to all.
Result
Fails if the arguments are not specified correctly, or if the source and destination regions do not match.
On success, returns the number of matching blocks (the total number of blocks in all mode, or the number of source region non-air blocks in masked mode).