search
Minecraft Wiki

Minecraft Wiki

936 pages 4332 edits Updated: Jul 06
Wiki BG

Command Blocks

Command Blocks
Source: Youtube


A command block is a type of block that has the ability to execute commands. It serves a specific purpose in various gameplay scenarios, such as multiplayer servers, Creative worlds, and custom maps. In Survival mode, acquiring or modifying command blocks without enabling cheat mode is not possible. Therefore, their usage is mainly observed in the aforementioned contexts.


The default variant of a command block is known as an impulse command block. When activated, it executes the command it contains only once.


On the other hand, a chain command block operates differently. It executes its command every time it is triggered or activated.


Lastly, a repeating command block functions on a per-game tick basis. As long as it remains activated, it repeatedly executes its command during each game tick.


youtube-cover


Obtaining


Obtaining
Source: Youtube


In the Java Edition of the game, command blocks can be found in the Creative inventory under the "Operator Utilities" tab. This is accessible if the "Operator Items Tab" setting in the "Controls" Options tab is set to "ON". In both Java and Bedrock editions, players can obtain command blocks through different methods. They can either use the pick block control to obtain a copy of the block, or they can utilize various commands like "/give @s minecraft:command_block" or "/setblock ~ ~ ~ command_block".


Similar to other blocks capable of storing NBT (Named Binary Tag) data, players can use the pick block function combined with the CTRL key to copy the command and options stored within the command block. This enables them to place the block elsewhere without the need to re-enter the data.


Command blocks are non-flammable and possess the same blast resistance as bedrock. It is important to note that command blocks, structure blocks, and jigsaw blocks cannot be mined in Survival mode.


Additionally, it is possible for a non-operator player to place command blocks in the game.


Usage


The command block serves the purpose of executing commands upon being activated by redstone power. It possesses a permission level of 2 in Java Edition (or 1 in Bedrock Edition), enabling it to regulate the usage of specific commands. This means that players who don't have general access to a particular command can still utilize it through the command block. For instance, it allows granting anyone the ability to acquire a specific item using the /give command, without granting unrestricted access to /give any item they desire.


The orientation of a command block is significant as it determines which chain command block will be activated next, and which blocks will be assessed to determine whether a command block operating in "Conditional" mode will execute its command.


In order to execute commands using command blocks in Java Edition multiplayer, the "enable-command-block" setting in the server.properties file must be set to true (the default value is false). On the other hand, in Bedrock Edition, the "Command Blocks Enabled" option must be enabled in the game's settings.


Command Block GUI Modification


Java Edition command block GUI

To input or modify commands within a command block, the player can utilize the "Use Item" control while interacting with the command block. This action opens the command block GUI, which stands for Graphical User Interface. It's important to note that the GUI is accessible exclusively when the player is in Creative mode and possesses the necessary permissions. In single-player mode, this requires enabling the "Allow Cheats" option in Java Edition or the "Activate Cheats" option in Bedrock Edition within the game's settings. In multiplayer, the GUI can only be accessed by operators who are in Creative mode. Additionally, in Java Edition, the "op-permission-level" value within the server.properties file needs to be set at 2 or above (with 4 being the default value).


In Java Edition, in order to input or modify commands within a command block, the "enable-command-block" setting in the server.properties file must be adjusted to true. By default, this setting is set to false.


Console Command/ Command Input


In Java Edition, when opening the command block GUI in single-player, the game is paused to allow the player to focus on entering or modifying commands without any distractions.


  • The command input is done in the top text pane of the GUI. It's important to note that command blocks have a text limit of 32,500 characters for commands, although only a small portion of this limit is visible in the text pane at a time.


  • Unlike the chat window, commands entered in a command block do not require the forward-slash (/) prefix, although using it still functions correctly.


  • To facilitate command input, players can press the Tab ↹ key to auto-complete words or cycle through available options, providing a convenient way to streamline the command entry process.


  • In Bedrock Edition, below the console command text pane, there are helpful reminder tips about using target selectors, which aid players in understanding how to effectively utilize this feature.


