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).

Requirements

To run game commands in Minecraft, you have to turn cheats on in your world.

TestForBlock Command

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:””}.

Examples

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:""}

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.

Click to rate this post!
[Total: 2 Average: 5]