|Tile Entity ID||
dec: 137 hex: 89
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. Currently, it is not available in the creative mode inventory either. Only players with sufficient privileges to use the 'give' command:
/give <player_name> 137 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. In survival mode, command blocks can be broken instantly, even without a tool, but will only drop as an item when mined with a pickaxe. They can't be pushed by pistons, as they have tile entities. The maximum command length is limited to 254 characters.
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[r=3] 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 (eg. "/tp" or "/spawnpoint") add 0.5 to integers, like usual. To clarify, the number -33 would be interpreted as -32.5, and the number 187 would be interpreted as 187.5.
- The player can make a kind of world guard using the command block. (e.g. code:
/gamemode <gamemode> @a[r=<radius>])
- The commandBlockOutput gamerule does not affect the command block using the
- The commands
/say Hello, @pand
/tell @p Hello, @pwill cause the command block to say user name of the nearest player in the message, however
/me Hello, @pjust causes it to say "Hello, @p".
 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|
|doFireTick||Enables/disables fire spread|
|doMobLoot||Enables/disables mob drops|
|doMobSpawning||Enables/disables the spawning of mobs unless you want them to (excl: eggs and mob spawners will still spawn mobs)|
|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 and zombies breaking doors|
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.|
|y||Y coordinate for the search center.|
|z||Z coordinate for the search center.|
|r||Maximum search radius.|
|rm||Minimum search radius.|
|m||A player's game mode. 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. Inserting an '!' before the name checks only for players who do not have this name.|
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||13w19a||Command Blocks are no longer mineable in survival, and are also not damaged by explosions, similar to bedrock.|
Issues relating to "Command Block" are maintained on Mojira. Report issues there.
The first image released of the Command Block.