Previous Output Modification


In the command block GUI, the bottom text pane serves the purpose of displaying the output message (whether the command execution was successful or not) from the last executed command. Initially, the text pane is either blank in Java Edition or displays a hyphen ("-") in Bedrock Edition. It is important to note that the text in the output pane cannot be edited by the player.


To the right of the Previous Output text pane in Java Edition (or to the left of the "Previous Output" text pane in Bedrock Edition), there is a button that allows the player to specify whether the last output should be stored and displayed. In Java Edition, this button appears as "O" when the output text should be stored and displayed, and as "X" when the output text should not be stored. In Bedrock Edition, the button appears as "enabled" or "disabled" for the same purpose. This feature becomes particularly useful in worlds that contain numerous command blocks, especially those operating on fast clocks. By opting not to store the output text, it can help reduce memory and storage requirements.


By default, if the gamerule "sendCommandFeedback" is set to true (which is the default setting), the button will default to "O" in Java Edition or "enabled" in Bedrock Edition, indicating that the output text should be stored and displayed. However, if the "sendCommandFeedback" gamerule is set to false, the button will default to "X" in Java Edition or "disabled" in Bedrock Edition, signifying that the output text should not be stored.


Block Type Modification


Block Type Modification
Source: Youtube


Command block textures

  • Left: Texture representing the "Impulse" block type.

  • Middle: Texture representing the "Chain" block type.

  • Right: Texture representing the "Repeating" block type.

  • Top: Texture indicating the "Unconditional" mode.

  • Bottom: Texture indicating the "Conditional" mode.


By clicking the "Impulse/Chain/Repeat" button (in Java Edition) or the "Block Type" button (in Bedrock Edition), the command block's type can be changed. The default state of the command block is set to "Impulse," but it is possible to obtain and place non-default command block types. When changing the command block's type, its color also changes accordingly:


  • "Impulse" command blocks have an orange color. They execute their commands once every time they are activated.

  • "Chain" command blocks have a green color. They execute their commands once every time they are triggered, given that they have been activated.

  • "Repeat" command blocks have a purple color. They execute their commands once every game tick or more (in Bedrock Edition) as long as they remain activated.


Condition Modification


To modify the conditional behavior of a command block, you can click the "Conditional/Unconditional" button (in Java Edition) or the "Condition" button (in Bedrock Edition). This button allows you to toggle the command block between two modes:


  • "Conditional" mode: When a command block is set to conditional mode, it will execute its command only if the command block positioned behind it has successfully executed its command (indicated by a "Success count" greater than 0). In other words, the execution of the current command block depends on the success of the command block situated behind it.


  • "Unconditional" mode (default): By default, a command block operates in unconditional mode. In this mode, the command block executes its command regardless of whether there is a command block positioned behind it that failed to execute its command successfully. It disregards the success or failure of the preceding command block and carries out its command independently.


It's important to note that when referring to "behind it," it signifies the opposite direction to which the command block is facing, irrespective of the chain direction or even if chaining is occurring between command blocks.


Redstone Modification


To adjust the activation requirements of a command block, you can click the "Always Active/Needs Redstone" button (in Java Edition) or the "Redstone" button (in Bedrock Edition). This button allows you to toggle between two settings:


  • "Needs Redstone" (default for impulse and repeat command blocks): When a command block is set to "Needs Redstone," it can only be activated by providing a redstone signal. In other words, the command block requires an external redstone input to trigger its execution.


  • "Always Active" (default for chain command blocks): On the other hand, when a command block is set to "Always Active," it is continuously active without the need for a redstone signal. It remains operational at all times, regardless of whether a redstone input is present.


It's important to note that the default setting varies depending on the type of command block. Impulse and repeat command blocks default to "Needs Redstone," meaning they require redstone activation. Chain command blocks default to "Always Active," implying that they remain active without relying on a redstone signal.


Execute on First Tick Modification (Bedrock Edition)


