/testforblock Command in Minecraft Bedrock Edition

Test for a Block at Specific Coordinates

Bedrock EditionLogic & ScoreboardPermission: Game DirectorsCheats: Yes

The /testforblock command in Minecraft Bedrock Edition checks whether a certain block is located at a specific position in your world. You can check for just the block type or include optional block states to be more precise.

Players and map makers often use this command inside command blocks to create custom puzzles, locks, and triggers. When the tested block matches the location, the command succeeds and can activate other mechanisms.

Syntax (1 form)

  1. /testforblock <position: x y z> <tileName: Block> [blockStates: block properties]

    Test for block, optional block state

Arguments

ArgumentTypeWhat it means
blockStatesblock propertiesThis optional argument defines the exact block properties that the block must have to pass the test.
position: x y zpositionThis required argument is the vector coordinate of the location where you want to test for the block.
tileNameBlockThis required argument specifies the block name from the game's block list that you are looking for.

Examples

Tips

Common mistakes

Bedrock vs Java

Minecraft Java Edition does not have a command named /testforblock, as this command is exclusive to Bedrock Edition.

FAQ

What does the /testforblock command do in Minecraft?

It checks a specific x, y, and z coordinate in the world to see if the block located there matches the block name and optional block states you typed into the command.

Do I need cheats enabled to use /testforblock?

Yes, cheats must be turned on in your world, and you need the Game Directors permission level to run this command.

Are block states required when using /testforblock?

No, the block states argument is optional, so you only need to include the coordinates and the block name for a basic check.

Related commands

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