Minecraft:Command Block: Difference between revisions
More actions
imported>TheSentientCommandBlock →Gallery: Added "extra stuff". |
Fix template calls: add MC/ prefix |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{For||Command (disambiguation)}} | {{MC/For||Command (disambiguation)}} | ||
{{Infobox block | {{Infobox block | ||
|image= | |image= | ||
| Line 31: | Line 31: | ||
* {{TooltipSprite||Repeating Command Block}} {{Map color|Repeating Command Block}} | * {{TooltipSprite||Repeating Command Block}} {{Map color|Repeating Command Block}} | ||
}} | }} | ||
A '''command block''' is an | A '''command block''' is an indestructible [[Minecraft:block]] that can execute [[Minecraft:commands]]. Because it cannot be obtained, destroyed or used in Survival mode without cheats, it is primarily used in multiplayer servers, Creative worlds, and custom maps. There are 3 types of these blocks. | ||
An '''impulse command block''' is the default block type; it executes only once when activated. | An '''impulse command block''' is the default block type; it executes only once when activated. | ||
| Line 40: | Line 40: | ||
== Obtaining == | == Obtaining == | ||
{{ | {{MC/In|Java}}, command blocks are available in the [[Minecraft: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 various [[Minecraft:commands]], such as {{MC/Cmd|give @s minecraft:command_block}} or {{MC/Cmd|setblock ~ ~ ~ command_block}}, or by pressing the {{MC/Control|pick block}} control on an existing command block. | ||
Just like other blocks that can store | Just like other blocks that can store NBT data, using {{MC/Control|pick block}} + {{MC/Key|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 | Command blocks are not flammable, and have the same blast resistance as [[Minecraft:bedrock]]. Command blocks, structure blocks, and jigsaw blocks cannot be mined in Survival. | ||
== Usage == | == Usage == | ||
{{ | {{MC/See also|Commands|Tutorials/Command blocks and functions}} | ||
A command block can execute commands when [[#Activation|activated]] by | A command block can execute commands when [[#Activation|activated]] by redstone power. It always has permissions of level 2{{only|java}}/level 1{{only|bedrock}}, 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 {{MC/Cmd|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. | 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}} the | To execute the command, {{MC/In|java}} the game rule <code>command_blocks_work</code> must be set to <code>true</code>; {{MC/In|bedrock}} "Command Blocks Enabled" in world options must be enabled. | ||
Command blocks can only be placed or broken by an | Command blocks can only be placed or broken by an operator player in Creative mode. | ||
=== Modification === | === Modification === | ||
[[File:Command Block GUI.png|thumb|''Java Edition'' command block GUI|alt=]] | [[File:Command Block GUI.png|thumb|''Java Edition'' command block GUI|alt=]] | ||
To enter command or modify the command block, use the {{ | To enter command or modify the command block, use the {{MC/Control|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"{{only|java|short=1}} or "Activate Cheats"{{only|bedrock|short=1}} in world options must be enabled. In [[Minecraft:multiplayer]], GUI can be opened only by operators in Creative mode, and {{MC/In|java}} <code>op-permission-level</code> in the [[Minecraft:server.properties]] file must be set to <code>2</code> or above (default is 4). | ||
{{ | {{MC/In|java}} to enter command or modify the command block, <code>enable-command-block</code> in the [[Minecraft:server.properties]] file must be set to <code>true</code> (default is <code>false</code>). | ||
[[File:Bedrock Command Block GUI.png|thumb|''Bedrock Edition'' command block GUI]] | [[File:Bedrock Command Block GUI.png|thumb|''Bedrock Edition'' command block GUI]] | ||
{{ | {{MC/In|java}}, opening the GUI in singleplayer pauses the game. | ||
;Console Command{{only|java|short=1}}/Command Input{{only|bedrock|short=1}} | ;Console Command{{only|java|short=1}}/Command Input{{only|bedrock|short=1}} | ||
| Line 71: | Line 71: | ||
:Commands in a command block do ''not'' need to be prefixed with the forward-slash (<code>/</code>) as they do in the chat window, but doing so still works. | :Commands in a command block do ''not'' need to be prefixed with the forward-slash (<code>/</code>) as they do in the chat window, but doing so still works. | ||
:Press {{ | :Press {{MC/Key|tab}} to complete words or cycle through options. | ||
:{{ | :{{MC/In|bedrock}}, below the console command text pane are some reminder tips about how to use [[Minecraft:target selectors]]. | ||
;Previous Output | ;Previous Output | ||
| Line 122: | Line 122: | ||
;Done | ;Done | ||
:{{ | :{{MC/In|java}}, click the "Done" button or {{MC/Key|Enter}} to save the command and leave the command block GUI. | ||
:{{ | :{{MC/In|bedrock}}, close the GUI to save the command and changes. | ||
;Cancel | ;Cancel | ||
:Click the "Cancel" button or {{ | :Click the "Cancel" button or {{MC/Key|Esc}}{{only|java|short=1}}to leave the command block GUI without saving any changes. | ||
=== Activation === | === Activation === | ||
Command blocks are [[Minecraft:Redstone components#Mechanism components|redstone mechanisms]] and can be activated by: | Command blocks are [[Minecraft:Redstone components#Mechanism components|redstone mechanisms]] and can be activated by: | ||
* An adjacent active '''[[Minecraft:Redstone components#Power components|power component]]''': for example, a [[Minecraft:lever]], a | * An adjacent active '''[[Minecraft:Redstone components#Power components|power component]]''': for example, a [[Minecraft:lever]], a block of redstone, a daylight sensor, a [[Minecraft:button]] etc. | ||
* An adjacent ''' powered block''' (for example, an opaque block with an active redstone torch under it) | * An adjacent ''' powered block''' (for example, an opaque block with an active redstone torch under it) | ||
* A powered ''' | * A powered '''redstone comparator''' or '''redstone repeater''' facing the mechanism component | ||
* Powered ''' | * Powered '''redstone dust''' configured to point at the command block (or on top of it) or directionless; a command block is ''not'' activated by adjacent powered redstone dust that is configured to point away from it. | ||
A command block can also be activated by setting it to "Always Active" mode. | A command block can also be activated by setting it to "Always Active" mode. | ||
| Line 146: | Line 146: | ||
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{{only|bedrock|short=1}}), 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. | 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{{only|bedrock|short=1}}), 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 {{ | 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 {{MC/In|bedrock}}, 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{{only|bedrock|short=1}}). | ||
When executing a command, it also updates its [[#Success count|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. | When executing a command, it also updates its [[#Success count|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: | 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. {{ | * 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. {{MC/In|java}}, 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 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{{only|bedrock|short=1}}). | * 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{{only|bedrock|short=1}}). | ||
| Line 167: | Line 167: | ||
Chained command blocks execute simultaneously in the same game tick in the order they are chained. | Chained command blocks execute simultaneously in the same game tick in the order they are chained. | ||
{{ | {{MC/In|bedrock}}, it can also delay before executing commands if "Delay in Ticks" is not 0: | ||
:When it is triggered, | :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. | :* 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. | ||
| Line 173: | Line 173: | ||
:* If it has not been activated, it triggers (without delay) the chain command block it is facing to attempt execution. | :* If it has not been activated, it triggers (without delay) the chain command block it is facing to attempt execution. | ||
{{ | {{MC/In|java}}, 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|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. | If the chain command block has been activated when triggered, it also updates its [[#Success count|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. | ||
| Line 185: | Line 185: | ||
:The signal strength always reflects the last command executed, even after the command block is deactivated. | :The signal strength always reflects the last command executed, even after the command block is deactivated. | ||
:{{ | :{{MC/In|java}}, success count is usually 0 or 1, except for {{MC/Cmd|function}} and {{MC/Cmd|execute}}. | ||
:{{ | :{{MC/In|bedrock}}, 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.) | ||
:{{ | :{{MC/In|java}}, leaving the command block GUI by clicking "Done" or pressing {{MC/Key|Enter}} resets the success count to 0, regardless of whether changes were made in the GUI. {{MC/In|bedrock}}, leaving the GUI with changes resets the success count to 0. | ||
==== Message ==== | ==== Message ==== | ||
| Line 196: | Line 196: | ||
:''Previous Output:'' The output message is always written to the "Previous Output" text pane of the command block GUI. | :''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 | :''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 {{MC/Cmd|gamerule commandBlockOutput false}}. Some commands may write additional text to the chat as their normal function, which won't be suppressed (for example, the {{MC/Cmd|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 {{MC/Cmd|me}}, {{MC/Cmd|say}} and {{MC/Cmd|tell}} commands) use <code>@</code> {{Only|JE}} / <code>!</code> {{Only|BE}} as the player name. If the command block had been named in an [[Minecraft:anvil]] before placement, that name is used instead. {{MC/In|bedrock}}, it can also modified in the GUI. | ||
: ''Logs:'' The output message is written to multiplayer server logs unless it has been suppressed with {{ | : ''Logs:'' The output message is written to multiplayer server logs unless it has been suppressed with {{MC/Cmd|gamerule logAdminCommands false}}. | ||
=== {{ | === {{MC/Anchor|Unusable commands}} Notes === | ||
Command blocks execute commands with OP level 2. The following commands cannot be used in a command block: {{ | Command blocks execute commands with OP level 2. The following commands cannot be used in a command block: {{MC/Cmd|ban}}, {{MC/Cmd|banlist}}, {{MC/Cmd|ban-ip}}, {{MC/Cmd|debug}}, {{MC/Cmd|deop}}, {{MC/Cmd|kick}}{{only|java|short=1}}, {{MC/Cmd|op}}, {{MC/Cmd|pardon}}, {{MC/Cmd|pardon-ip}}, {{MC/Cmd|publish}}, {{MC/Cmd|reload}}{{only|bedrock|short=1}}, {{MC/Cmd|save-all}}, {{MC/Cmd|save-off}}, {{MC/Cmd|save-on}}, {{MC/Cmd|stop}}, {{MC/Cmd|tick}}, and {{MC/Cmd|whitelist}} (i.e., {{MC/Cmd|debug}}, {{MC/Cmd|tick}}, {{MC/Cmd|publish}}, and all of the multiplayer-only commands except {{MC/Cmd|list}}). | ||
==== Easter eggs ==== | ==== Easter eggs ==== | ||
{{ | {{MC/Main|Easter eggs#Command blocks}} | ||
Running " | Running "Searge" (case insensitive) as the command in the command block without a preceding "<code>/</code>" will set the previous output to "#itzlipofutzli". Its success count is 1. | ||
=== Piston interactivity === | === Piston interactivity === | ||
Command blocks cannot be pushed by [[Minecraft:piston]]s. They also cannot be pushed or pulled by | Command blocks cannot be pushed by [[Minecraft:piston]]s. They also cannot be pushed or pulled by sticky pistons. | ||
== Sounds == | == Sounds == | ||
{{Sound table/Block/Metal}} | {{MC/Sound table/Block/Metal}} | ||
== Data values == | == Data values == | ||
=== ID === | === ID === | ||
{{ | {{MC/Edition|java}}: | ||
{{ID table | {{ID table | ||
|edition=java | |edition=java | ||
| Line 244: | Line 244: | ||
|foot=1}} | |foot=1}} | ||
{{ | {{MC/Edition|bedrock}}: | ||
{{ID table | {{ID table | ||
|edition=bedrock | |edition=bedrock | ||
| Line 274: | Line 274: | ||
=== Block states === | === Block states === | ||
{{ | {{MC/See also|Block states}} | ||
{{ | {{MC/El|je}}: | ||
{{bst|conditional|false|false,true|True if the command block is in conditional mode.}} | {{bst|conditional|false|false,true|True if the command block is in conditional mode.}} | ||
{{bst|facing|north|down,east,north,south,up,west|The direction the command block is pointing.|foot=1}} | {{bst|facing|north|down,east,north,south,up,west|The direction the command block is pointing.|foot=1}} | ||
{{ | {{MC/El|be}}: | ||
{{bst|showaux=1|bits=0x8|conditional_bit|false|false,true|True if the command block is in conditional mode.|0,1}} | {{bst|showaux=1|bits=0x8|conditional_bit|false|false,true|True if the command block is in conditional mode.|0,1}} | ||
{{bst|bits=0x1,0x2,0x4|facing_direction|0|0,1,2,3,4,5|The direction the command block is pointing. | {{bst|bits=0x1,0x2,0x4|facing_direction|0|0,1,2,3,4,5|The direction the command block is pointing. | ||
| Line 294: | Line 294: | ||
A command block has a block entity associated with it that holds additional data about the block. | A command block has a block entity associated with it that holds additional data about the block. | ||
{{ | {{MC/El|java}}: | ||
{{ | {{MC/See also|Block entity format}} | ||
<section begin="block data"/><div class="treeview"> | <section begin="block data"/><div class="treeview"> | ||
*{{ | *{{MC/Nbt|compound}} Block entity data | ||
** {{ | ** {{MC/Nbt inherit/blockentity}} | ||
** {{ | ** {{MC/Nbt inherit/nameable}} | ||
*** Replaces the usual '@' when using commands such as {{ | *** Replaces the usual '@' when using commands such as {{MC/Cmd|say}} and {{MC/Cmd|tell}}. | ||
** {{ | ** {{MC/Nbt|byte|auto}}: 1 or 0 (true/false) - Allows to activate the command without the requirement of a redstone signal. | ||
** {{ | ** {{MC/Nbt|string|Command}}: The command to issue to the server. | ||
** {{ | ** {{MC/Nbt|byte|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. | ||
** {{ | ** {{MC/Nbt|long|LastExecution}}: stores the tick a chain command block was last executed in. | ||
** {{ | ** {{MC/Nbt|string|LastOutput}}: The last line of output generated by the command block. Still stored even if the game rule {{MC/Cd|commandBlockOutput}} is {{MC/Cd|false}}. Appears in the GUI of the block when right-clicked, and includes a timestamp of when the output was produced. | ||
** {{ | ** {{MC/Nbt|byte|powered}}: 1 or 0 (true/false) - States whether or not the command block is powered by redstone or not. | ||
** {{ | ** {{MC/Nbt|int|SuccessCount}}: Represents the strength of the analog signal output by redstone comparators attached to this command block. | ||
** {{ | ** {{MC/Nbt|byte|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. | ||
** {{ | ** {{MC/Nbt|byte|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. | ||
</div><section end="block data"/> | </div><section end="block data"/> | ||
{{ | {{MC/El|bedrock}}: | ||
:See [[Minecraft:Bedrock Edition level format/Block entity format]]. | :See [[Minecraft:Bedrock Edition level format/Block entity format]]. | ||
== History == | == History == | ||
{{See also|Commands#History}} | {{MC/See also|Commands#History}} | ||
=== Announcement === | === Announcement === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine||July 27, 2012|link={{tweet|jeb|228811183107493888}}| | |{{HistoryLine||July 27, 2012|link={{tweet|jeb|228811183107493888}}|Jeb began tweeting of a new [[Minecraft:block]] he had created to start expanding Adventure mode. He began posting pictures, ideas and hints of what the block can do.}} | ||
|{{HistoryLine||July 31, 2012|link=http://www.reddit.com/r/Minecraft/comments/xfzdg/i_am_markus_persson_aka_notch_creator_of/c5m0a79|During | |{{MC/HistoryLine||July 31, 2012|link=http://www.reddit.com/r/Minecraft/comments/xfzdg/i_am_markus_persson_aka_notch_creator_of/c5m0a79|During Notch's AMA on Reddit, he hinted the block may be in Java Edition 1.4.}} | ||
}} | }} | ||
=== ''Java Edition'' === | === ''Java Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{MC/HistoryLine|java}} | ||
|{{HistoryLine||1.4.2|dev=12w32a|[[File:Impulse Command Block JE1.png|32px]] Added command blocks.}} | |{{MC/HistoryLine||1.4.2|dev=12w32a|[[File:Impulse Command Block JE1.png|32px]] Added command blocks.}} | ||
|{{HistoryLine|||dev=12w38a|Added the | |{{HistoryLine|||dev=12w38a|Added the game rule {{MC/Cd|commandBlockOutput}}.}} | ||
|{{HistoryLine||1.5|dev=13w03a|Command block success can now power a | |{{MC/HistoryLine||1.5|dev=13w03a|Command block success can now power a redstone comparator.}} | ||
|{{HistoryLine|||dev=13w04a|Command blocks renamed with an [[Minecraft:anvil]] now use their name instead of @ in the | |{{MC/HistoryLine|||dev=13w04a|Command blocks renamed with an [[Minecraft:anvil]] now use their name instead of @ in the chat.}} | ||
|{{HistoryLine|||dev=13w10a|Pressing {{Keys|Esc}} in a command block will exit its GUI.}} | |{{HistoryLine|||dev=13w10a|Pressing {{MC/Keys|Esc}} in a command block will exit its GUI.}} | ||
|{{HistoryLine||1.6.1|dev=13w19a|Command blocks are no longer | |{{MC/HistoryLine||1.6.1|dev=13w19a|Command blocks are no longer mineable in Survival. | ||
|Command blocks are no longer damaged by | |Command blocks are no longer damaged by explosions, except by blue [[Minecraft:Wither#Wither Skull|wither skull]]s.}} | ||
|{{HistoryLine||1.7.2|dev=13w37a|A bar that shows the previous output of command blocks has been added. | |{{MC/HistoryLine||1.7.2|dev=13w37a|A bar that shows the previous output of command blocks has been added. | ||
|The character limit when inserting a | |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.}} | ||
|{{HistoryLine||1.8|dev=14w07a|[[Minecraft:Dispenser]]s now place command blocks, instead of shooting them out.}} | |{{MC/HistoryLine||1.8|dev=14w07a|[[Minecraft:Dispenser]]s now place command blocks, instead of shooting them out.}} | ||
|{{HistoryLine|||dev=14w20a|The in-game character limit of 16,369 has been removed, allowing access to the full 32,767 characters.}} | |{{MC/HistoryLine|||dev=14w20a|The in-game character limit of 16,369 has been removed, allowing access to the full 32,767 characters.}} | ||
|{{HistoryLine|||dev=14w27a|Added CommandStats NBT | |{{MC/HistoryLine|||dev=14w27a|Added CommandStats NBT tag to command blocks.}} | ||
|{{HistoryLine||1.8.6|[[Minecraft:Dispenser]]s no longer place command blocks, due to security concerns.<ref>https://bugs.mojang.com/browse/MC-80671?focusedCommentId=228546&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-228546</ref>}} | |{{MC/HistoryLine||1.8.6|[[Minecraft:Dispenser]]s no longer place command blocks, due to security concerns.<ref>https://bugs.mojang.com/browse/MC-80671?focusedCommentId=228546&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-228546</ref>}} | ||
|{{HistoryLine||1.9|dev=15w33a|The character limit for command blocks is now 32,500 instead of 32,767.}} | |{{MC/HistoryLine||1.9|dev=15w33a|The character limit for command blocks is now 32,500 instead of 32,767.}} | ||
|{{HistoryLine|||dev=15w34a|[[File:Chain Command Block JE1.png|32px]] [[File:Repeating Command Block JE1.png|32px]] Added the chain command block and the repeating command block. | |{{MC/HistoryLine|||dev=15w34a|[[File:Chain Command Block JE1.png|32px]] [[File:Repeating Command Block JE1.png|32px]] Added the chain command block and the repeating command block. | ||
|Added block facing for command blocks. | |Added block facing for command blocks. | ||
|[[File:Impulse Command Block JE2.png|32px]] The texture of command blocks has been changed.}} | |[[File:Impulse Command Block JE2.png|32px]] The texture of command blocks has been changed.}} | ||
|{{HistoryLine|||dev=15w34b|Added Conditional mode within command blocks. | |{{MC/HistoryLine|||dev=15w34b|Added Conditional mode within command blocks. | ||
|Added tab completion support within command blocks.}} | |Added tab completion support within command blocks.}} | ||
|{{HistoryLine|||dev=15w35a|[[File:Impulse Command Block JE3 BE1.png|32px]] [[File:Chain Command Block JE2 BE1.png|32px]] [[File:Repeating Command Block JE2 BE1.png|32px]] The textures of all three command blocks have been changed. | |{{MC/HistoryLine|||dev=15w35a|[[File:Impulse Command Block JE3 BE1.png|32px]] [[File:Chain Command Block JE2 BE1.png|32px]] [[File:Repeating Command Block JE2 BE1.png|32px]] The textures of all three command blocks have been changed. | ||
|[[File:Conditional Impulse Command Block JE1 BE1.png|32px]] [[File:Conditional Chain Command Block JE1 BE1.png|32px]] [[File:Conditional Repeating Command Block JE1 BE1.png|32px]] When command blocks are set to conditional, the back of the arrow texture is now curved. | |[[File:Conditional Impulse Command Block JE1 BE1.png|32px]] [[File:Conditional Chain Command Block JE1 BE1.png|32px]] [[File:Conditional Repeating Command Block JE1 BE1.png|32px]] When command blocks are set to conditional, the back of the arrow texture is now curved. | ||
|Added Always active and needs [[Minecraft:redstone]] options for command blocks. | |Added Always active and needs [[Minecraft:redstone]] options for command blocks. | ||
|Added <code>auto</code> NBT tag to control [[Minecraft:redstone]] options within command blocks.}} | |Added <code>auto</code> NBT tag to control [[Minecraft:redstone]] options within command blocks.}} | ||
|{{HistoryLine|||dev=15w36a| | |{{HistoryLine|||dev=15w36a|Players are now unable to use [[Minecraft:commands]], such as {{MC/Cmd|give}}, within command blocks. | ||
|Players, who are unable to use commands, can no longer place command blocks.}} | |Players, who are unable to use commands, can no longer place command blocks.}} | ||
|{{HistoryLine|||dev=15w36d|Each command block type now appears with different colors on [[Minecraft:map]]s.}} | |{{MC/HistoryLine|||dev=15w36d|Each command block type now appears with different colors on [[Minecraft:map]]s.}} | ||
|{{HistoryLine|||dev=16w02a|Running {{ | |{{HistoryLine|||dev=16w02a|Running {{MC/Cmd|help}} in a command block now randomly uses one of various different humorous phrases as the previous output.}} | ||
|{{HistoryLine|||dev=16w04a|Running " | |{{MC/HistoryLine|||dev=16w04a|Running "Searge" as the command in the command block without a preceding "<code>/</code>" now sets the previous output to "#itzlipofutzli".}} | ||
|{{HistoryLine||1.12|dev=17w16a|Chains of command blocks no longer schedule their [[Minecraft:commands]] to be run in the ''next'' [[Minecraft:tick]]. Instead, they now execute all in the same tick they are read. This allows later [[Minecraft:block]]s in a chain to be modified via earlier blocks, allowing techniques like branching and looping, all in the same tick.}} | |{{MC/HistoryLine||1.12|dev=17w16a|Chains of command blocks no longer schedule their [[Minecraft:commands]] to be run in the ''next'' [[Minecraft:tick]]. Instead, they now execute all in the same tick they are read. This allows later [[Minecraft:block]]s in a chain to be modified via earlier blocks, allowing techniques like branching and looping, all in the same tick.}} | ||
|{{HistoryLine|||dev=17w16b|Added the game rule {{ | |{{HistoryLine|||dev=17w16b|Added the game rule {{MC/Cd|maxCommandChainLength}} to control the max length of a command block chain.}} | ||
|{{HistoryLine|||dev=17w17a|Added <code>UpdateLastExecution</code> and <code>LastExecution</code> NBT tags, which control the tracking of which tick a chain command block was last executed in.}} | |{{MC/HistoryLine|||dev=17w17a|Added <code>UpdateLastExecution</code> and <code>LastExecution</code> NBT tags, which control the tracking of which tick a chain command block was last executed in.}} | ||
|{{HistoryLine|||dev=pre6|Tab-completing | |{{MC/HistoryLine|||dev=pre6|Tab-completing command names in command blocks no longer add a <code>/</code> prefix.}} | ||
|{{HistoryLine||1.13|dev=18w21a|The rarity of command blocks, chain command blocks and repeating command blocks has been changed from "Common" to "Epic".}} | |{{MC/HistoryLine||1.13|dev=18w21a|The rarity of command blocks, chain command blocks and repeating command blocks has been changed from "Common" to "Epic".}} | ||
|{{HistoryLine|||dev=pre1|The | |{{MC/HistoryLine|||dev=pre1|The player can now tab-complete in command blocks again.}} | ||
|{{HistoryLine||1.14|dev=18w43a|[[File:Impulse Command Block JE4.png|32px]] [[File:Chain Command Block JE3 BE2.png|32px]] [[File:Repeating Command Block JE3.png|32px]] The textures of command blocks have been changed.}} | |{{MC/HistoryLine||1.14|dev=18w43a|[[File:Impulse Command Block JE4.png|32px]] [[File:Chain Command Block JE3 BE2.png|32px]] [[File:Repeating Command Block JE3.png|32px]] The textures of command blocks have been changed.}} | ||
|{{HistoryLine|||dev=18w47b|[[File:Impulse Command Block JE5 BE2.png|32px]] [[File:Repeating Command Block JE4 BE2.png|32px]] The textures of impulse and repeating command blocks have been changed.}} | |{{MC/HistoryLine|||dev=18w47b|[[File:Impulse Command Block JE5 BE2.png|32px]] [[File:Repeating Command Block JE4 BE2.png|32px]] The textures of impulse and repeating command blocks have been changed.}} | ||
|{{HistoryLine||1.19.3|dev=22w44a|Command blocks are now available in the creative inventory, but only if cheats are enabled.}} | |{{MC/HistoryLine||1.19.3|dev=22w44a|Command blocks are now available in the creative inventory, but only if cheats are enabled.}} | ||
|{{HistoryLine|||dev=22w45a|Moved 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.}} | |{{MC/HistoryLine|||dev=22w45a|Moved 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.}} | ||
|{{HistoryLine||1.20.2|dev=23w31a|The text in command blocks now scrolls when selected using {{ | |{{HistoryLine||1.20.2|dev=23w31a|The text in command blocks now scrolls when selected using {{MC/Key|shift}} and arrow keys.<ref>{{bug|MC-140646|||Fixed}}</ref>}} | ||
|{{HistoryLine||1.21.9|dev=25w35a|Added | |{{MC/HistoryLine||1.21.9|dev=25w35a|Added game rule <code>enableCommandBlocks</code>, which replaces <code>enable-command-block</code> in [[Minecraft:server.properties]].}} | ||
|{{HistoryLine|||dev=25w37a|Renamed game rule <code>enableCommandBlocks</code> to <code>commandBlocksEnabled</code>.}} | |{{MC/HistoryLine|||dev=25w37a|Renamed game rule <code>enableCommandBlocks</code> to <code>commandBlocksEnabled</code>.}} | ||
|{{HistoryLine||1.21.11|dev=25w44a|Renamed game rule <code>commandBlocksEnabled</code> to <code>command_blocks_work</code>.}} | |{{MC/HistoryLine||1.21.11|dev=25w44a|Renamed game rule <code>commandBlocksEnabled</code> to <code>command_blocks_work</code>.}} | ||
}} | }} | ||
=== ''Bedrock Edition'' === | === ''Bedrock Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|pocket}} | |{{MC/HistoryLine|pocket}} | ||
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|[[File:Impulse Command Block JE3 BE1.png|32px]] [[File:Chain Command Block JE2 BE1.png|32px]] [[File:Repeating Command Block JE2 BE1.png|32px]] Added all types of command blocks.}} | |{{MC/HistoryLine||1.0.5|dev=alpha 1.0.5.0|[[File:Impulse Command Block JE3 BE1.png|32px]] [[File:Chain Command Block JE2 BE1.png|32px]] [[File:Repeating Command Block JE2 BE1.png|32px]] Added all types of command blocks.}} | ||
|{{HistoryLine|bedrock}} | |{{MC/HistoryLine|bedrock}} | ||
|{{HistoryLine||1.8.0|dev=beta 1.8.0.8|Command blocks now have a default name of <code>!</code> instead of <code>@</code>.}} | |{{MC/HistoryLine||1.8.0|dev=beta 1.8.0.8|Command blocks now have a default name of <code>!</code> instead of <code>@</code>.}} | ||
|{{HistoryLine||1.10.0|dev=beta 1.10.0.3|[[File:Impulse Command Block JE5 BE2.png|32px]] [[File:Chain Command Block JE3 BE2.png|32px]] [[File:Repeating Command Block JE4 BE2.png|32px]] The textures of command blocks have been changed.}} | |{{MC/HistoryLine||1.10.0|dev=beta 1.10.0.3|[[File:Impulse Command Block JE5 BE2.png|32px]] [[File:Chain Command Block JE3 BE2.png|32px]] [[File:Repeating Command Block JE4 BE2.png|32px]] The textures of command blocks have been changed.}} | ||
|{{HistoryLine||1.12.0|dev=beta 1.12.0.2|Tab-complete has been added to command blocks. | |{{MC/HistoryLine||1.12.0|dev=beta 1.12.0.2|Tab-complete has been added to command blocks. | ||
|Added a delay option to command blocks, which allows a delay to be added to a | |Added a delay option to command blocks, which allows a delay to be added to a redstone tick delay field.}} | ||
|{{HistoryLine||1.20.70|dev=Preview 1.20.70.22|Command Block no longer drops itself when breaking.}} | |{{MC/HistoryLine||1.20.70|dev=Preview 1.20.70.22|Command Block no longer drops itself when breaking.}} | ||
}} | }} | ||
=== Legacy Console Edition === | === Legacy Console Edition === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|console}} | |{{MC/HistoryLine|console}} | ||
|{{HistoryLine||xbox=TU19|xbone=CU7|ps3=1.12|psvita=1.12|ps4=1.12|wiiu=Patch 1|switch=1.0.1|[[File:Impulse Command Block JE1.png|32px]] Added command blocks. | |{{MC/HistoryLine||xbox=TU19|xbone=CU7|ps3=1.12|psvita=1.12|ps4=1.12|wiiu=Patch 1|switch=1.0.1|[[File:Impulse Command Block JE1.png|32px]] Added command blocks. | ||
|Command blocks do not have any functionality and can be obtained only with mods.}} | |Command blocks do not have any functionality and can be obtained only with mods.}} | ||
|{{HistoryLine||xbox=?|xbone=?|ps3=?|psvita=?|ps4=?|wiiu=?|switch=?|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.}} | |{{MC/HistoryLine||xbox=?|xbone=?|ps3=?|psvita=?|ps4=?|wiiu=?|switch=?|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.}} | ||
}} | }} | ||
=== Data history === | === Data history === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{MC/HistoryLine|java}} | ||
|{{HistoryLine||1.11|dev=16w32a|The [[Minecraft:block entity]] ID has been changed from <code>Control</code> to <code>command_block</code>.}} | |{{MC/HistoryLine||1.11|dev=16w32a|The [[Minecraft:block entity]] ID has been changed from <code>Control</code> to <code>command_block</code>.}} | ||
|{{HistoryLine||1.13|dev=17w47a|Prior to | |{{MC/HistoryLine||1.13|dev=17w47a|Prior to ''The Flattening'', the numeral IDs for the command block, repeating command block, and chain command block were 137, 210, and 211, respectively.}} | ||
}} | }} | ||
== Issues == | == Issues == | ||
{{Issue list}} | {{MC/Issue list}} | ||
== Gallery == | == Gallery == | ||
=== Mojang images === | === Mojang images === | ||
<gallery> | <gallery> | ||
Command Block GUI (Bedrock Edition).png|The command block GUI {{ | Command Block GUI (Bedrock Edition).png|The command block GUI {{MC/In|be}} pre 1.12.0 | ||
1.4.2 Dev Command Block.png|The first image released by | 1.4.2 Dev Command Block.png|The first image released by jeb_ of the command block. | ||
1.4.2 Dev Command Block 2.png|The second image released by jeb_ showing the block giving [[Minecraft:glass]] to the player. | 1.4.2 Dev Command Block 2.png|The second image released by jeb_ showing the block giving [[Minecraft:glass]] to the player. | ||
Command Block Recursion.gif|Command blocks creating more command blocks. | Command Block Recursion.gif|Command blocks creating more command blocks. | ||
Command Block Particles.png|A command block summoning block breaking particles. | Command Block Particles.png|A command block summoning block breaking particles. | ||
Command Block Cube.png|Command blocks in a terracotta cube. | Command Block Cube.png|Command blocks in a terracotta cube. | ||
Command Block Texture Reveal.png|The new command block texture as revealed by | Command Block Texture Reveal.png|The new command block texture as revealed by Searge on twitter. | ||
Command Block Ultra High Resolution Screenshot.png|"Ultra high resolution" teaser image from Searge showing new command blocks. | Command Block Ultra High Resolution Screenshot.png|"Ultra high resolution" teaser image from Searge showing new command blocks. | ||
New Command Blocks.png|The back of each command block type in 12w32a. | New Command Blocks.png|The back of each command block type in 12w32a. | ||
| Line 415: | Line 415: | ||
Too Many Eggs.png|A bunch of eggs being summoned with a command block. | Too Many Eggs.png|A bunch of eggs being summoned with a command block. | ||
New Command Block Variants.png|Each of the command block types in each mode of operation. | New Command Block Variants.png|Each of the command block types in each mode of operation. | ||
Searge Command Block.jpg | Searge Command Block.jpg|Searge holding a command block in front of a command block. | ||
</gallery> | </gallery> | ||
| Line 421: | Line 421: | ||
<gallery> | <gallery> | ||
File:Command Block IRL.jpg|A command block hooked up to real circuit boards | File:Command Block IRL.jpg|A command block hooked up to real circuit boards | ||
File:MCSM Command Block.webp|A | File:MCSM Command Block.webp|A command block as it appears in ''Minecraft: Story Mode'' | ||
File:CommuniKate's command block.png| | File:CommuniKate's command block.png|CommuniKate with a command block | ||
</gallery> | </gallery> | ||
== References == | == References == | ||
{{Reflist}} | {{MC/Reflist}} | ||
== External links == | == External links == | ||
*{{Mcnet|block-week-command-block|Block of the Week: Command Block|April 27, 2018| | *{{Mcnet|block-week-command-block|Block of the Week: Command Block|April 27, 2018|Duncan Geere}} | ||
*{{Mcnet|exploring-commands|Exploring Minecraft Commands|September 11, 2021| | *{{Mcnet|exploring-commands|Exploring Minecraft Commands|September 11, 2021|Riley Manns}} | ||
*{{Mcnet|minecraft-commands|How to Use Commands in Minecraft|September 22, 2023| | *{{Mcnet|minecraft-commands|How to Use Commands in Minecraft|September 22, 2023|Duncan Geere}} | ||
*[https://help.minecraft.net/hc/en-us/articles/360058742632-What-are-Command-Blocks-in-Minecraft What are Command Blocks in Minecraft?] – | *[https://help.minecraft.net/hc/en-us/articles/360058742632-What-are-Command-Blocks-in-Minecraft What are Command Blocks in Minecraft?] – Minecraft Help Center | ||
== Navigation == | == Navigation == | ||
{{Navbox redstone|components}} | {{MC/Navbox redstone|components}} | ||
{{Navbox blocks|creative}} | {{MC/Navbox blocks|creative}} | ||
[[Category:Mechanisms]] | [[Category:Mechanisms]] | ||
| Line 444: | Line 444: | ||
[[Category:Readable by comparators]] | [[Category:Readable by comparators]] | ||
cs:Příkazový blok | |||
de:Befehlsblock | |||
es:Bloque de comandos | |||
fr:Bloc de commande | |||
it:Blocco comandi | |||
ja:コマンドブロック | |||
ko:명령 블록 | |||
nl:Opdrachtblok | |||
pl:Blok poleceń | |||
pt:Bloco de Comando | |||
ru:Командный блок | |||
th:บล็อกคำสั่ง | |||
uk:Командний блок | |||
zh:命令方块 | |||
Latest revision as of 20:07, 9 April 2026
Template:Hatnote Template:Infobox block A command block is an indestructible Minecraft:block that can execute Minecraft:commands. Because it cannot be obtained, destroyed or used in Survival mode without cheats, it is primarily used in multiplayer servers, Creative worlds, and custom maps. There are 3 types of these blocks.
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 Minecraft:tick as long as it is activated.
Obtaining
in Template:Editions, command blocks are available in the Minecraft: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 various Minecraft:commands, such as
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr, or by pressing the {{#vardefine: control | middle click on mouse }}pick block control on an existing command block. Just like other blocks that can store NBT data, using {{#vardefine: control | middle click on mouse }}pick block +
- REDIRECT Template:Keys
Template:Redr 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 Minecraft:bedrock. Command blocks, structure blocks, and jigsaw blocks cannot be mined in Survival.
Usage
{{#vardefine:params|2 }}Template:Hatnote
A command block can execute commands when activated by redstone power. It always has permissions of level 2Template:Only/level 1Template: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
- REDIRECT Template:Command
Template:Redr 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 Template:Editions the game rule command_blocks_work must be set to true; in Template:Editions "Command Blocks Enabled" in world options must be enabled.
Command blocks can only be placed or broken by an operator player in Creative mode.
Modification
To enter command or modify the command block, use the {{#vardefine: control | right click on mouse or left trigger on gamepad }}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"Template:Only or "Activate Cheats"Template:Only in world options must be enabled. In Minecraft:multiplayer, GUI can be opened only by operators in Creative mode, and in Template:Editions op-permission-level in the Minecraft:server.properties file must be set to 2 or above (default is 4).
in Template:Editions to enter command or modify the command block, enable-command-block in the Minecraft:server.properties file must be set to true (default is false).
in Template:Editions, opening the GUI in singleplayer pauses the game.
- Console CommandTemplate:Only/Command InputTemplate: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
- REDIRECT Template:Keys
Template:Redr to complete words or cycle through options.
- in Template:Editions, below the console command text pane are some reminder tips about how to use Minecraft:target selectors.
- Previous Output
- The bottom text pane displays the output message (success or failure) of the last executed command (it is blankTemplate:Only or "
-"Template:Only initially). Its text is not editable.
- A button to the right of the Previous Output text paneTemplate:Only or the left of the "Previous Output"Template:Only specifies whether the last output should be stored and displayed. It is
OTemplate:Only/enabledTemplate:Only when the output text should be stored andXTemplate:Only/disabledTemplate: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
sendCommandFeedbackis true (the default), default toOTemplate:Only/enabledTemplate:Only. Otherwise defaults toXTemplate:Only/disabledTemplate:Only.
- Block Type
Middle: "Chain" block type.
Right: "Repeating" block type.
Top: "Unconditional" mode.
Bottom: "Conditional" mode.
- Click the "Impulse/Chain/Repeat" buttonTemplate:Only/"Block Type:" dropdown menuTemplate:Only 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 cyan. 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 Minecraft:tick (or moreTemplate:Only) as long as they are activated.
- Condition
- Click the "Conditional/Unconditional" buttonTemplate:Only/"Condition:" dropdown menuTemplate:Only 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" buttonTemplate:Only/"Redstone:" dropdown menuTemplate:Only 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 TickTemplate: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 TicksTemplate: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 NoteTemplate: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 Template:Editions, click the "Done" button or
- REDIRECT Template:Keys
Template:Redr to save the command and leave the command block GUI.
- in Template:Editions, close the GUI to save the command and changes.
- Cancel
- Click the "Cancel" button or
- REDIRECT Template:Keys
Template:RedrTemplate:Onlyto leave the command block GUI without saving any changes.
Activation
Command blocks are redstone mechanisms and can be activated by:
- An adjacent active power component: for example, a Minecraft:lever, a block of redstone, a daylight sensor, a Minecraft:button etc.
- An adjacent powered block (for example, an opaque block with an active redstone torch under it)
- A powered redstone comparator or redstone repeater facing the mechanism component
- Powered redstone dust configured to point at the command block (or on top of it) or directionless; a command block is not activated by adjacent powered redstone dust that is configured to point away from it.
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 moreTemplate: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 moreTemplate: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 Template:Editions, 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 moreTemplate: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 Template:Editions, 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 moreTemplate: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).
- 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 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 Template:Editions, 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.
- 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.
in Template:Editions, 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 Template:Editions, success count is usually 0 or 1, except for
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
- in Template:Editions, 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 Template:Editions, leaving the command block GUI by clicking "Done" or pressing
- REDIRECT Template:Keys
Template:Redr resets the success count to 0, regardless of whether changes were made in the GUI. in Template:Editions, 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
- REDIRECT Template:Command
Template:Redr. Some commands may write additional text to the chat as their normal function, which won't be suppressed (for example, the
- REDIRECT Template:Command
Template:Redr 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
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
Template:Redr commands) use @ Template:Only / ! Template:Only as the player name. If the command block had been named in an Minecraft:anvil before placement, that name is used instead. in Template:Editions, it can also modified in the GUI.
- Logs: The output message is written to multiplayer server logs unless it has been suppressed with
- REDIRECT Template:Command
Notes
Command blocks execute commands with OP level 2. The following commands cannot be used in a command block:
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr, and
- REDIRECT Template:Command
Template:Redr (i.e.,
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr, and all of the multiplayer-only commands except
- REDIRECT Template:Command
Easter eggs
{{#vardefine:params|0 }}Template:Hatnote
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 Minecraft:pistons. They also cannot be pushed or pulled by sticky pistons.
Sounds
Data values
ID
Template:!((Java EditionTemplate:))!: Template:ID table Template:ID table Template:ID table Template:ID table
Template:!((Bedrock EditionTemplate:))!: Template:ID table Template:ID table Template:ID table Template:ID table
Block states
{{#vardefine:params|0 }}Template:Hatnote
- REDIRECT Template:Edition
Template:Rcat: Template:Bst Template:Bst
- REDIRECT Template:Edition
Template:Rcat: Template:Bst Template:Bst
Block data
A command block has a block entity associated with it that holds additional data about the block.
- REDIRECT Template:Edition
Template:Rcat: {{#vardefine:params|0 }}Template:Hatnote
<section begin="block data"/>
- Template:Nbt/sprite Block entity data
- Template:Nbt inherit
- Template:Nbt inherit
- Replaces the usual '@' when using commands such as
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
- Template:Nbt/sprite auto: 1 or 0 (true/false) - Allows to activate the command without the requirement of a redstone signal.
- Template:Nbt/sprite Command: The command to issue to the server.
- Template:Nbt/sprite 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.
- Template:Nbt/sprite LastExecution: stores the tick a chain command block was last executed in.
- Template:Nbt/sprite LastOutput: The last line of output generated by the command block. Still stored even if the game rule
- REDIRECT Template:Code
- REDIRECT Template:Code
Template:Redr. Appears in the GUI of the block when right-clicked, and includes a timestamp of when the output was produced.
- Template:Nbt/sprite powered: 1 or 0 (true/false) - States whether or not the command block is powered by redstone or not.
- Template:Nbt/sprite SuccessCount: Represents the strength of the analog signal output by redstone comparators attached to this command block.
- Template:Nbt/sprite 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.
- Template:Nbt/sprite 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.
<section end="block data"/>
- REDIRECT Template:Edition
History
{{#vardefine:params|0 }}Template:Hatnote
Announcement
Java Edition
Bedrock Edition
Legacy Console Edition
Data history
Issues
Script error: No such module "Issue list".
Gallery
Mojang images
-
The command block GUI in Template:Editions pre 1.12.0
-
The first image released by jeb_ of the command block.
-
The second image released by jeb_ showing the block giving Minecraft:glass to the player.
-
Command blocks creating more command blocks.
-
A command block summoning block breaking particles.
-
Command blocks in a terracotta cube.
-
The new command block texture as revealed by Searge on twitter.
-
"Ultra high resolution" teaser image from Searge showing new command blocks.
-
The back of each command block type in 12w32a.
-
Each command block type placed in a wall.
-
A bunch of eggs being summoned with a command block.
-
Each of the command block types in each mode of operation.
-
Searge holding a command block in front of a command block.
In other media
-
A command block hooked up to real circuit boards
-
A command block as it appears in Minecraft: Story Mode
-
CommuniKate with a command block
References
<references group="">
</references>
External links
- Template:Mcnet
- Template:Mcnet
- Template:Mcnet
- What are Command Blocks in Minecraft? – Minecraft Help Center
| |||||||
|
| |||||||
Template:Article otherTemplate:Article other
cs:Příkazový blok de:Befehlsblock es:Bloque de comandos fr:Bloc de commande it:Blocco comandi ja:コマンドブロック ko:명령 블록 nl:Opdrachtblok pl:Blok poleceń pt:Bloco de Comando ru:Командный блок th:บล็อกคำสั่ง uk:Командний блок zh:命令方块