The "Execute on First Tick" setting, available only in Bedrock Edition, determines whether a repeat command block executes its command immediately upon activation or if it waits for a delay specified by the player. When the setting is disabled, the repeat command block will execute its command for the first time after the delay period has elapsed since activation.


Delay in Ticks (Bedrock Edition)


For impulse or chain command blocks in Bedrock Edition, the "Delay in Ticks" option allows you to specify the number of game ticks the command block should wait before executing its command after activation or being triggered. In the case of a repeat command block, the "Delay in Ticks" determines the interval between each subsequent execution.


It is worth noting that in Bedrock Edition, a value of 0 and 1 for impulse or repeat command blocks function the same way, as the game interprets 0 as 1. However, for chain command blocks, there is a distinction between 0 and 1.


Hover Note (Bedrock Edition)


The "Hover Note" setting specifies the name of the command block, which becomes visible when pointing at the block. This name is also used for message commands. If the command block was named using an anvil before being placed, that assigned name will be used. If the field is left empty, the default name will be "!."


Done


In Java Edition, clicking the "Done" button or pressing ↵ Enter finalizes the command and saves it, while also exiting the command block GUI. In Bedrock Edition, simply closing the GUI will save the command and any changes made.


Cancel


By clicking the "Cancel" button or pressing the Esc key in Java Edition, you can exit the command block GUI without saving any changes made to the command or its settings.


Activation of Command Blocks


Command blocks in Minecraft can be activated through various means, primarily involving redstone mechanisms. Here are the ways in which command blocks can be activated:


  • Adjacent Active Power Component: Command blocks can be activated by being in close proximity to an active power component. This can include levers, blocks of redstone, daylight sensors, buttons, and other similar devices.


  • Adjacent Powered Block: If a command block is adjacent to a powered block, such as an opaque block with an active redstone torch beneath it, the command block will be activated.


  • Powered Redstone Comparator or Repeater: Command blocks can also be activated by facing a powered redstone comparator or redstone repeater towards them.


  • Powered Redstone Dust: When redstone dust is configured to point at a command block (or placed on top of it) or is directionless, it can activate the command block. However, adjacent powered redstone dust that is configured to point away from the command block will not activate it.


  • "Always Active" Mode: By setting a command block to "Always Active" mode, it remains activated at all times without relying on any external redstone signals.


Once a command block is activated, it executes its respective command based on its type:


  • Impulse Command Block: An impulse command block executes its command once when activated.


  • Chain Command Block: A chain command block does not execute its command immediately upon activation. It waits to be triggered by another event or command.


  • Repeat Command Block: A repeat command block executes its command every game tick (or at a specified interval in Bedrock Edition) as long as it remains activated.


These activation mechanisms provide flexibility and control over when and how command blocks execute their commands within Minecraft.


Execution of Command Blocks


The execution of command blocks in Minecraft depends on their type, mode, and activation conditions. Here is a detailed explanation of how impulse and repeat command blocks behave when activated, along with additional relevant information:


Impulse Command Block

  • When an impulse command block is activated, it first checks if the command block behind it (if in conditional mode) has been executed successfully.

  • After a delay of 1 game tick (or more in Bedrock Edition), if the condition is met before the delay (in "Conditional" mode), the impulse command block executes its command once.

  • Upon execution, it triggers the chain command block that it is pointing to, if connected.


Repeat Command Block

  • Upon activation, a repeat command block immediately checks if the command block behind it (if in conditional mode) has been executed successfully.

  • After 1 game tick (always 1, regardless of the specified "Delay in Ticks"), if the condition is met and "Execute on First Tick" is enabled (in Bedrock Edition), the repeat command block executes its command once.

  • It then triggers the chain command block it is pointing to, if connected.

  • If the repeat command block remains activated, it continues to check, execute, and trigger the chain command block after each subsequent game tick (or more in Bedrock Edition).


Success Count and Activation Conditions

When a command block executes a command, it updates its success count.


In "Conditional" mode, if the command block behind it fails to execute successfully, the impulse or repeat command block sets its success count to 0. Otherwise, it sets it to the success count of the executed command.


