Not to be confused with Commands/testforblocks.
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[]
Command | Trigger | Bedrock Edition |
---|---|---|
any | the 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 | ||
any | Otherwise | Successful |
Output[]
Command | Edition | Situation | Success Count |
---|---|---|---|
any | Bedrock Edition | On fail | 0 |
On success | 1 |
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.2 | 13w37a | Added /testforblock . | |||
1.11 | 16w32a | Added block state support to /testforblock . | |||
1.13 | 17w45a | Removed /testforblock in favour of /execute if . | |||
Pocket Edition Alpha | |||||
v0.16.0 | build 1 | Added /testforblock . | |||
Bedrock Edition | |||||
1.18.0 | beta 1.18.0.20 | Added block state support. | |||
1.19.70 | beta 1.19.70.21 | Removed dataValue: int argument. |