Command Block

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:   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  to   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, as they are tile entities.The maximum command length is limited to 254 characters (removed in the new snapshot).

Usage
The Command Block can execute some useful commands, such as giving items or experience to a player.

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. 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 or.

For innovative, practical uses of the Command Block, view Tutorials/Command Block.

Examples
If you don't want to target a specific player, you can use,  , or   instead of
 * It is possible to make teleporters using the command block. (e.g. code: )
 * 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:   This would teleport the player 8 blocks into the air).
 * Commands using coordinates (e.g. or ) 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 and,  and  commands.
 * The commands, , and will 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.

Game Rules
Game Rules allow players and command blocks to adjust several base settings.

Usage:

Disabled or Unavailable Commands
The following commands cannot be used in a command block for various reasons:

* Some commands, such as,  , and   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.

Arguments
After using a target (,  or  ) 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.

Example:

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,  may be used to select the farthest player instead of the nearest one.