Minecraft Wiki
Advertisement

A command block is a block that can execute commands. Because it cannot be obtained or edited in Survival mode without cheats, it is primarily used on multiplayer servers, in Creative worlds, and custom maps.

An impulse command block is the default block type; it executes only once when activated.

A chain command block executes every time when triggered.

A repeating command block executes every game tick as long as it is activated.

Obtaining[]

In Java Edition, command blocks are available in the Creative inventory under the "Operator Utilities" tab, if the "Operator Items Tab" setting in the "Controls" Options tab is set to "ON". Across both Java and Bedrock editions, they can either be obtained by using the pick block control, or by using various commands, such as /give @s minecraft:command_block, or /setblock ~ ~ ~ command_block.

Just like other blocks that can store NBT data, using pick block + CTRL copies the command and options inside the command block. This allows it to be placed elsewhere without having to re-enter the data inside.

Command blocks are not flammable, and have the same blast resistance as bedrock. Command blocks, structure blocks, and jigsaw blocks cannot be mined in Survival.

Command blocks can be placed by a non-operator player.

Usage[]

A command block can execute commands when activated by redstone power. It always has permissions of 2 level‌[Java Edition only]/1 level‌[Bedrock Edition only], so it can be used to allow a specific use of a command by players who can't use that command in general (for example, allowing anyone to obtain a specific item with /give without allowing everyone to /give themselves whatever they want).

A command block has an orientation that determines the chain command block to activate, and the blocks to be checked to see if a command block in "Conditional" mode executes.

To execute the command, in Java Edition in multiplayer enable-command-block in the server.properties file must be set to true (default is false); in Bedrock Edition "Command Blocks Enabled" in options must be enabled.

Modification[]

Command Block GUI

Java Edition command block GUI

To enter command or modify the command block, use the Use Item control on the command block to open the command block GUI (graphical user interface). The GUI opens only if the player is in Creative mode, and has the proper permissions. That means, in singleplayer, "Allow Cheats"‌[JE only] or "Activate Cheats"‌[BE only] in options must be enabled. In multiplayer, Gui can be opened only by operators in Creative mode, and in Java Edition op-permission-level in the server.properties file must be set to 2 or above (default is 4).

In Java Edition to enter command or modify the command block, enable-command-block in the server.properties file must be set to true (default is false).

Bedrock Command Block GUI

Bedrock edition command block GUI

In Java Edition, opening the GUI in singleplayer pauses the game.

Console Command‌[JE only]/Command Input‌[BE only]
Commands can be entered in the top text pane. The text limit for commands in a command block is 32,500 characters, but the text pane can show only a small portion of this amount at a time.
Commands in a command block do not need to be prefixed with the forward-slash (/) as they do in the chat window, but doing so still works.
Press Tab ↹ to complete words or cycle through options.
In Bedrock Edition, below the console command text pane are some reminder tips about how to use target selectors.
Previous Output
The bottom text pane displays the output message (success or failure) of the last executed command (it is blank‌[JE only] or " - "‌[BE only] initially). Its text is not editable.
A button to the right of the Previous Output text pane‌[JE only] or the left of the "Previous Output"‌[BE only] specifies whether the last output should be stored and displayed. It is O[JE only]/enabled‌[BE only] when the output text should be stored and X[JE only]/disabled‌[BE only] when the output text should not be stored. For worlds with many command blocks, especially command blocks running on fast clocks, not storing the output text can reduce memory and storage requirements.
If gamerule sendCommandFeedback is true (the default), default to O[JE only]/enabled‌[BE only]. Otherwise defaults to X[JE only]/disabled‌[BE only].
Block Type
Command block textures

Left: "Impulse" block type.
Middle: "Chain" block type.
Right: "Repeating" block type.
Top: "Unconditional" mode.
Bottom: "Conditional" mode.

Click the "Impulse/Chain/Repeat"‌[JE only]/"Block Type"‌[BE only] button to change the command block's type. The default state is "Impulse", but non-default command blocks can be obtained and placed. The command block also changes color when changing its command block type:
  • "Impulse" command blocks are orange. They execute once every time they are activated.
  • "Chain" command blocks are green. They execute once every time they are triggered if they have been activated.
  • "Repeat" command blocks are purple. They execute their commands once every one game tick (or more‌[BE only]) as long as they are activated.
