|Tile Entity ID||
dec: 137 hex: 89 bin: 10001001
The Command Block is a block made with the intent to support Adventure mode and allows mapmakers to expand the interaction with the player through server commands. The block can run specified server commands when activated by a redstone current. Considering its great power and possibilities, it can't be normally crafted. It is not available in the creative mode inventory either. Only players with sufficient privileges to use the 'give' command:
/give <playername> command_block can obtain the block. Furthermore, only players which are in Creative mode and are also an operator on the server are able to edit and successfully save the command of the block. To be able to use this block in multiplayer, you have to set the value of
true in the server.properties file. If this line doesn't exist, you'll have to add it. It is not possible to break Command Blocks in Survival Mode, and explosions do not damage them in any mode. They can't be pushed by pistons, but can be destroyed by EnderDragons.
To change the command executed by the block, simply right-click it, and the GUI will open.
In place of player names, it is possible to use multiple different variables:
Comparators can be used to determine whether or not a command block's command succeeded, as well as the number of times it has succeeded in a single execution. More information on this behavior can be found here, and command success criteria can be found in the Command article.
When using commands, treat them as if entered from the console - you always need to specify the target, so it is not possible to use commands such as "kill" which do not take a player argument. For example, to change the mode to Survival for the nearest player type
/gamemode survival @p. Note that you will have to be in Creative mode to change the command associated with the block.
The command block sends commands through the console in singleplayer and multiplayer, though commands can still be prefixed with a "/". If you want to give the nearest player stone, you can enter
/give @p 1 or
give @p 1.
For innovative, practical uses of the Command Block, view Tutorials/Command Block.
- It is possible to make teleporters using the command block. (e.g. code:
tp @p x y z)
- If you use the teleport command with the command block, you can use relative coordinates in the destination coordinates by placing an
~in front of a Coordinate (e.g. code:
tp @p ~0 ~8 ~0This would teleport the player 8 blocks into the air).
- Commands using coordinates (e.g.
/spawnpoint) add 0.5 to whole numbers, like usual. To clarify, the number -33 would be interpreted as -32.5, and the number 187 would be interpreted as 187.5. Values with decimal places (25.3, 90.0) after them are left as-is.
- The player can make a kind of world guard using the command block. (e.g. code:
- The commandBlockOutput gamerule does not affect the command block using the
- The commands
/say Hello, @p,
/tell @p hello, @p, and
/me Hello, @pwill cause the command block to say user name of the nearest player in the message.
- You can also clear players inventories, to prevent griefing and/or cheating.
/clear <playername> [item]
If you don't want to target a specific player, you can use
@r instead of
 Game Rules
Game Rules allow players and command blocks to adjust several base settings.
/gamerule <gamerule> <true/false>
|commandBlockOutput||Enables/disables text output of command block commands to console|
|doDaylightCycle||Enables/disables day/night cycle|
|doFireTick||Enables/disables fire updates (no fire spread or dissipation)|
|doMobLoot||Enables/disables mob drops|
|doMobSpawning||Enables/disables the spawning of mobs (with the exception of spawn eggs and mob spawners)|
|doTileDrops||Enables/disables blocks dropping items when broken (includes TNT destroying blocks)|
|keepInventory||Enables/disables keeping inventory on death|
|mobGriefing||Enables/disables creepers, ghasts, and Wither blowing up blocks, endermen picking up blocks, zombies breaking doors, and certain mobs picking up weapons/armor|
|naturalRegeneration||Allows/Disallows player to naturally regenerate health (if their hunger bar is high enough)|
The following commands cannot be used in a command block for various reasons:
|Category||Reason for Unavailability||Commands|
|Disabled for server security||These commands are likely disabled due to limited use in command blocks and the potential for severe, unintended consequences on servers.||ban, ban-ip, deop, kick, op, pardon, pardon-ip, save-all, save-off, save-on, stop, whitelist add/remove/on/off/reload, debug, publish|
|Disabled for unknown reasons||These commands do not bear unintended consequences, but still fail in command blocks.||banlist, whitelist list|
|Unavailable to console||These commands require a player to be the executor*.||kill|
|Available, but no apparent effect||These commands output messages to their user only, not to public chat.||help, seed, list, scoreboard objectives/players/teams list|
*Some commands, such as
/say would be expected to require a player as the executor, but work in command blocks and the server console. The command block's "name" defaults to "@", but can be renamed with an anvil.
After using a target (
@r) you can optionally use arguments. This is how you use the arguments:
NOTE: Make sure you do NOT add a space between arguments or commas.
|x||X coordinate for the search center. Note, this cannot be a decimal value.|
|y||Y coordinate for the search center. Note, this cannot be a decimal value.|
|z||Z coordinate for the search center. Note, this cannot be a decimal value.|
|r||Maximum search radius.|
|rm||Minimum search radius.|
|m||A player's game mode. -1=All, 0=Survival, 1=Creative, 2=Adventure|
|c||Number of players. If negative, uses players from the end of the list first.|
|l||Maximum experience level of players.|
|lm||Minimum experience level of players.|
|score_name||For the objective "name", the maximum score this player has.|
|score_name_min||For the objective "name", the minimum score this player has.|
|team||Checks if player is in the specified team. Inserting an '!' before the team name checks only for players not on this team. Providing no team name allows for checking for all players without a team.|
|name||Checks for players with this name. Using
Alternatively, the coordinates and maximum (but not minimum!) radius can be provided more concisely as long as they're the first (up to four) arguments without keys, for instance:
is identical to the previous example.
Because the argument 'c' uses players from the end of a list first when negative,
@p[c=-1] may be used to select the farthest player instead of the nearest one.
|27 July 2012|
|Jeb 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 will be able to do.|
|31 July 2012|
|During Notch's AMA he hinted the block may be in 1.4.|
|1.4.2||12w32a||Added Command Block, plus a number of new commands for the block to use.|
|12w38a||Target parameters upgraded, allowing for more details of how, where and who the command acts on. See https://gist.github.com/3736487 for further details.|
|12w39b||Added more target parameters: l for maximum player level, lm for minimum player level and rm for minimum range.|
|1.5||13w03a||Added more command block functionality by introducing the /testfor command and outputting a comparator signal when a command is run successfully.|
|13w04a||Command blocks renamed with an anvil now use their name instead of @ in the chat.|
|Added a new command feature - "scoreboard"|
|13w05a||Added a new argument - "teams"|
|1.6.1||13w19a||Command Blocks are no longer mineable in survival, and are also not damaged by explosions, similar to bedrock. However, Command Blocks can still be damaged by the explosions of Blue Wither Skulls (Is this a bug?).|
|13w23a||Added a new command/feature - "spreadplayers"|
|Added a bar that shows the previous output.|
|Three new commands:
|13w39a||Added Minecart with Command Block.|
|13w43a||Added a new command:
Issues relating to "Command Block" are maintained on Mojira. Report issues there.
The first image released of the Command Block.
The Minecart with Command Block item, in snapshot 13w39a.