/testforblocks Command in Minecraft Bedrock Edition

Test If Two Block Regions Match

Bedrock EditionLogic & ScoreboardPermission: Game DirectorsCheats: Yes

The /testforblocks command checks whether the blocks in one rectangular area match the blocks in another area. You define a source region using two opposite corners and then pick a destination point to compare it against.

Map makers and builders often use this command with command blocks to create block-based puzzles, secret doors, or structure checks. You can choose to compare every single block including air, or ignore air blocks in your source region so only solid shapes are tested.

Syntax (1 form)

  1. /testforblocks <begin: x y z> <end: x y z> <destination: x y z> [mode: TestForBlocksMode]

    Test for blocks

Arguments

ArgumentTypeWhat it means
begin: x y zpositionThe X, Y, and Z coordinates of the first corner of the rectangular source region you want to compare.
destination: x y zpositionThe X, Y, and Z coordinates of the lower northwest corner of the target area you are testing against.
end: x y zpositionThe X, Y, and Z coordinates of the opposite corner of the rectangular source region.
modeTestForBlocksModeAn optional setting that can be set to 'all' to match every block including air (the default), or 'masked' so air blocks in the source region match any block in the destination.

Examples

Tips

Common mistakes

Bedrock vs Java

Minecraft Java Edition does not have the /testforblocks command, as this command is exclusive to Bedrock Edition.

FAQ

What is the difference between 'all' and 'masked' mode in /testforblocks?

The all mode checks that every single block matches, including air blocks, while the masked mode allows air blocks in your first region to match any block at all in the destination region.

Which corner should I use for the destination coordinates?

You must always use the lower northwest corner of the target area, which is the corner with the smallest X, Y, and Z coordinate numbers.

Who has permission to use the /testforblocks command?

You need the Game Directors permission level and cheats must be enabled in the world to run this command.

Related commands

/dialogue/execute/function/packstack/reload/reloadpacketlimitconfig/schedule/scoreboard/scriptevent/sendshowstoreoffer/tag/testfor/testforblock/toggledownfall