Condition
Click the "Conditional/Unconditional"‌[JE only]/"Condition"‌[BE only] button to change the command block's conditional behavior:
  • "Conditional": A command block in conditional mode executes its command only when the command block behind it has executed successfully ("Success count" is greater than 0).
  • "Unconditional" (default): A command block in unconditional mode executes its command even if there's a command block behind it that didn't execute its command successfully.
"Behind it" in the sense of opposite to the direction the command block is facing, regardless of chain direction or even if chaining is occurring.
Redstone
Click the "Always Active/Needs Redstone"‌[JE only]/"Redstone"‌[BE only] button to change the command block's activation requirements:
  • "Needs Redstone" (the default for impulse and repeat command blocks): A command block in the "Needs Redstone" setting can be activated only with redstone.
  • "Always Active" (the default for chain command blocks): The command block is activated when set to "Always Active". Then it is always active even without redstone activation.
Execute on First Tick‌[BE only]
Specifies whether a repeat command block executes its command as soon as it is activated. If it's disabled, executes the first time after the delay from the time when it is activated.
Delay in Ticks‌[BE only]
For impulse or chain command block, specifies how many game ticks it delays before executing a command after it is activated or triggered.
For repeat command block, specifies how many game ticks it delays to execute again.
Note that for impulse or repeat command block, 0 and 1 work the same; the game takes 0 as 1. However, For chain command block, 0 and 1 are different.
Hover Note‌[BE only]
Specifies the name of the command block, which can be seen when you point to the block. It is also used for message commands. If the command block had been named in an anvil before placement, that name is used as well. If it is empty, defaults to !.
Done
In Java Edition, click the "Done" button or ↵ Enter to save the command and leave the command block GUI.
In Bedrock Edition, close the GUI to save the command and changes.
Cancel
Click the "Cancel" button or Esc[JE only]to leave the command block GUI without saving any changes.

Activation[]

Command blocks are redstone mechanisms and can be activated by:

A command block can also be activated by setting it to "Always Active" mode.

When activated, a command block executes its command, depending on the command block's type:

  • An impulse command block executes its command once.
  • A chain command block does not execute its command until it is triggered.
  • A repeat command block executes its command once every one game tick (or more‌[BE only]) until no longer activated.

Execution[]

An impulse command block, when it is activated, checks whether the command block behind it has executed successfully (if in conditional mode). After the delay of 1 game tick (or more‌[BE only]), if the condition is met before the delay (if in "Conditional" mode), it executes its command once and triggers the chain command block it is pointing to.

A repeat command block, when it is activated, after 1 game tick (always 1 no matter how many "Delay in Ticks" is), checks whether the command block behind it has executed successfully (if in conditional mode). If the condition is met, and if "Execute on First Tick‌" is enabled in Bedrock Edition, it executes its command once and triggers the chain command block it is pointing to. If it is still activated, it then checks, executes, and triggers the chain command block again after 1 game tick (or more‌[BE only]).

When executing a command, it also updates its success count: If in "Conditional" mode, if the command block behind it didn't execute successfully, it sets its success count to 0. Otherwise, it sets it to the success count of the command.

Also:

  • When an impulse or repeat command block in "Needs Redstone" mode with a command is placed or is cloned by a command to a powered location, the new command block executes its command only if it hasn't been activated with redstone. In Java Edition, it also needs a block update to execute its command.
  • When an impulse or repeat command block in "Always Active" mode with a command is placed or is cloned by a command to a powered location, the new command block executes its command only if it hasn't been activated with redstone.
  • When an impulse or chain command block is set to "Repeat", if it has been activated, checks whether the command block behind it has executed successfully (if in conditional mode). After 1 game tick (always 1 no matter how many "Delay in Ticks" is), if the condition is met, it executes its command once and triggers the chain command block it is pointing to. Then it checks, executes, and triggers the chain command block again after 1 game tick (or more‌[BE only]).

Trigger and chaining[]

If any command block having executed its command (whether successfully or unsuccessfully) faces a chain command block, it triggers the chain command block to also attempt execution.

When a chain command block is triggered,

  • If it has been activated,
    • It checks whether it is in "Conditional" mode and the command block behind it hasn't executed successfully (Behind in the sense of the direction it is facing, not in the sense of which command block chained to it),
      • If true, it triggers another chain command block it is facing, without executing the command.
      • If false, it checks whether it has been already executed in this game tick. If false, it executes the command and triggers another chain command block it is facing. If true, it does nothing. That means that chained execution cannot be passed to a command block that has already executed in that game tick (loops execute only once).
  • If it has not been activated, it triggers the chain command block it is facing to attempt execution.

