Tutorials/Command blocks and functions

The Command Block is a new block that was introduced in 12w32a and will be officially released in Minecraft 1.4. It was introduced as a way to help support Adventure Mode and custom maps.

To find out more in detail, visit the Command Block page.

Singleplayer Applications (SSP)
Command blocks can be used in single player to change the difficulty, change the state of the weather, or give you predesignated items. They are particularly useful for the /downfall and /set time x commands, as they are only available in cheat mode otherwise. The /set time x command is especially useful, as it allows one to change the current time to a preset time at the press of a button.

Multiplayer Applications (SMP)
This section details the applications of the Command Block in multiplayer.

Through, one can create teleporters for public use on a server. Can be applied to a range of scenarios. For example, one could make a system of portals in a particularly large world in which all portals link to a central hub, which contains portals to all other portal locations creating a sort of "Fast Travel Hub"
 * Teleportation/Transport

Through, one can create a lottery. Keep in mind that in the most recent snapshot,  will directly put items into one's inventory, instead of throwing them on the ground in front of the character.
 * Lottery

By using  a whole bunch, you can force a player to stay at a certain place. If you do this it would be advisable to either turn off commands in your chat settings or do.
 * Jails

By using the parameter, only players in Creative will be affected by the command block. Hopefully only ops are in Creative on your server.
 * Admin Only

By using  in a command block one can create announcements that could play even when the admin/owner wasn't there.
 * Announcements

By using, you can scan people for items. If you want to remove certain items, use. For example, on a server that doesn't want griefing you could have a clock connected to a command block set to.
 * Security Scan

Using, the command block can report the nearest player. If the command block is placed after a finish line, it will say the finishers in order.
 * Race Referee

Creating a "Creative Only" zone is possible through command blocks, but it is complex and more of a case-by-case basis. The basic idea would be to create a "fence" of command block affected zones so that, once a player flies in creative though it, they would be changed to survival or adventure mode. A "World Guard" zone would be a lot simpler, just have a command block do. To prevent people pressing the button a second time and again getting their kit you can make two command blocks activated in order: 1.
 * Creative Area/World Guard

Although you are not directly able to obtain colored/bold/italic text when typing into the Command Block GUI, through McEdit filters you can edit the text to have those properties just like how plug=ins change chat text properties on servers. SethBling's McEdit Filter: ColorCommandBlockText
 * Special Colorful Words

When a player walks over a pressure plate, it can trigger a command block with /say @p
 * Alarm System

Using coordinate and maximum parameters you can teleport everyone within a specific area to another specific area.
 * Remove Players

If a certain player has been very nice,regular,or helpful to the sever but not quite meeting the requirements to be promoted to an admin, you could have a room full of buttons connected to Command Blocks with helpful effects, like giving the helpful player a stack of diamonds or a bedrock block, then have it connected to another command block, sending them to the spawn point. (It is VERY important this room is reinforced with bedrock, hidden, and you can only get in by teliporting to its co-ordanates to avoid abuse).
 * Reward Room

Application in Custom Maps
This section details the applications of the Command Block in custom maps.

One map that takes advantage of a lot of the features of the Command Block is SethBling's TF2 Map "Dustbowl" in Minecraft. Video:[ http://www.youtube.com/watch?v=_f2brU8hBWc&feature=plcp]

Using pressure plates or tripwire, make areas (like a castle for instance) a different difficulty (for this instance I will use peaceful). the doors could have tripwire hooked to a command block that changes ones difficulty to peaceful, creating a sort of "Safe Haven". one could also do it the other way around, creating a more dangerous zone, such as arenas having the difficulty of hard, rather than normal or easy.
 * Safe Haven/Arena Fight Zone

Using parameter [m=1], you can affect those who are in Creative, or survival with parameter [m=0].
 * Detecting Cheaters

This is a simple one, just have a system of tp-ing command blocks at the entrence/exit of a place, and you can build the interior somewhere else, allowing you to cheat space restriction. (example of use: you want interior walls to be wool, but exterior walls to be wood (normally 2m thick walls). You can make the outside of the house be 8x10 m, and the inside of the house be 8x10 m.)
 * It's bigger on the inside

Related Pages

 * Command Block
 * Multiplayer
 * Adventure Mode

Ideas
This section details some ideas that you may submit to this section via editing. Please add ideas as you wish!

1. Use the me command, command blocks can dump custom map related flavour directly into the player's chat box. This can be combined with repeaters to give delays or make sure all the text arrives in order.

2. XP for Item Shops. Use give command in combination with a filter to exchange XP for Items. Inspired by MrABgaming and SethBling.

Two Command blocks stacked, with a repeater on a single block.

Top Block Command code: xp -1l @p[lm=5]

Bottom Block Command code give @p[lm=5] 256 1

This gives an Iron Shovel for 1 xp level, provided you have a minimum of 5 levels.

example video: http://www.youtube.com/watch?v=ZDlyLi6ztSg
 * admins, please review, many thanks

3.

4.