Additional Information

If an impulse or repeat command block is set to "Needs Redstone" mode and placed or cloned to a powered location, it will execute its command only if it hasn't been previously activated by redstone. In Java Edition, a block update is also required for execution. If an impulse or repeat command block is set to "Always Active" mode and placed or cloned to a powered location, it will execute its command only if it hasn't been previously activated by redstone.


When a chain command block is set to "Repeat" mode and activated, it follows a similar execution process as described for the impulse command block. It checks the success of the command block behind it (if conditional), executes its command, triggers the chain command block it is pointing to, and repeats the process after each game tick (or more in Bedrock Edition).


These mechanisms and conditions allow for intricate command block setups and precise control over command execution in Minecraft.


Triggering and Chaining of Command Blocks


When a command block executes its command, regardless of the success or failure of the command, it triggers any chain command block it is facing. This allows for sequential execution of commands.


Triggering a Chain Command Block

  • If a command block has executed its command and faces a chain command block, it triggers the chain command block to attempt execution.

  • If the chain command block is activated:

  • It checks if it is in "Conditional" mode and the command block behind it (in the direction it is facing) has not executed successfully.

  • If true, it triggers another chain command block it is facing, without executing its own command.

  • If false, it proceeds to the next step.

  • It checks if it has already been executed in the current game tick:

  • If false, it executes its command, triggers another chain command block it is facing, and marks itself as executed in the current game tick.

  • If true, it does nothing, preventing execution loops.

  • If the chain command block has not been activated, it triggers the chain command block it is facing to attempt execution.


Chained Command Block Execution


Chained command blocks execute simultaneously within the same game tick, following the order in which they are chained.


Delay in Ticks (Bedrock Edition)

In Bedrock Edition, chain command blocks can have a specified delay before executing their commands if the "Delay in Ticks" value is not set to 0:


  • When triggered, if the chain command block has been activated, it checks if the command block behind it (if in conditional mode) has executed successfully and then proceeds to the next step.

  • After the specified delay in game ticks, it executes its command once, regardless of the condition being met before the delay.

  • It triggers the chain command block it is facing to attempt execution.


Updating Success Count

  • If a chain command block is triggered and it has been activated, it updates its success count:

  • In "Conditional" mode, if the command block behind it didn't execute successfully, it sets its success count to 0.


Otherwise, it sets its success count to the success count of the command executed.


Additional Notes (Java Edition)

  • In Java Edition, chain command blocks can be set to execute multiple times within the same game tick by disabling the "UpdateLastExecution" property. In this case, the command block does not check if it has already executed in the current game tick.

  • The triggering and chaining of command blocks provide a powerful mechanism for creating complex and dynamic command sequences in Minecraft.


When a command block is activated and executes its command, it can produce multiple types of output:


Success Count


The command block can power a redstone comparator facing away from it, with the signal strength reflecting the success count of the command. In Java Edition, the success count is usually 0 or 1, except for certain commands like /function and /execute.


In Bedrock Edition, the success count is an integer value related to the specific command executed, such as the number of players affected or the value returned by the command. The success count always reflects the last executed command, even after the command block is deactivated.


In Java Edition, leaving the command block GUI by clicking "Done" or pressing Enter resets the success count to 0, regardless of any changes made in the GUI. In Bedrock Edition, leaving the GUI with changes also resets the success count to 0.


Output Message


The output message describes the success or failure of the executed command and can be written to various destinations.


The output message is always written to the "Previous Output" text pane in the command block GUI.


In Java Edition, the output message is written to the chat text in single player mode or broadcasted to all other operators in multiplayer mode unless it has been suppressed with the /gamerule commandBlockOutput false.


Some commands may write additional text to the chat as part of their normal function (e.g., the /say command), which won't be suppressed.


In Bedrock Edition, the output message can also be modified in the GUI. The output message is also written to multiplayer server logs unless it has been suppressed with the /gamerule logAdminCommands false.


