How to Use the TestForBlock Command in Minecraft
This Minecraft tutorial explains how to use the /testforblock command with screenshots and step-by-step instructions.
You can test whether there is a certain block at a specific location in the game using the /testforblock command in Minecraft.
TIP: Starting in Minecraft Java Edition (PC/Mac) 1.13, the /testforblock command was removed from the Java Edition version of the game.
Let's explore how to use this cheat (game command).
Supported Platforms
The /testforblock command is available in the following versions of Minecraft:
Platform | Supported (Version*) |
Java Edition (PC/Mac) | Yes (1.7.2), but removed in (1.13) |
Pocket Edition (PE) | Yes (0.16.0) |
Xbox 360 | No |
Xbox One | Yes (1.2) |
PS3 | No |
PS4 | Yes (1.14.0) |
Wii U | No |
Nintendo Switch | Yes (1.5.0) |
Windows 10 Edition | Yes (0.16.0) |
Education Edition | Yes |
* The version that it was added or removed, if applicable.
NOTE: Pocket Edition (PE), Xbox One, PS4, Nintendo Switch, and Windows 10 Edition are now called Bedrock Edition. We will continue to show them individually for version history.
Requirements
To run game commands in Minecraft, you have to turn cheats on in your world.
TestForBlock Command
- Java
- PE
- Xbox
- PS
- Nintendo
- Win10
- Edu
TestForBlock Command in Minecraft Java Edition (PC/Mac)
In Minecraft Java Edition (PC/Mac) 1.8, 1.9, 1.10, 1.11 and 1.12, the syntax to test whether a certain block is in a specific location is:
/testforblock <x> <y> <z> <block> [dataValue] [dataTag]
Definitions
- x y z is the coordinate to test. Learn about the coordinate system.
- block is name of the block to test for. (See Minecraft Item Names)
- dataValue is optional. It is the variation of the block if more than one type exists for that block. To match on all data values, either omit this parameter or use a dataValue of
-1
or *
.
- dataTag is optional. It is the data tag for the block. It is a compound NBT tag such as {Lock:""}.
TestForBlock Command in Minecraft Pocket Edition (PE)
In Minecraft Pocket Edition (PE), the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> <blockStates>
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- blockStates replaces the old
tileData
parameter. It is enclosed in [ ]
and identifies specific properties of titleName such as ["color":"black"]
(See our Bedrock Fill generator for blockStates)
TestForBlock Command in Minecraft Xbox One Edition
In Minecraft Xbox One Edition, the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> <blockStates>
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- blockStates replaces the old
tileData
parameter. It is enclosed in [ ]
and identifies specific properties of titleName such as ["color":"black"]
(See our Bedrock Fill generator for blockStates)
TestForBlock Command in Minecraft PS4 Edition
In Minecraft PS4 Edition, the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> <blockStates>
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- blockStates replaces the old
tileData
parameter. It is enclosed in [ ]
and identifies specific properties of titleName such as ["color":"black"]
(See our Bedrock Fill generator for blockStates)
TestForBlock Command in Minecraft Nintendo Switch Edition
In Minecraft Nintendo Switch Edition, the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> <blockStates>
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- blockStates replaces the old
tileData
parameter. It is enclosed in [ ]
and identifies specific properties of titleName such as ["color":"black"]
(See our Bedrock Fill generator for blockStates)
TestForBlock Command in Minecraft Windows 10 Edition
In Minecraft Windows 10 Edition, the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> <blockStates>
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- blockStates replaces the old
tileData
parameter. It is enclosed in [ ]
and identifies specific properties of titleName such as ["color":"black"]
(See our Bedrock Fill generator for blockStates)
TestForBlock Command in Minecraft Education Edition
In Minecraft Education Edition, the syntax to test whether a certain block is in a specific location is:
/testforblock <position> <tileName> [dataValue]
Definitions
- position is the x y z coordinate to test.
- tileName is name of the block to test for. (See Minecraft Item Names).
- dataValue is optional. It is the variation of the block if more than one type exists for that tileName. To match on all data values, either omit this parameter or use a dataValue of
-1
.
Examples
- Java
- PE
- Xbox
- PS
- Nintendo
- Win10
- Edu
Example in Java Edition (PC/Mac) 1.11 and 1.12
To test whether there is a diamond ore directly below you in Minecraft 1.11 and 1.12:
/testforblock ~ ~-1 ~ diamond_ore
To test whether there is a chest at coordinate (-62, 89, 213) that is facing North (a data value of 2 denotes North facing):
/testforblock -62 89 213 chest 2
To test whether there is a chest at coordinate (-62, 89, 213) that is facing any direction (North, South, East or West) and is not locked:
/testforblock -62 89 213 chest * {Lock:""}
Example in Pocket Edition (PE)
To test whether there is a pink wool block directly below you in Minecraft PE:
/testforblock ~ ~-1 ~ pink_wool
To test whether there is polished granite at coordinate (7, 62, 52):
/testforblock 7 62 52 stone ["stone_type":"granite_smooth"]
Example in Xbox One Edition
To test whether there is a fire coral block directly below you in Minecraft Xbox One Edition:
/testforblock ~ ~-1 ~ coral_block ["coral_color":"red"]
To test whether there is blue ice at coordinate (13, 67, -8):
/testforblock 13 67 -8 blue_ice
Example in PS4 Edition
To test whether there is a magenta concrete powder block directly below you in Minecraft PS4 Edition:
/testforblock ~ ~-1 ~ concrete_powder ["color":"magenta"]
To test whether there is a honey block at coordinate (8, 64, -10):
/testforblock 8 64 -10 honey_block
Example in Nintendo Switch Edition
To test whether there is a light blue concrete block directly below you in Minecraft Nintendo Switch Edition:
/testforblock ~ ~-1 ~ concrete ["color":"light_blue"]
To test whether there is purple shulker box at coordinate (-35, 60, 4):
/testforblock -35 60 4 shulker_box ["color":"purple"]
Example in Windows 10 Edition
To test whether there is a red terracotta directly below you in Minecraft Windows 10 Edition:
/testforblock ~ ~-1 ~ stained_hardened_clay ["color":"red"]
To test whether there is andesite at coordinate (12, 65, 3):
/testforblock 12 65 3 stone ["stone_type":"andesite"]
Example in Education Edition
To test whether there is sand (any color) directly below you in Minecraft Windows 10 Edition:
/testforblock ~ ~-1 ~ sand
To test whether there is a red sand directly below you:
/testforblock ~ ~-1 ~ sand 1
To test whether there is smooth sandstone at coordinate (24, 67, 8):
/testforblock 24 67 8 sandstone 2
How to Enter the Command
1. Open the Chat Window
The easiest way to run a command in Minecraft is within the chat window. The game control to open the chat window depends on the version of Minecraft:
- For Java Edition (PC/Mac), press the T key to open the chat window.
- For Pocket Edition (PE), tap on the chat button at the top of the screen.
- For Xbox One, press the D-Pad (right) on the controller.
- For PS4, press the D-Pad (right) on the controller.
- For Nintendo Switch, press the right arrow button on the controller.
- For Windows 10 Edition, press the T key to open the chat window.
- For Education Edition, press the T key to open the chat window.
2. Type the Command
In this example, we will test whether there is a grass block directly below you with the following command:
/testforblock ~ ~-1 ~ diamond_ore
Type the command in the chat window. As you are typing, you will see the command appear in the lower left corner of the game window. Press the Enter key to run the command.
Once the cheat has been entered, the /testforblock command will check for diamond ore at the location specified.
You will see the message "Successfully found the block at -182, 72, 230" appear in the lower left corner of the game window to indicate that the block was found at the specified location.
Congratulations, you have learned how to use the /testforblock command in Minecraft.