Getting Started with Control Blocks

Command blocks are a specialized type of block inside a Minecraft: Bedrock Edition earth that allows the utilise of panel commands in-game. The same commands that players tin can type from chat can exist run automatically by command blocks using redstone ability.

In this tutorial, yous will learn the following;

  • What are command blocks and how to access them in-game.
  • How commands can be used via command blocks.
  • How command block bondage work by stringing together multiple control blocks.
  • Create a gameplay loop to advantage a actor later performing an activity.

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

Requirements

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

Setting the map upward

While command blocks can be used in any Minecraft world, nosotros will be using a flat world for a unproblematic and clean environment.

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

How to get Control Blocks

Command blocks can but be obtained past running a command.

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

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

How to use Command Blocks

First, place the command cake on the ground like any other block. Wait at the control block from the side, and y'all may find an arrow.

Image showcasing CommandBlock Arrows pointing to the right of the image

These arrows will always point towards the player when placing downward. The arrows show the flow of execution. As shown in the image, the block on the left will execute first, followed by the middle control cake, and finally the last block on the right will execute.

Click the Use push (correct-click on PC) to open up upwards the control cake user interface.

Command Cake User Interface

Overview of the command block graphical user interface

  • Block Blazon defines what type of control block this is. There are three options:
    • Impulse command blocks are activated when they receive a redstone signal.
    • Chain command blocks are activated when a command cake pointing into it is activated.
    • Repeat command blocks are activated once every in-game tick, as long as they have a redstone point. Minecraft has 20 ticks per second.
  • Condition defines when a control block will execute its activeness. At that place are 2 options:
    • Conditional will simply execute if the previous cake in a concatenation was successful.
    • Unconditional will execute regardless if the previous cake was successful or not.
  • Redstone defines whether or not a control block requires redstone to activate. In that location are ii options:
    • Needs Redstone will fix the control cake to merely activate when it has redstone power.
    • Ever Active volition set the control block to always activate with or without redstone. For impulse command blocks, this causes them to only run once, so it isn't very useful. For chain control blocks, this is enabled by default.
  • Execute on First Tick is only usable for repeating command blocks with a delay. If enabled, the control will execute as soon as the block is powered, and then will wait for the filibuster before running once more. If disabled, the control volition not run the showtime fourth dimension until the delay has finished.
  • Delay in Ticks is a value that defines how long a command block waits to execute later on the command block receives redstone power.

Designing a Gameplay Loop

A use case of command blocks is allowing creators to create gameplay loops within Minecraft. A uncomplicated gameplay loop would exist rewarding a player for completing an activeness. If the gameplay loop was to give a actor an emerald for placing a diamond block in a certain location, you tin break down each stride needed:

  1. Cheque to see if a diamond block exists at a set location.
  2. If it does, cheque to see if the histrion has already received the reward.
  3. If the role player hasn't received the reward, give the player an emerald.
  4. After giving the player an emerald, mark that they have received the reward.

Setting upwards the first Command Block

At present that we have looked at the settings of a control block, allow'southward set up upwardly the first cake to discover a certain blazon of block in a location.

  1. Place a command block on the basis in a location near your player character.
  2. Open up the command cake interface.
  3. Gear up the Block Type to Repeat.
  4. Gear up the Redstone to Always Active.

The /testforblock Control

The /testforblock command looks for a specific cake at a specified signal in the globe.

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

  • position is the coordinates in the world where the control will look for the specific block. Example: 0 four 0.
  • tileName is the type of block yous are looking for. Example: diamond_block.
  • dataValue is an optional argument 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, you will be in a flat world. As yous walk effectually, y'all tin see your actor's position in the top-left of the screen. Let'southward check for a cake near the origin.

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

Control Block Chains

For the next pace, we demand to place a chain command block. Every bit mentioned to a higher place, concatenation command blocks execute when a block pointing into them is activated. Make sure you place the cake similar the epitome showing the arrows.

Setting up the /testforblock Command Cake

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

Since the second cake is set to Provisional, this new block will only execute if the commencement command block succeeds, meaning the diamond block was present. This command checks to see if the role player hasn't already received the reward.

Setting up the Reward Command Block

Let's add a third block to set a command to reward the player for placing a block in the right spot.

  1. Place some other command block side by side to the existing block. Make certain that the new cake is placed in front end of the direction that the arrow is pointing.
  2. Open the control block interface.
  3. Set the Block Type to Chain.
  4. Set the Condition to Conditional.
  5. Set the Redstone to Always Active.
  6. Set up the Control Input to /requite @p emerald.

Once once again, this command will only activate if the previous command succeeded, meaning both the diamond block was present and the player hasn't received the advantage still.

Closing the loop

If we stop now, placing the diamond block at 0 four 0 will requite the player 20 emeralds per second! That's because we need to do one last pace, marking the role player every bit having received the reward.

  1. Identify another command block adjacent to the existing block. Make sure that the new block is placed in front end of the direction that the arrow is pointing.
  2. Open the control block interface.
  3. Set the Cake Type to Chain.
  4. Set the Condition to Provisional.
  5. Set the Redstone to Always Agile.
  6. Set the Command Input to /tag @p add placed_block

Testing the loop

If everything has been set upwardly correctly, you can now place a diamond block on location 0, four, 0 and you lot will receive a unmarried emerald in your histrion inventory.