Note

Command blocks execute commands with OP level 2. Certain commands, such as /ban, /kick, /op, and /whitelist, cannot be used in a command block. The behavior and availability of specific commands may vary between Java Edition and Bedrock Edition.


Data Values


In Minecraft, command blocks have specific data values that define their properties. The data values differ between Java Edition and Bedrock Edition. Here are the data values for command blocks in each edition:


Java Edition


Command Block

  • ID: command_block

  • Block Tags: dragon_immune

  • Translation Key: block.minecraft.command_block

  • Block Entity: command_block


Chain Command Block

  • ID: chain_command_block

  • Block Tags: dragon_immune

  • Translation Key: block.minecraft.chain_command_block

  • Block Entity: command_block


Repeating Command Block

  • ID: repeating_command_block

  • Block Tags: dragon_immune

  • Translation Key: block.minecraft.repeating_command_block

  • Block Entity: command_block


Bedrock Edition


Command Block

  • ID: command_block

  • Numeric ID: 137

  • Form: Block & Giveable Item

  • Item ID: command_block

  • Translation Key: tile.command_block.name

  • Savegame ID (Block Entity): CommandBlock


Chain Command Block

  • ID: chain_command_block

  • Numeric ID: 189

  • Form: Block & Giveable Item

  • Item ID: chain_command_block

  • Translation Key: tile.chain_command_block.name

  • Savegame ID (Block Entity): CommandBlock


Repeating Command Block

  • ID: repeating_command_block

  • Numeric ID: 188

  • Form: Block & Giveable Item

  • Item ID: repeating_command_block

  • Translation Key: tile.repeating_command_block.name

  • Savegame ID (Block Entity): CommandBlock


Additionally, command blocks have block states that determine their specific settings. Here are the block states for command blocks:


Java Edition

Conditional:

Default Value: false

Allowed Values: false, true

Description: Specifies if the command block is in conditional mode.


Facing:

Default Value: north

Allowed Values: down, east, north, south, up, west

Description: Specifies the direction the command block is pointing.


Bedrock Edition

Conditional Bit:

  • Metadata Bits: 0x8

  • Default Value: false

  • Allowed Values: false, true

  • Description: Specifies if the command block is in conditional mode.


Facing Direction:

  • Metadata Bits: 0x1, 0x2, 0x4

  • Default Value: 0

  • Allowed Values: 0, 1, 2, 3, 4, 5


Values

  • 0: facing down

  • 1: facing up

  • 2: facing north

  • 3: facing south

  • 4: facing west

  • 5: facing east


These data values and block states are used to define the properties and behavior of command blocks in Minecraft.


Block data


In Java Edition, a command block has a block entity associated with it that holds additional data about the block. Here are the block entity data tags for a command block:


  • auto: This tag indicates whether the command block can be activated without a redstone signal. It has a value of 1 (true) or 0 (false).

  • Command: This tag stores the command that the command block will issue to the server.

  • conditionMet: For conditional command blocks, this tag indicates whether the condition for activation was met during the last activation. It has a value of 1 (true) if the condition was met, or 0 (false) if it was not a conditional command block.

  • CustomName: An optional tag that specifies the custom name of the command block using JSON text components. This name can replace the usual '@' symbol when using commands like /say and /tell.

  • LastExecution: This tag stores the tick value when a chain command block was last executed.

  • LastOutput: The LastOutput tag stores the last line of output generated by the command block. It is retained even if the game rule commandBlockOutput is set to false. The LastOutput appears in the GUI of the command block when right-clicked, and includes a timestamp indicating when the output was produced.

  • powered: This tag indicates whether the command block is currently powered by redstone. It has a value of 1 (true) if powered or 0 (false) if not powered.

  • SuccessCount: The SuccessCount tag represents the strength of the analog signal output by redstone comparators attached to the command block. It reflects the success count of the last executed command.

  • TrackOutput: This tag determines whether the LastOutput is stored. It has a value of 1 (true) if the LastOutput is stored or 0 (false) if it is not. It can be toggled in the command block's GUI by clicking a button near the "Previous Output" textbox. The button will show an "O" if the LastOutput is being tracked and an "X" if it is not.

  • UpdateLastExecution: This tag determines whether a command block can run multiple times in one tick, creating a loop. By default, it is set to true. If set to false, the same command block can run multiple times in a single tick.