Chained command blocks execute simultaneously in the same game tick in the order they are chained.

In Bedrock Edition, it can also delay before executing commands if "Delay in Ticks" is not 0:

When it is triggered,
  • If it has been activated, the chain command block checks whether the command block behind it has executed successfully (if in conditional mode), then it delays.
    • After a delay, if the condition is met before the delay (if in "Conditional" mode), it executes its command once and triggers the chain command block it is pointing to no matter whether the condition met.
  • If it has not been activated, it triggers (without delay) the chain command block it is facing to attempt execution.

In Java Edition, it can execute multiple times in the same game tick if "UpdateLastExecution" is set to false. In this case, it does not check whether it has already executed in this game tick.

If the chain command block has been activated when triggered, it also updates its success count: If in "Conditional" mode, if the command block behind it didn't execute successfully, it sets its success count to 0. Otherwise, it sets it to the success count of the command.

Output[]

When activated, a command block can produce multiple types of output:

Success count[]

A command block can power a redstone comparator facing away from it (possibly separated by a block) with signal strength specific to the success count. Success count is an integer between 0 to 2,147,483,647 (inclusive).
The signal strength always reflects the last command executed, even after the command block is deactivated.
In Java Edition, success count is usually 0 or 1, except for /function and /execute.
In Bedrock Edition, success count is an integer related to the command (e.g., the number of players affected by the command, the number of blocks that were altered, the value returned by the command, etc.)
In Java Edition, leaving the command block GUI by clicking "Done" or pressing ↵ Enter resets the success count to 0, regardless of whether changes were made in the GUI. In Bedrock Edition, leaving the GUI with changes resets the success count to 0.

Message[]

The output message describes the success or failure of the executed command, and may be written to multiple destinations:
Previous Output: The output message is always written to the "Previous Output" text pane of the command block GUI.
Chat: The output message is written to the chat text in singleplayer mode, or broadcast to all other ops in multiplayer mode, unless it has been suppressed with /gamerule commandBlockOutput false. Some commands may write additional text to the chat as their normal function, which won't be suppressed (for example, the /say command writes a message to the chat of all players), separate from the output message. Chat messages that would usually be prefaced by a player's name (such as from the /me, /say and /tell commands) use @[Java Edition only] / ![Bedrock Edition only] as the player name. If the command block had been named in an anvil before placement, that name is used instead. In Bedrock Edition, it can also modified in the GUI.
Logs: The output message is written to multiplayer server logs unless it has been suppressed with /gamerule logAdminCommands false.

Notes[]

Command blocks execute commands with OP level 2. The following commands cannot be used in a command block: /ban, /banlist, /ban-ip, /debug, /deop, /kick[JE only], /op, /pardon, /pardon-ip, /publish, /reload[BE only], /save-all, /save-off, /save-on, /stop, and /whitelist (i.e., /debug, /publish, and all of the multiplayer-only commands except /list).

Easter eggs[]

Running "Searge" (case insensitive) as the command in the command block without a preceding "/" will set the previous output to "#itzlipofutzli". Its success count is 1.

Piston interactivity[]

Command blocks cannot be pushed by pistons. They also cannot be pushed or pulled by sticky pistons.

Sounds[]

Java Edition:

SoundSubtitlesSourceDescriptionResource locationTranslation keyVolumePitchAttenuation
distance
Block brokenBlocksOnce the block has brokenblock.metal.breaksubtitles.block.generic.break1.01.216
Block placedBlocksWhen the block is placedblock.metal.placesubtitles.block.generic.place1.01.216
Block breakingBlocksWhile the block is in the process of being brokenblock.metal.hitsubtitles.block.generic.hit0.250.7516
None[sound 1]Entity-DependentFalling on the block with fall damageblock.metal.fallNone[sound 1]0.51.2516
FootstepsEntity-DependentWalking on the blockblock.metal.stepsubtitles.block.generic.footsteps0.151.516
  1. a b MC-177082

Bedrock Edition:

