Commands/testforblock

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Bedrock Edition.
testforblock
Restrictions

Operator

First introduced

Java Edition 1.7.2 (13w37a)
PE Alpha 0.16.0 (PE Alpha 0.16.0 build 1)

Removed

Java Edition 17w45a

Tests whether a certain block is in a specific location.

Syntax[edit]

testforblock <position: x y z > <tileName: Block> [dataValue: int]

Arguments[edit]

position: x y z

Specifies the position of the block to test. x and z must 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 and caret notation to specify a position relative to the command's execution.

tileName: block

Specifies the block to test for. Must be a valid block id (for example, minecraft:stone).

dataValue: int

Specifies the block data to test for. Must be between -1 and 15 (inclusive). If not specified, or if -1, matches any block data value.

Result[edit]

Fails if the arguments are not specified correctly, or if the block at the specified position does not match the specified block id or data.

On success, returns a success count of 1.

Examples[edit]

  • To test if the block at (0,64,0) is any type of wool:
    • testforblock 0 64 0 wool
    • testforblock 0 64 0 wool -1
  • To test if the block at (0,64,0) is orange wool:
    • testforblock 0 64 0 wool 1
  • To test if the block below is a jukebox:
    • testforblock ~ ~-1 ~ jukebox -1

History[edit]

Java Edition
1.7.213w37aAdded /testforblock.
1.1116w32aAdded block state support to /testforblock.
1.1317w45aRemoved /testforblock.
Pocket Edition Alpha
0.16.0build 1Added /testforblock.