Test for a Block at Specific Coordinates
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.
/testforblock <position: x y z> <tileName: Block> [blockStates: block properties]Test for block, optional block state
| Argument | Type | What it means |
|---|---|---|
blockStates | block properties | This optional argument defines the exact block properties that the block must have to pass the test. |
position: x y z | position | This required argument is the vector coordinate of the location where you want to test for the block. |
tileName | Block | This required argument specifies the block name from the game's block list that you are looking for. |
/testforblock 100 64 -200 stoneChecks if there is a stone block at the exact coordinates 100, 64, -200.
/testforblock ~ ~-1 ~ grass_blockTests whether the block directly beneath the player or command block is a grass block.
/testforblock 0 70 0 chestVerifies if a chest is placed at the coordinates 0, 70, 0.
/testforblock ~2 ~ ~-3 diamond_blockChecks for a diamond block located 2 blocks east and 3 blocks north of the current position.
/testforblock 45 12 80 airTests if the space at 45, 12, 80 is empty by checking for an air block.
/testforblock -50 65 120 lever ["lever_direction"="north","open_bit"=true]Checks if a lever at -50, 65, 120 is facing north and is currently switched on.
/testforblock ~ ~1 ~ oak_log ["pillar_axis"="y"]Tests if the block directly above is an oak log placed upright along the Y axis.
/testforblock 210 80 -15 furnace ["facing_direction"=2]Verifies that a furnace is at 210, 80, -15 and is facing direction 2.
Minecraft Java Edition does not have a command named /testforblock, as this command is exclusive to Bedrock Edition.
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.
Yes, cheats must be turned on in your world, and you need the Game Directors permission level to run this command.
No, the block states argument is optional, so you only need to include the coordinates and the block name for a basic check.
/dialogue/execute/function/packstack/reload/reloadpacketlimitconfig/schedule/scoreboard/scriptevent/sendshowstoreoffer/tag/testfor/testforblocks/toggledownfall