Minecraft Wiki
Advertisement
Not to be confused with Commands/testforblock.
Information icon
This feature is exclusive to Bedrock Edition and Minecraft Education. 
This page describes content that exists only in outdated versions of Java Edition. 
This feature used to be in the game, but has ever since been removed.It may or may not return in a future update.

Tests whether the blocks in two regions match. Shows 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).

Syntax[]

testforblocks <begin: x y z> <end: x y z> <destination: x y z> [masked|all]

Arguments[]

begin: x y z: CommandPosition and end: x y z: CommandPosition

Specifies two opposing corners of the region to use as the pattern to test for (the "source region").
Must be a three-dimensional coordinates composed of <x>, <y> and <z>, each of which must be a floating-point number or tilde and caret notation.
Block position is the coordinates of the point at the lower northwest corner of a block. Because of this, the lesser coordinates of each axis falls right on the region boundary, but the greater coordinates are one block from the boundary, and the block volume of the source region is (xgreater - xlesser + 1) × (ygreater - ylesser + 1) × (zgreater - zlesser + 1). For example, 0 0 0 0 0 0 has a 1-block volume, and 0 0 0 1 1 1 and 1 1 1 0 0 0 both identify the same region with an 8-block volume.

destination: x y z: CommandPosition

Specifies the lower northwestern corner (the corner with the most-negative values) of the region to be checked (the "destination region"). Source and destination regions may overlap.
In Java Edition, must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation. In Bedrock Edition, must be a three-dimensional coordinates composed of <x>, <y> and <z>, each of which must be a floating-point number or tilde and caret notation.

masked|all

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[]

CommandTriggerBedrock Edition
anythe arguments are not specified correctly Unparseable
one or both specified regions are unloaded or out of the world Failed
the block volume of the source region is greater than 524288(equivalent to 8 chunks)
the source and destination regions do not match
anyOtherwiseSuccessful

Output[]

CommandEditionSituationSuccess Count
anyBedrock EditionOn fail0
On success1

History[]

Java Edition
1.814w07aAdded /testforblocks.
1.1317w45aRemoved /testforblocks.
Pocket Edition Alpha
v0.16.0build 1Added /testforblocks.
Advertisement