SoundSourceDescriptionResource locationVolumePitch
BlocksOnce the block has brokendig.stone1.01.1-1.2
BlocksWhen the block is placeduse.stone1.01.2-1.25
BlocksWhile the block is in the process of being brokenhit.stone0.30.75
PlayersFalling on the block with fall damagefall.stone0.41.0
PlayersWalking on the blockstep.stone0.351.0
PlayersJumping from the blockjump.stone0.121.0
PlayersFalling on the block without fall damageland.stone0.221.0

Data values[]

ID[]

Java Edition:

NameIdentifierFormBlock tagsTranslation key
Command Blockcommand_blockBlock & Itemdragon_immune
wither_immune
block.minecraft.command_block
Chain Command Blockchain_command_blockBlock & Itemdragon_immune
wither_immune
block.minecraft.chain_command_block
Repeating Command Blockrepeating_command_blockBlock & Itemdragon_immune
wither_immune
block.minecraft.repeating_command_block
NameIdentifier
Block entitycommand_block

Bedrock Edition:

NameIdentifierNumeric ID FormItem ID[i 1]Translation key
Command Blockcommand_block137Block & Giveable Item[i 2]Identical[i 3]tile.command_block.name
Chain Command Blockchain_command_block189Block & Giveable Item[i 2]Identical[i 3]tile.chain_command_block.name
Repeating Command Blockrepeating_command_block188Block & Giveable Item[i 2]Identical[i 3]tile.repeating_command_block.name
  1. ID of block's direct item form, which is used in savegame files and addons.
  2. a b c Available with /give command.
  3. a b c The block's direct item form has the same id as the block.
NameSavegame ID
Block entityCommandBlock

Block states[]

See also: Block states

Java Edition:

Name Default value Allowed values Description
conditionalfalsefalse
true
True if the command block is in conditional mode.
facingnorthdown
east
north
south
up
west
The direction the command block is pointing.

Bedrock Edition:

NameMetadata Bits Default value Allowed valuesValues for
Metadata Bits
Description
conditional_bit0x8falsefalse
true
0
1
True if the command block is in conditional mode.
facing_direction0x1
0x2
0x4
00
1
2
3
4
5
0
1
2
3
4
5
The direction the command block is pointing.
  • 0: facing down
  • 1: facing up
  • 2: facing north
  • 3: facing south
  • 4: facing west
  • 5: facing east

Block data[]

A command block has a block entity associated with it that holds additional data about the block.

Java Edition:

  • Block entity data
    • Tags common to all block entities
    •  auto: 1 or 0 (true/false) - Allows to activate the command without the requirement of a redstone signal.
    •  Command: The command to issue to the server.
    •  conditionMet: 1 or 0 (true/false) - Indicates whether a conditional command block had its condition met when last activated. True if not a conditional command block.
    •  CustomName: Optional. The name JSON text component of this command block, replacing the usual '@' when using commands such as /say and /tell.
    •  LastExecution: stores the tick a chain command block was last executed in.
    •  LastOutput: The last line of output generated by the command block. Still stored even if the game rule commandBlockOutput is false. Appears in the GUI of the block when right-clicked, and includes a timestamp of when the output was produced.
    •  powered: 1 or 0 (true/false) - States whether or not the command block is powered by redstone or not.
    •  SuccessCount: Represents the strength of the analog signal output by redstone comparators attached to this command block.
    •  TrackOutput: 1 or 0 (true/false) - Determines whether the LastOutput is stored. Can be toggled in the GUI by clicking a button near the "Previous Output" textbox. Caption on the button indicates current state: "O" if true, "X" if false.
    •  UpdateLastExecution: 1 or 0 (true/false) - Defaults to true. If set to false, loops can be created where the same command block can run multiple times in one tick.

Bedrock Edition:

See Bedrock Edition level format/Block entity format.

History[]