These block entity data tags provide additional control and information about the behavior and output of the command block in Java Edition.

FAQs

Q. How can a command block be activated in Minecraft?

A. A command block can be activated by various means, including adjacent active power components (levers, redstone blocks, buttons, etc.), powered blocks, powered redstone comparators or repeaters, or by setting it to "Always Active" mode.

Q. What is the difference between an impulse command block and a repeat command block?

A. An impulse command block executes its command once when activated, while a repeat command block executes its command repeatedly, once every game tick until it is no longer activated.

Q. How does chaining between command blocks work?

A. When a command block executes its command, if it is facing a chain command block, it triggers the chain command block to attempt execution. Chained command blocks execute simultaneously in the same game tick in the order they are chained.

Q. What types of output can a command block produce?

A. A command block can produce output in the form of a success count, which can power a redstone comparator and a message that can be displayed in the command block GUI, chat, or server logs.
This functionality is open only to Wiki Admins

Popular In Minecraft Wiki

Comments

Latest Wiki Pages

Smelting

Smelting

Minecraft Wiki 10 mn 22 d
Sky Dimension in Minecraft

Sky Dimension in Minecraft

Minecraft Wiki 10 mn 5 d
Education Edition

Education Edition

Minecraft Wiki 10 mn 8 d
Getting Started in Minecraft

Getting Started in Minecraft

Minecraft Wiki 10 mn 12 d
The Twilight Forest Minecraft mod

The Twilight Forest Minecraft mod

Minecraft Wiki 11 mn 27 d
Mowzie’s Mobs

Mowzie’s Mobs

Minecraft Wiki 11 mn 28 d
What is Pixelmon in Minecraft?

What is Pixelmon in Minecraft?

Minecraft Wiki 11 mn 30 d
How to Craft an Oak Button in Minecraft

How to Craft an Oak Button in Minecraft

Minecraft Wiki 11 mn 30 d
How to Craft a Tripwire Hook in Minecraft?

How to Craft a Tripwire Hook in Minecraft?

Minecraft Wiki 11 mn 2 d
How to Craft a Lever in Minecraft?

How to Craft a Lever in Minecraft?

Minecraft Wiki 11 mn 3 d
How to craft a Redstone Repeater in Minecraft?

How to craft a Redstone Repeater in Minecraft?

Minecraft Wiki 11 mn 4 d
How to craft a Daylight Detector in Minecraft?

How to craft a Daylight Detector in Minecraft?

Minecraft Wiki 11 mn 5 d
How to Craft a Redstone Comparator in Minecraft

How to Craft a Redstone Comparator in Minecraft

Minecraft Wiki 11 mn 6 d
Can Dragon Fireball be used as a decorative item in Minecraft?

Can Dragon Fireball be used as a decorative item in Minecraft?

Minecraft Wiki 11 mn 7 d
How to Craft a Beacon in Minecraft

How to Craft a Beacon in Minecraft

Minecraft Wiki 11 mn 9 d
What are Elder Guardians and what do they do in Minecraft?

What are Elder Guardians and what do they do in Minecraft?

Minecraft Wiki 11 mn 14 d
Verdant Froglight in Minecraft

Verdant Froglight in Minecraft

Minecraft Wiki 12 mn 16 d
What are Dragon Fireballs in Minecraft?

What are Dragon Fireballs in Minecraft?

Minecraft Wiki 12 mn 17 d
What is Structure Void in Minecraft?

What is Structure Void in Minecraft?

Minecraft Wiki 12 mn 18 d
What are Structure blocks in Minecraft?

What are Structure blocks in Minecraft?

Minecraft Wiki 12 mn 18 d