Minecraft Wiki
Advertisement
Not to be confused with Commands/testforblocks.
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 a certain block is in a specific location.

Syntax[]

testforblock <position: x y z> <tileName: Block> [blockStates: block states]

Arguments[]

position: x y z : CommandPosition

Specifies the coordinates of the block to test.
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.

tileName: Block: enum

Specifies the block to test for.
Must be a block id.

blockStates: block states: BlockStateCommandParam

Specifies the block states to match when testfor.
Must be a blockstate argument as ["<state1>":<value1>,"<state2>":<value2>,...]. For example: ["old_leaf_type":"birch","persistent_bit":true].

Result[]

CommandTriggerBedrock Edition
anythe arguments are not specified correctly Unparseable
the specified position is unloaded or out of the world Failed
the block at the specified position does not match the specified block id or states
anyOtherwiseSuccessful

Output[]

CommandEditionSituationSuccess Count
anyBedrock EditionOn fail0
On success1

Examples[]

  • To test if the block at (0,64,0) is white wool:
    • testforblock 0 64 0 wool
    • testforblock 0 64 0 white_wool
  • To test if the block at (0,64,0) is stone:
    • testforblock 0 64 0 stone []
  • To test if the block below is a jukebox:
    • testforblock ~ ~-1 ~ jukebox

History[]

Java Edition
1.7.213w37aAdded /testforblock.
1.1116w32aAdded block state support to /testforblock.
1.1317w45aRemoved /testforblock in favour of /execute if.
Pocket Edition Alpha
v0.16.0build 1Added /testforblock.
Bedrock Edition
1.18.0beta 1.18.0.20Added block state support.
1.19.70beta 1.19.70.21Removed dataValue: int argument.
Advertisement