Getting Started with Command Blocks

Command blocks are a specialized type of block within a Minecraft: Bedrock Edition world that allows the use of panel commands in-game. The aforementioned commands that players tin can blazon from conversation can exist run automatically by control blocks using redstone power.

In this tutorial, you will learn the post-obit;

  • What are command blocks and how to admission them in-game.
  • How commands can be used via control blocks.
  • How command block chains work by stringing together multiple command blocks.
  • Create a gameplay loop to reward a player afterward performing an activeness.

In this guide, we will set a control block chain to look for a certain type of block in a prepare location, then reward the player for placing a cake in the correct place.

Requirements

  • Introduction to Commands
  • A Minecraft world with cheats enabled.

Setting the map upwardly

While command blocks can be used in whatever Minecraft world, we volition exist using a flat world for a unproblematic and make clean environs.

  1. Launch Minecraft: Bedrock Edition.
  2. Select Play, select Create New, then select Create New Globe.
  3. In the world settings, set the world type to Flat.
  4. In the earth settings, enable Show Coordinates.
  5. In the earth settings, enable Actuate Cheats.
  6. Select Create.

How to go Control Blocks

Control blocks tin only be obtained by running a control.

  1. Open chat.
  2. Type the following command: /give @p command_block.

Yous will run across a single command block that been added to your inventory.

How to use Command Blocks

Beginning, identify the command block on the ground like whatever other block. Expect at the command block from the side, and yous may discover an arrow.

Image showcasing CommandBlock Arrows pointing to the right of the image

These arrows will e'er point towards the role player when placing downward. The arrows bear witness the catamenia of execution. Every bit shown in the image, the block on the left volition execute first, followed by the heart command cake, and finally the last block on the correct volition execute.

Click the Utilize button (right-click on PC) to open up the command cake user interface.

Command Block User Interface

Overview of the command block graphical user interface

  • Block Type defines what type of command block this is. There are iii options:
    • Impulse command blocks are activated when they receive a redstone signal.
    • Chain command blocks are activated when a command block pointing into information technology is activated.
    • Echo command blocks are activated in one case every in-game tick, every bit long equally they have a redstone indicate. Minecraft has 20 ticks per second.
  • Condition defines when a command block will execute its activeness. There are 2 options:
    • Conditional volition simply execute if the previous block in a concatenation was successful.
    • Unconditional volition execute regardless if the previous block was successful or not.
  • Redstone defines whether or non a command block requires redstone to activate. There are 2 options:
    • Needs Redstone will prepare the command block to only activate when it has redstone power.
    • Ever Active will gear up the command cake to always activate with or without redstone. For impulse control blocks, this causes them to only run once, then information technology isn't very useful. For chain command blocks, this is enabled by default.
  • Execute on Beginning Tick is merely usable for repeating command blocks with a delay. If enabled, the command volition execute equally presently as the block is powered, and and so volition look for the filibuster before running again. If disabled, the command will not run the first time until the delay has finished.
  • Filibuster in Ticks is a value that defines how long a command block waits to execute afterwards the command block receives redstone power.

Designing a Gameplay Loop

A employ case of command blocks is allowing creators to create gameplay loops inside Minecraft. A unproblematic gameplay loop would be rewarding a histrion for completing an action. If the gameplay loop was to give a role player an emerald for placing a diamond cake in a certain location, yous can interruption down each step needed:

  1. Check to see if a diamond block exists at a set location.
  2. If it does, check to see if the player has already received the reward.
  3. If the player hasn't received the advantage, give the histrion an emerald.
  4. After giving the player an emerald, marking that they accept received the reward.

Setting up the first Control Block

Now that we have looked at the settings of a control block, let'due south prepare the first cake to detect a certain type of block in a location.

  1. Place a command block on the ground in a location near your player character.
  2. Open up up the command block interface.
  3. Fix the Block Blazon to Repeat.
  4. Set the Redstone to Always Active.

The /testforblock Command

The /testforblock command looks for a specific block at a specified indicate in the world.

/testforblock <position: 10 y z> <tileName: Block> [dataValue: int]

  • position is the coordinates in the world where the command will look for the specific cake. Example: 0 4 0.
  • tileName is the blazon of block you are looking for. Example: diamond_block.
  • dataValue is an optional statement used to handle variations of the same block. For this tutorial, we won't be needing to employ this.

If you are following this tutorial, yous volition be in a apartment globe. As you lot walk effectually, you can see your player's position in the top-left of the screen. Let's check for a block near the origin.

  1. In the Command Input section, input the post-obit: /testforblock 0 4 0 diamond_block.
  2. Close the interface.

Command Block Chains

For the next step, nosotros need to place a concatenation command cake. As mentioned above, chain control blocks execute when a cake pointing into them is activated. Brand certain you identify the block like the image showing the arrows.

Setting upwards the /testforblock Command Block

  1. Place another command cake side by side to the existing block. Make sure that the new block is placed in forepart of the direction that the arrow is pointing.
  2. Open the command block interface.
  3. Set the Block Type to Chain.
  4. Fix the Status to Provisional.
  5. Set up the Redstone to Always Active.
  6. Set the Command Input to /testfor @p[tag=!placed_block]

Since the second block is set to Conditional, this new block will just execute if the starting time command block succeeds, meaning the diamond cake was present. This control checks to see if the histrion hasn't already received the reward.

Setting up the Advantage Command Block

Let'south add together a 3rd block to prepare a command to reward the histrion for placing a block in the right spot.

  1. Place another control block next to the existing block. Make sure that the new cake is placed in front of the direction that the arrow is pointing.
  2. Open the command block interface.
  3. Set up the Block Blazon to Chain.
  4. Gear up the Condition to Provisional.
  5. Set the Redstone to Ever Active.
  6. Set the Command Input to /give @p emerald.

Again, this command will only activate if the previous command succeeded, meaning both the diamond cake was present and the thespian hasn't received the reward yet.

Closing the loop

If we stop now, placing the diamond block at 0 4 0 will give the actor 20 emeralds per 2d! That'southward because we demand to do ane concluding step, marking the player as having received the reward.

  1. Place another command block side by side to the existing block. Make sure that the new block is placed in front of the direction that the arrow is pointing.
  2. Open the control block interface.
  3. Set the Block Blazon to Chain.
  4. Set the Condition to Conditional.
  5. Gear up the Redstone to Always Active.
  6. Fix the Command Input to /tag @p add together placed_block

Testing the loop

If everything has been fix up correctly, y'all can now place a diamond block on location 0, 4, 0 and you will receive a single emerald in your player inventory.