Java Edition
July 27, 2012Jeb began tweeting of a new block he had created to start expanding Adventure mode. He began posting pictures, ideas and hints of what the block can do.
July 31, 2012During Notch's AMA on Reddit, he hinted the block may be in Java Edition 1.4.
1.4.212w32aImpulse Command Block JE1 Added command blocks.
12w38aAdded the game rule commandBlockOutput.
1.513w03aCommand block success can now power a redstone comparator.
13w04aCommand blocks renamed with an anvil now use their name instead of @ in the chat.
13w10aPressing Esc in a command block will exit its GUI.
1.6.113w19aCommand blocks are no longer mineable in Survival.
Command blocks are no longer damaged by explosions, except by blue wither skulls.
1.7.213w37aA bar that shows the previous output of command blocks has been added.
The character limit when inserting a command in a command block has been increased from 256 to 16,369. Using a third-party editor allows the player to reach 32,767 characters.
1.814w07aDispensers now place command blocks, instead of shooting them out.
14w20aThe in-game character limit of 16,369 has been removed, allowing access to the full 32,767 characters.
14w27aAdded CommandStats NBT tag to command blocks.
1.8.6Dispensers no longer place command blocks.[1]
1.915w33aThe character limit for command blocks is now 32,500 instead of 32,767.
15w34aChain Command Block JE1 Repeating Command Block JE1 Added the chain command block and the repeating command block.
Added block facing for command blocks.
Impulse Command Block JE2 The texture of command blocks has been changed.
15w34bAdded Conditional mode within command blocks.
Added tab completion support within command blocks.
15w35aImpulse Command Block JE3 BE1 Chain Command Block JE2 BE1 Repeating Command Block JE2 BE1 The textures of all three command blocks have been changed.
Conditional Impulse Command Block JE1 BE1 Conditional Chain Command Block JE1 BE1 Conditional Repeating Command Block JE1 BE1 When command blocks are set to conditional, the back of the arrow texture is now curved.
Added Always active and needs redstone options for command blocks.
Added auto NBT tag to control redstone options within command blocks.
15w36aPlayers are now unable to use commands, such as /give, within command blocks.
Players, who are unable to use commands, can no longer place command blocks.
15w36dEach command block type now appears with different colors on maps.
16w02aRunning /help in a command block now randomly uses one of various different humorous phrases as the previous output.
16w04aRunning "Searge" as the command in the command block without a preceding "/" now sets the previous output to "#itzlipofutzli".
1.1116w32aThe block entity ID has been changed from Control to command_block.
1.1217w16aChains of command blocks no longer schedule their commands to be run in the next tick. Instead, they now execute all in the same tick they are read. This allows later blocks in a chain to be modified via earlier blocks, allowing techniques like branching and looping, all in the same tick.
17w16bAdded the game rule maxCommandChainLength to control the max length of a command block chain.
17w17aAdded UpdateLastExecution and LastExecution NBT tags, which control the tracking of which tick a chain command block was last executed in.
pre6Tab-completing command names in command blocks no longer add a / prefix.
1.1317w47aPrior to The Flattening, the numeral IDs for the command block, repeating command block, and chain command block were 137, 210, and 211, respectively.
pre1The player can now tab-complete in command blocks again.
1.1418w43aImpulse Command Block JE4 Chain Command Block JE3 BE2 Repeating Command Block JE3 The textures of command blocks have been changed.
18w47bImpulse Command Block JE5 BE2 Repeating Command Block JE4 BE2 The textures of impulse and repeating command blocks have been changed.
1.19.322w44aCommand blocks are now available in the creative inventory, but only if cheats are enabled.
22w45aMoved command blocks behind the Operator Utilities tab in the creative inventory. The tab is only available if cheats are enabled and the "Operator Items Tab" option in the controls menu is turned on.
Upcoming Java Edition
1.20.223w31aThe text in command blocks now scrolls when selected using ⇧ Shift and arrow keys.[2]
Pocket Edition
1.0.5alpha 1.0.5.0Impulse Command Block JE3 BE1 Chain Command Block JE2 BE1 Repeating Command Block JE2 BE1 Added all types of command blocks.
Bedrock Edition
1.8.0beta 1.8.0.8Command blocks now have a default name of ! instead of @.
1.10.0beta 1.10.0.3Impulse Command Block JE5 BE2 Chain Command Block JE3 BE2 Repeating Command Block JE4 BE2 The textures of command blocks have been changed.
1.12.0beta 1.12.0.2Tab-complete has been added to command blocks.
Added a delay option to command blocks, which allows a delay to be added to a redstone tick delay field.
Legacy Console Edition
TU19CU7 1.12 Patch 1Impulse Command Block JE1 Added command blocks.
Command blocks do not have any functionality and can be obtained only with mods.
?????Added chain and repeating command blocks. These are completely unobtainable without inventory editing with an external editor, but can be modded into the game. They do not have any functionality.

Issues[]

Issues relating to "Command Block" are maintained on the bug tracker. Report issues there.

Gallery[]

References[]

External Links[]

Advertisement