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.
Let's explore how to use this cheat (game command).
* 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.
- 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 [dataValue] [dataTag]
Definitions
- x y zis the coordinate to test.Learn about the coordinate system.
- blockis name of the block to test for. (See我的世界Item Names)
- dataValueis optional. It is the variation of the block if more than one type exists for thatblock. To match on all data values, either omit this parameter or use adataValueof
-1
or*
.
- dataTagis optional. It is the伟德1946网页版
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
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 [dataValue]
Definitions
- positionis thex y z coordinateto test.
- tileNameis name of the block to test for. (See我的世界Item Names).
- dataValueis optional. It is the variation of the block if more than one type exists for thattileName. To match on all data values, either omit this parameter or use adataValueof
-1
.
- 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
测试是否有胸部在协调(62, 89, 213) that is facing North (a data value of 2 denotes North facing):
/testforblock -62 89 213 chest 2
测试是否有胸部在协调(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 wool block (any color) directly below you in Minecraft PE:
/testforblock ~ ~-1 ~ wool
To test whether there is a pink wool block directly below you:
/testforblock ~ ~-1 ~ wool 6
To test whether there is polished granite at coordinate (7, 62, 52):
/testforblock 7 62 52 stone 2
Example in Xbox One Edition
To test whether there is a coral block (any color) directly below you in Minecraft Xbox One Edition:
/testforblock ~ ~-1 ~ coral_block
To test whether there is a fire coral block directly below you:
/testforblock ~ ~-1 ~ coral_block 3
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 concrete powder block (any color) directly below you in Minecraft PS4 Edition:
/testforblock ~ ~-1 ~ concretepowder
To test whether there is a magenta concrete powder block directly below you:
/testforblock ~ ~-1 ~ concretepowder 2
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 concrete block (any color) directly below you in Minecraft Nintendo Switch Edition:
/testforblock ~ ~-1 ~ concrete
To test whether there is a light blue concrete block directly below you:
/testforblock ~ ~-1 ~ concrete 3
To test whether there is purple shulker box at coordinate (-35, 60, 4):
/testforblock -35 60 4 shulker_box 10
Example in Windows 10 Edition
To test whether there is terracotta (any color) directly below you in Minecraft Windows 10 Edition:
/testforblock ~ ~-1 ~ stained_hardened_clay
To test whether there is a red terracotta directly below you:
/testforblock ~ ~-1 ~ stained_hardened_clay 14
To test whether there is andesite at coordinate (12, 65, 3):
/testforblock 12 65 3 stone 5
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
In this example, we will test whether there is a grass block directly below you with the following command:
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 theEnterkey to run the command.
Once the cheat has been entered, the /testforblock command will check for diamond ore at the location specified.
Congratulations, you have learned how to use the /testforblock command in Minecraft.