Minecraft Wiki

The Minecraft Wiki is no longer considered as official by Microsoft and therefore several changes are required to be made, including to the wiki's logo. Please read this announcement for more information.

READ MORE

Minecraft Wiki
(moved see link into text)
(→‎Raw JSON Text: In the code, "value" is only used if MinecraftServer == null. Can anybody confirm whether that's even possible in vanilla? Nevertheless, the game does go through the trouble of reading it as a valid property.)
Line 826: Line 826:
 
<div class="treeview">
 
<div class="treeview">
 
* {{nbt|compound}} The base chat component Object
 
* {{nbt|compound}} The base chat component Object
** {{nbt|string|text}}: A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names, you will need to use 'selector'.
+
** {{nbt|string|text}}: A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names; use '''selector''' instead.
** {{nbt|string|selector}}: Selectors (@p,@a,@r,@e) are translated into their respective entity names and displayed as raw text in chat. Supports selector arguments.
 
 
** {{nbt|list|extra}}: A list of additional objects, sharing the same format as the base object.
 
** {{nbt|list|extra}}: A list of additional objects, sharing the same format as the base object.
 
*** {{nbt|compound}} A list element with the same format as the base object (recursive). Note that all properties of this object are inherited by children except for '''text''', '''extra''', '''translate''', '''with''', and '''score'''. This means that children will retain the same formatting and events as this object unless they explicitly override them.
 
*** {{nbt|compound}} A list element with the same format as the base object (recursive). Note that all properties of this object are inherited by children except for '''text''', '''extra''', '''translate''', '''with''', and '''score'''. This means that children will retain the same formatting and events as this object unless they explicitly override them.
Line 853: Line 852:
 
*** {{nbt|string|name}}: The name of the player whose score should be displayed. Selectors (such as @p) cannot be used, but "fake" player names created by the scoreboard system can be used. In addition, if the name is "*", it will show the player's own score (for example, <code>/tellraw @a {score:{name:"*",objective:"obj"}}</code> will show every online player their own score in the "obj" objective).
 
*** {{nbt|string|name}}: The name of the player whose score should be displayed. Selectors (such as @p) cannot be used, but "fake" player names created by the scoreboard system can be used. In addition, if the name is "*", it will show the player's own score (for example, <code>/tellraw @a {score:{name:"*",objective:"obj"}}</code> will show every online player their own score in the "obj" objective).
 
*** {{nbt|string|objective}}: The internal name of the objective to display the player's score in.
 
*** {{nbt|string|objective}}: The internal name of the objective to display the player's score in.
  +
*** {{nbt|string|value}}: Optional. A default value for the score. May never be used, however: although the game reads this value, it will be overwritten by the correct score or "?" when displayed.
  +
** {{nbt|string|selector}}: A string containing a selector (@p,@a,@r, or @e) and, optionally, selector arguments. Unlike '''text''', the selector will be translated into the correct player/entity names. If more than one player/entity is detected by the selector, it will be displayed in a form such as 'Name1 and Name2' or 'Name1, Name2, Name3, and Name4'. Ignored completely if '''text''', '''translate''', or '''score''' is present.
 
</div>
 
</div>
   
Due to the '''extra''' tag, the above format may be recursively nested to produce very complicated and functional text strings. However, a raw json string doesn't have to be complicated at all: virtually all properties are optional and may be left out.
+
Due to the '''extra''' tag, the above format may be recursively nested to produce very complex and functional text strings. However, a raw json string doesn't have to be complicated at all: virtually all properties are optional and may be left out.
   
 
To be valid, each object must have at least either '''text''', '''translate''', or '''score''' (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted for a String. In this case, that string will be considered the value of the '''text''' property. For example, <code>"This is raw text"</code> is equivalent to <code>{text:"This is raw text"}</code>. This shorthand substitution is valid anywhere a raw text object is required (including the base <''raw json message''> argument of {{cmd|tellraw}}, the elements of the '''extra''' list, and the '''value''' of a "show_text" '''hover_event''').
 
To be valid, each object must have at least either '''text''', '''translate''', or '''score''' (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted for a String. In this case, that string will be considered the value of the '''text''' property. For example, <code>"This is raw text"</code> is equivalent to <code>{text:"This is raw text"}</code>. This shorthand substitution is valid anywhere a raw text object is required (including the base <''raw json message''> argument of {{cmd|tellraw}}, the elements of the '''extra''' list, and the '''value''' of a "show_text" '''hover_event''').

Revision as of 20:53, 20 May 2014

Commands are advanced functions activated by typing certain strings of text.

In a regular Minecraft client or the stand alone client, commands are entered via Minecraft's chat window, which is displayed by pressing the T key (default) or / key. Using the / key will also enter the forward slash that commands require as a prefix, so it is a useful shortcut. Pressing Tab ↹ while entering commands cycles through possible commands or arguments.

Commands may also be entered in a multiplayer server's console, but are not preceded by a / when entered this way. Commands in command blocks can be preceded by a slash, but it is not required.

The majority of commands are only available in the following situations:

  • In a Minecraft multiplayer server game, entered by an operator or command block.
  • In other multiplayer games, entered by the player who opened a LAN game with cheats enabled, or is hosting their own multiplayer server
  • In singleplayer, if cheats were enabled at world creation (via the "More World Options..." button).

Some player commands are also available in singleplayer even when cheats are not enabled.

Note: In singleplayer worlds where cheats were not enabled at creation, they can be enabled on a temporary basis by opening the current game session to LAN play ( Esc -> "Open to LAN", then "Allow Cheats" button and "Start LAN World"). You do not actually need to be on a LAN or have others join. This is not permanent, but will allow the use of commands until you quit the world, and changes you make via commands (items spawned, etc.) will be saved with the world. You can do this each time you start playing the world again. Note that this will disable game pausing, so from then on you should get somewhere safe before using the Esc and Options screens.

Usage

Legend

In the listings below, command text is formatted as follows:

If you see... Then
<angle brackets> This is a required argument.
[square brackets] This is an optional argument.
italics Replace this with an appropriate value.
plain text Enter this literally, exactly as shown.
x|y Pick one of the options shown.

Available options are shown separated by vertical bars: |

ellipsis … The argument may consist of multiple words separated by spaces.

Target selectors

Instead of player names, it is possible to trigger multiple different targets at the same time, using the following variables:

Variable Function
@p Nearest player
@r Random player
@a All players
@e All Entities

Target selector arguments

After using a target (@a, @p, @r, or @e) you can optionally use arguments. This is how you use the arguments: @<selector>[<argument>=<value>,<argument>=<value>,...]
NOTE: Make sure you do NOT add any spaces or full stops in between the brackets.

Argument Function
x X coordinate for the search area, being the center for radial selection and the starting corner for cubic selection. Note, this must be an integer.
y Y coordinate for the search area, being the center for radial selection and the starting corner for cubic selection. Note, this must be an integer.
z Z coordinate for the search area, being the center for radial selection and the starting corner for cubic selection. Note, this must be an integer.
dx X coordinate offset of the opposite corner to define a rectangular search area. Note, this cannot be negative.
dy Y coordinate offset of the opposite corner to define a rectangular search area. Note, this cannot be negative.
dz Z coordinate offset of the opposite corner to define a rectangular search area. Note, this cannot be negative.
r Maximum search radius.
rm Minimum search radius.
rx Maximum x rotation.
rxm Minimum x rotation.
ry Maximum y rotation.
rym Minimum y rotation.
m A player's game mode. -1=All, 0=Survival, 1=Creative, 2=Adventure, 3=Spectator
c Number of targets to specify. If negative, uses targets 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 or entities with this name. Using =! instead of = checks only for players/entities who do not have this name. (Example: name=!Notch)
type Checks for entities with this entity type. (Example: type=EntityHorse) This can also be used with =! (described above).

Example: @p[x=1,y=30,z=26,r=10,rm=2,m=1,c=3,l=25,lm=3,score_Kills_min=1,score_Deaths=2,team=Red] Breakdown:

@p only specifies the nearest player.

x=1,y=30,z=26 sets the middle of the radius to x: 1, y: 30 and z: 26.

r=10 sets the (max) search radius to 10.

rm=2 sets the minimum search radius to 2.

m=1 only specifies players with gamemode 1 (creative).

c=3 specifies the three first players in the list (note: for @p, the default c is 1, unlike @e and @a).

l=25 specifies all players with xp-level 25 or less.

lm=3 specifies all players with xp-level 3 or more.

score_Kills_min=1 specifies all players with at least 1 "Kills" (score).

score_Kills=2 specifies all players with at most 2 "Kills" (score).

team=Red specifies all players in "Red" (team).


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:

@p[1,30,26,10,rm=2,m=1,c=3,l=25,lm=3,score_Kills_min=1,score_Deaths=2,team=Red]

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 (for @e[c=-1] this will select the farthest entity).

@e[type=Arrow,r=100,c=-1]

finds the farthest in the search radius (100).

If r is specified along with dx, dy and/or dz, only entities within the overlap of both search regions will be found.

Player commands

These commands can be used in the chat window by any player who is allowed to connect to a server, and can also be used in singleplayer whether or not cheats are enabled.

Command Description Success Conditions[note 1]

help [page|command name]
? [page|command name]

Shows a list of available commands or further information to the command name. Note: the multiplayer-only commands are not listed in single-player games, even when open to LAN players.

Succeeds if page is valid or no arguments are specified. Technically fails if command name is specified, although it displays the usage of the command.

me <action …>

Sends a narrative message to the other players in the form of "* Yourname action" (e.g., "* Notch sneezes." or "* Notch exploded." ). If a multi-person target selector (e.g., @a) is used in action, the list of names is formatted as "name1, name2, and name3", or "name1 and name2" for two names. Therefore, regardless of any target selectors which are used in action, this command will only output once.

All target selectors (e.g., @p) in action must evaluate.

tell <player> <private message …>
msg <player> <private message …>
w <player> <private message …>

Used to send a private message to a player on the server. Very useful on servers if you need to ask/tell something from/to another player without other players seeing. If a multi-person target selector (e.g., @a) is used in private message, the list of names is formatted as "name1, name2, and name3", or "name1 and name2" for two names. Therefore, regardless of any target selectors which are used in private message, this command will only output once - however, a selector for player can send a message to multiple people.

All target selectors (e.g., @p) in private message must evaluate, and player must be online.

trigger <objective> <add|set> <value>

Used together with /tellraw to let players activate systems made by operators or mapmakers. The objective must be an enabled scoreboard objective of the criteria "trigger". The given value is either added to its existing value, or becomes its new value, depending on whether the second argument is add or set. The value of the objective is only changed for the player who uses the command.

objective must have the "trigger" criteria and the player who is running the command must be able to modify objective.

  1. A command's Success Conditions must be met in order for the game to consider the command "successful". This is used to determine a variety of things, such as the output of a redstone comparator feeding from command block with a command. Note that not all "successful" commands actually do something, and not all "failed" commands fail to do something useful.

Operator-only commands

These commands are usable by ops (operators) from the server console as well as through the chat window when prefixed by the command character /. The results of these commands are broadcast to other ops online.

These commands are also available in singleplayer mode with enabled cheats or for players hosting a world.

Command Description Success Conditions

achievement give <stat_name> [player]

Gives a player an achievement, and all prerequisite achievements, or increment a statistic by 1. stat_name must use achievement.achievement_name, where achievement_name is a valid achievement (see Scoreboard or Achievements for valid names), or stat.statistic_name, where statistic_name is a valid statistic (see Scoreboard for valid statistics). If player is not specified, the achievement/statistic will be given to the command's executor.

stat_name must be a valid achievement/statistic name. player is not optional in command blocks and player must be online.

blockdata <x> <y> <z> <dataTag>

Edits the data tags of the block at the location x, y, z. For more information on data tags, see the Data tags section.

dataTag must be a valid argument at the block located at x, y, z.

clear <player> [item] [data] [maxCount] [dataTag]

Clears the inventory of player or the specified item:data, with the specified dataTag. Does not remove more than maxCount items. If no optional tags are specified, the entire inventory is cleared.

At least zero item(s) must be removed, and player must be online. Can output a comparator signal if successfully cleared item(s). data can be set to -1 to clear regardless of Damage value, and maxCount can be set to -1 to clear all of the selected item.

clone <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [mode]

Clones the given area. The destination is (x, y, z), where the blocks are placed going into positive coordinate values. mode can be replace (the default), which copies all blocks, or masked, which copies all non-air blocks.

The area being cloned and the area where the cloned blocks are going must both be rendered, must not overlap, and must be within the 4096 block limit (including air blocks)

debug <start|stop>

Starts a new debug profiling session or stops the session currently running. It notifies about potential performance bottlenecks in the console when active and creates a profiler results file in the folder debug when stopped.

Can only stop if a session is running. Cannot be used in a command block.

defaultgamemode <mode>

Sets the default game mode that is shown on the world selection menu. New players that join the world will be put into the default game mode; i.e., if the default game mode is creative, new players will start in creative. This command cannot enable or disable Hardcore mode.

mode must be a valid game mode: survival, creative, adventure, or spectator. The game modes can be abbreviated to "s/c/a/sp" or "0/1/2/3" respectively.

difficulty <new difficulty>

Changes the difficulty for as long as the server is running. If the server is restarted, the difficulty will go back to whatever difficulty is set in server.properties.

new difficulty must be a valid difficulty: peaceful, easy, normal, or hard. The difficulties can be abbreviated to "p/e/n/h" or "0/1/2/3" respectively.

effect <player> <effect> [seconds] [amplifier] [hideParticles]

Gives the targeted player (or entity, via the @e target selector) the specified effect for the specified time (default is 30 seconds). Effects have a limit of 1,000,000 seconds, and the amplifier field has a limit of 255. Effect id's can be found on the potion effects page. Setting seconds to 0 clears this effect. If you put the amplifier to a number of a variably high value, it will not give the desired amplifier. Setting hideParticles to true hides effect particles, if value not given, defaults to false.

If clearing an effect, the player must have this effect. effect must be a valid effect. player must be online.

effect <player> clear

Clears all effects on player (or entity, via the @e target selector).

At least one effect must be removed, and player must be online.

enchant <player> <enchantment ID> [level]

Enchants the item that the player is currently holding, according to enchantment ID. Note that this works within the normal limitations of enchanting items. Enchantments can only be applied to items which can normally receive that specific enchantment. Enchantment levels can not be above the normal highest achievable for the selected enchantment. Conflicting or overpowering enchantment combinations usually prevented are also prevented with this command.

The enchantment ID must be valid, the level must be valid for this enchantment (unless the held item is also invalid), the held item must be able to accept this enchantment, the held item cannot have conflicting enchantments, and player must be online.

execute <entity> <x> <y> <z> <command …>

Runs command as though it was executed by entity, and as though entity was located at x, y, z. The command will be run as though the entity has operator-level permission.

n/a

fill <x1> <y1> <z1> <x2> <y2> <z2> <TileName> [dataValue] [oldBlockHandling] [dataTag]

Fills the given area with a block specified by TileName, dataValue, and dataTag. oldBlockHandling mode is either destroy, keep, hollow, or outline.

  • destroy - Destroys any blocks within the target location, dropping them as item entities, and replacing them with "TileName".
  • keep - Only replaces air blocks found in the fill area with "TileName".
  • hollow - Wraps only the outer layer of the fill area, creating a square box of "TileName", and replacing all blocks inside of the box area with air.
  • outline - Wraps only the outer layer of the fill area, creating a square box of "TileName". (Leaves all blocks leftover inside the box area alone and doesn't destroy them)

A starting point and an end point must be input followed by a block. Your feet (y-value), will be the point where blocks will begin to fill. Chunks must be loaded and can only fill within a 4096 block limit (including air blocks)

fill <x1> <y1> <z1> <x2> <y2> <z2> <TileName> <dataValue> replace [replaceTileName] [replaceDataValue]

Replaces all blocks matching replaceTileName and replaceDataValue in a given area with TileName and dataValue. If replaceTileName and replaceDataValue are not given, any block will be replaced. Note that the replace operation does not support a dataTag argument.

A starting point and an end point must be input followed by a block. Your feet (y-value), will be the point where blocks will begin to fill. Chunks must be loaded and can only fill within a 4096 block limit (including air blocks)

gamemode <mode> [player]

Changes the game mode for player. If no player is given, it will set your own gamemode.

mode must be a valid game mode: survival, creative, adventure, or spectator. The game modes can be abbreviated to "s/c/a/sp" or "0/1/2/3" respectively.

player must currently be online. player is not optional for command blocks.

gamerule <rule name>
gamerule <rule name> [value]

Activates or deactivates the rule name. If value is not given, displays the current status of rule name.

Available rules are:

  • commandBlockOutput - Whether command blocks should notify admins when they perform commands
  • doDaylightCycle - Whether time progresses
  • doFireTick - Whether fire should spread and naturally extinguish
  • doMobLoot - Whether mobs should drop items
  • doMobSpawning - Whether mobs should naturally spawn
  • doTileDrops - Whether blocks should have drops
  • keepInventory - Whether the player should keep items in their inventory after death
  • logAdminCommands (upcoming) - Whether to log admin commands to server log
  • mobGriefing - Whether Creepers, Endermen, Ghasts, Withers and Villagers should be able to change blocks or zombies, skeletons, and Zombie Pigmen can pick up items
  • naturalRegeneration - Whether the player can regenerate health naturally if their hunger is full enough
  • randomTickSpeed (upcoming) - How often a random tick occurs, such as plant growth, leaf decay, etc. Can be 0 to disable random updates.
  • showDeathMessages (upcoming) - Whether a message appears in chat when a player dies

Valid value for all gamerules are true or false, except randomTickSpeed which can be 0 or any positive integer.

Succeeds in all cases - even absent/invalid rule name or a property besides true or false.

give <player> <item> [amount] [data] [dataTag]

Spawns amount (defaults to 1) of the item defined by item with the specified data (defaults to 0) at the location of player, using dataTag for the "tag" NBT tag. For example typing /give John 5 30 1 {display:{Lore:["Wooden planks"]}} will give a player called John 30 blocks of Spruce Wood Planks with Lore that says "Wooden planks".

item must be a valid ID or item name, amount must be from 0 to 64, and player must be online.

kill [player|entity]

Inflicts 1000♥ × 500 void damage to the target, killing the target instantly even if in Creative mode (a high-level Resistance effect cannot protect the player either). The text "Ouch! That looks like it hurt." will be displayed after executing. Useful when lost, stuck, or to restore health and hunger (assuming you can get your items back easily or the keepInventory gamerule is set to "true"). If player|entity is not specified, the player running the command will be killed.

The player|entity argument will be added in 1.8 and is currently available only in the snapshots.

player|entity is not optional in command blocks.

particle <name> <x> <y> <z> <xd> <yd> <zd> <speed> [count] [player|entity]

Spawns particles in a given area or at a given player/entity

n/a

playsound <sound> <player> [x] [y] [z] [volume] [pitch] [minimumVolume]

Plays the selected sound to the selected player. The value of sound is any event defined in sounds.json (for example, mob.pig.say). Note that Resource Packs may add their own events to sounds.json; the command will successfully play these. File names are not used by this command; it strictly uses the events defined in sounds.json (which may not even be similar to the original file names and paths), and thus a resource pack adding new sound files must define events for them (this is not necessary when replacing old sounds which are already in defined events). If an event contains multiple sounds, this command will select randomly between them (chances are modified by each sound's "weight" property), just as the game normally would. For example, "mob.pig.say" will play one of several pig sounds at random, because the event has multiple sounds associated with it.

The coordinates x, y, and z are the coordinates to play the sound from. If prefixed with "~", they will be relative to the player's current location. Note that "~" is shorthand for "~0", and thus "~ ~ ~" can be used as a substitute for the player's current location.

The volume argument controls the distance from which a sound may be heard. At values less than 1.0, the sound will be quieter and have a smaller sphere within which it may be heard. At values greater than 1.0, the sound will not actually grow louder, but its audible range (a 16-block radius at 1.0) will be multiplied by volume. There will always be a gradual falloff to silence based on distance from the center of the sphere.

The minimumVolume argument controls the volume of the sound for players outside its normal audible sphere. If the player is outside the normal sphere, the sound will instead be centered some short distance (<4 blocks) from the player, and minimumVolume will determine its volume.

The pitch argument alters both the pitch and the duration of the sound (which means that it's actually changing its speed).

player must be online, volume must be at least 0.0, pitch must be between 0.0 and 2.0 (inclusive), minimumVolume must be between 0.0 and 1.0 (inclusive), and the player must be able to hear the sound from where it is played.

publish

Opens your single-player game for LAN friends to join. This command appears in the singleplayer cheats.

Cannot be used in a command block.

say <message …>

Broadcasts message to all players on the server. If a multi-person target selector (e.g., @a) is used, the list of names is formatted as "name1, name2, and name3", or "name1 and name2" for two names. Therefore, regardless of any target selectors which are used, this command will only output once.

All target selectors (e.g., @p) in the message must evaluate.

scoreboard <objectives|players|teams>

See Scoreboard for more information. Scoreboard-specific commands.

Main Article

seed

Displays the seed. This command can always be used in single-player mode, regardless of whether cheats are enabled or not.

Always succeeds (if user is a command block, player in singleplayer, or server op).

setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag]

Places the block in the x, y and z coordinates specified.

TileName must exist, dataValue must exist if specified, oldBlockHandling must be either replace, keep or destroy if specified and dataTag must evaluate if specified.

setworldspawn
setworldspawn <x> <y> <z>

Sets the world's spawn to the specified coordinates. The worldspawn is where you first spawn and where you respawn if you die and your bed is missing or obstructed. If no coordinates are specified, the world spawn will be set to the executor's current location. Note that a 10 chunk (160 block) radius around the worldspawn is kept loaded at all times. However this only applies if the chunks are already loaded when it is set. Setting it to a place where no player is will NOT cause the area to load. Also compasses (which in minecraft point to the worldspawn rather than north) will not update to the change until you reload the world.

x, y, and z must be within the range -30,000,000 to 30,000,000 (inclusive). x, y, and z are not optional in command blocks.

spawnpoint
spawnpoint <player>
spawnpoint <player> <x> <y> <z>

Sets the spawnpoint of that player to that position, or to the current position if x y and z are not specified. player is optional if x y z are not specified; will set the spawnpoint of the user to their current location. NOTE: Spawnpoint coordinates must be specified in integers. No decimals.

Sleeping in a bed will also set a spawn point where the bed is, but you can only sleep in beds at night or when it rains.

player must be online, and x, y, and z must be within the range -30,000,000 to 30,000,000 (inclusive).

spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player …>

This command allows players to spread out over a long or short distance.

x and z mark the center of the area across which players are to be spread.

spreadDistance is the rough minimum distance players will be spread apart.

maxRange is the maximum distance from x, z where players will be put. Note that this distance is not a circular radius; it represents the maximum distance on either coordinate (thus forming a box ranging from x-maxRange to x+maxRange and z-maxRange to z+maxRange).

respectTeams may be true or false, and represents whether players should be moved individually or teams should be kept together.

player is the list of players to spread. Names are separated by spaces.

x and z must be within the range -30,000,000 to 30,000,000 (exclusive), spreadDistance must be at least 0, maxRange must be at least 1.0 greater than spreadDistance, and there must not be too many players to fit within the area. If maxRange is larger than 30,000,000, the command can fail with even one player if it attempts to place them outside the world boundary).

summon <EntityName> [x] [y] [z] [dataTag]

Spawns an entity. For example, to create a charged creeper named Powered Creeper at the player's current location:

/summon Creeper ~ ~ ~ {powered:1,CustomName:Powered Creeper}

x and z must fall within the range -30,000,000 to 30,000,000 (exclusive), and y must be at least 0. If coordinates aren't specified the entity will spawn at the player's location (or inside a command block if the command was executed by one).

tellraw <player> <raw json message>

Sends a JSON message to specified player(s), allowing formatting and clickable actions in chat text. Color defaults to white and all formatting (bold, italic, etc.) defaults to false.

player must be online, and the message text must be correctly coded in JSON.

testfor <player> [dataTag]

Used to test whether the given player (or entity, by the @e target selector) could be located, and whether it has all tags specified by dataTag. A redstone comparator as output from a command block with this command will indicate the number of players/entities matched by it. For example, "testfor @a[r=3]" will output the number of players within 3 meters of the command block, and "testfor @e[type=Arrow,r=3] {inGround:1b}" will output the number of arrows stuck in a block within 3 meters.

player and dataTag must be valid and match some entity if specified.

testforblock <x> <y> <z> <TileName> [dataValue] [dataTag]

Used to test whether a particular block is in the x, y and z coordinates specified. Datatags will not work unless a special syntax is used to specify what type of NBT tag is used (s for Short, b for Byte, l for Long, f for Float and d for Double). Also all relevant tags must be included even if they are unused (e.g.: Chest contents must include Slot, id, Damage, and Count.)

TileName must exist, dataValue must exist if specified, and dataTag must evaluate if specified.

testforblocks <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [mode]

Compare the blocks at two locations in cuboid regions. mode is masked or all.

n/a

time set <value>

Sets the world time. value is an integer between 0 and 24000, inclusive, where 0 is dawn, 6000 midday, 12000 dusk and 18000 midnight. value can be greater than 24000; in this case, the time of day wraps around, but the moon's phase is advanced. However, setting the time "backward" (earlier than the current time) does not change the moon. "time set day" sets the time to 1000, and "time set night" sets the time to 13000.

value must be 0 or positive, or day or night.

time add <value>

Increments the world time, as above.

value must be 0 or positive. The daytime wraps, and the moon's phase advances; adding 24000 will advance the moon's phase by one day.

title <player> clear

Removes title from player.

player must be a valid online player.

title <player> reset

Resets subtitle, fadeIn time, stay time, and fadeOut time for player.

player must be a valid online player.

title <player> subtitle <raw json title>

Sets the subtitle text for player. This is only displayed if a title is on the player's screen at the same time (can be empty).

player must be a valid online player. raw json title must be a single word of text (not delimited by curly brackets) or a valid json specification.

title <player> times <fadeIn> <stay> <fadeOut>

Sets the time in game ticks for title (and optional subtitle) to fade in, persist, and fade out, for player.

player must be a valid online player.

title <player> title <raw json title>

Sets the title text for player and shows the title (optionally, with prespecified subtitle). Titles are displayed in the middle of your screen.

player must be a valid online player. raw json title must be a single word of text (not delimited by curly brackets) or a valid json specification.

toggledownfall

Toggles rain and snow.

Always succeeds.

tp [target player] <destination player>

Teleports target player (or entity, by the @e target selector) to the location of destination player (or entity, by the @e target selector). If no player/entity is specified, it will teleport yourself.

target player is not optional in command blocks. Both players must be online.

tp [target player] <x> <y> <z> [<y-rot> <x-rot>]

Teleports target player (or entity, by the @e target selector – or yourself if no player/entity is specified) to coordinates x,y,z. Can also relatively move the player/entity by adding the ~ character before the coordinate value. For example typing /tp John ~3 64 ~3 will teleport a player called John 3 blocks away from his current x and z, and to y 64. Additionally, y-rot and x-rot may optionally be used to specify the yaw and pitch in degrees - these also accept ~.

x and z must fall within the range -30,000,000 to 30,000,000 (exclusive), and y must be at least 0. target player is not optional in command blocks, and the player must be online.

weather <clear|rain|thunder> [duration in seconds]

Changes the weather for the specified duration.

duration in seconds must be at least 1, and cannot be greater than 1,000,000, and a valid weather condition must be provided.

worldborder center <x> <z>

Sets the center of the world border.

x and z must fall within the range -30,000,000 to 30,000,000 (exclusive).

worldborder damage amount <damagePerBlock>

Sets the amount of damage inflicted per second per block past the world border buffer (defaults to 0.2). For example, if damagePerBlock is 0.1, a player 5 blocks outside the world border buffer will take 0.5 damage per second (damage less than half a heart might not change the visual health display, but will still accumulate).

damagePerBlock must be at least 0.0.

worldborder damage buffer <sizeInBlocks>

Sets the buffer distance outside the world border before damage begins to be inflicted (defaults to 5.0).

sizeInBlocks must be at least 0.0.

worldborder set <sizeInBlocks> [timeInSeconds]

Sets the diameter of the world border. sizeInBlocks is the new diameter. timeInSeconds is the number of seconds it should take for the border to move from its previous location to the new location. If timeInSeconds is not specified, the diameter changes immediately.

sizeInBlocks must fall within the range 1 to 60,000,000 (inclusive).

worldborder warning distance <blocks>

Sets the distance inside the world border where visual warning of world border proximity begins (defaults to 5).

blocks must be at least 0.

worldborder warning time <seconds>

Sets the time before a moving world border intersects the player when visual warning of the world border starts (defaults to 15). For example, if seconds is 5, players will get a visual warning when the moving world border is 5 seconds or less away from passing their position.

seconds must be at least 0.

xp <amount> [player]

Gives the specified user the given number of orbs. Maximum is 2,147,483,647 per command. Negative amounts may not be used to remove experience points.

amount can be at most 2,147,483,647. player is not optional in command blocks, and player must be online.

xp <amount>L [player]

Gives player the amount number of experience levels. Maximum is 2,147,483,647 — if a player is given levels pushing them past this limit, they get reset to 0. Negative amounts may be used to remove experience levels.

amount must be between -2,147,483,648 and 2,147,483,647, inclusive. player is not optional in command blocks, and player must be online.

Multiplayer-only commands

These commands are only available in multiplayer mode, and are usable by ops (operators) from the server console as well as through the chat window when prefixed by the command character /.

None of these commands make use of target selectors and, with the exception of the list command, none of these commands can be executed by a command block.

Many of these commands can be used on players who have never been to the server, or even on names which are not (or cannot be) registered as Minecraft accounts.

Command Description Success Conditions
ban <name> [reason …] Blacklists the player name from the server so that they can no longer connect. Note: Bans supersede any whitelisting in place. Always succeeds.
ban-ip <address|name> [reason …] Blacklists an IP address so that all subsequent connections from it are rejected. address must be a valid IP or player name must be online.
banlist [ips|players] Displays banned IP addresses or banned players. Always succeeds.
deop <player> Revokes a player's operator status. Always succeeds.
kick <player> [reason …] Forcibly disconnects player from the server, displaying an optional reason to them. player must be online.
list Shows the names of all currently-connected players (the same can be achieved when pressing tab) Always succeeds, even in a command block.
op <player> Grants player operator status on the server. Always succeeds.
pardon <name> Removes player name from the blacklist, allowing them to connect again. Always succeeds.
pardon-ip <address> Removes IP address from the IP blacklist, allowing players from that IP address to connect to the server. address must be a valid IP.
save-all Forces the server to write all pending changes to the world to disk. Always succeeds.
save-off Disables the server writing to the world files. All changes will temporarily be queued. Always succeeds.
save-on Enables the server writing to the world files. This is the default behavior. Always succeeds.
setidletimeout <Minutes until kick> Set the idle kick timer. Any players idle for Minutes until kick will be kicked. Always succeeds.
stop Saves all changes to disk, then shuts down the server. Always succeeds.
whitelist <add|remove> <player> Adds or removes player from the whitelist. Always succeeds.
whitelist list Displays all players in the whitelist. Always succeeds.
whitelist <on|off> Enables/disables the server's use of a whitelist. Note: Server ops will always be able to connect when the whitelist is active, even if their names do not appear in the whitelist. Always succeeds.
whitelist reload Reloads the list of playernames in white-list.txt from disk (used when white-list.txt has been modified outside of Minecraft). Always succeeds.

Data tags

NBT tags can be specified for items and entities created with the /give, /summon and other commands. Data tags are data structures. The format is JSON, although it is not strict (lenient). The data is represented as a comma separated list of pairs. Each pair has the format <key>:<value>. The key is the name of the NBT tag and the value is the data that should be assigned to it. Tag names are case-sensitive, and whitespace outside keys or values is ignored.

The value can be different types:

  • String is a piece of text, can be wrapped with double-quotes. Double quotes have to be used if the String contains commas, curly braces or square brackets. To use double-quotes inside Strings, the quote is escaped by a backslash (\"). When using most commands, escaping is disabled (except for double quotes) and keys must not be quoted (probably a bug [1]). This causes an issue where trailing backslashes do not work (as do any other things that need to be escaped), even when escaped properly. The reason is that it escapes the quotation mark after the string which causes a malformed JSON object. Example:"My name is \"Steve\""
  • Number are 1 or more digits that can have a leading sign (+/-). They're classified in Integers, that don't have a decimal mark, Doubles, that uses a dot (.) as a decimal mark, and Floats, that also have f appended after the number. Examples: integer:-128; double:-1.2345; & float:1.2f
  • List (or 'Array') is multiple, comma separated values wrapped with square brackets. The containing values do not need to be of the same type. Example:[1,2,3]
  • Boolean can either be true or false, but using Numbers works, too. When using numbers, everything between 0 and below 1 is false, other is true. Example:true
  • Compound or 'Object' is a container for data structures (as explained above). They are wrapped with curly braces.
Notice: The Data tag itself is a Compound. Example: {Health:18,CustomName:"Friend"}
  • null This is a placeholder an empty value. Do not put quotes. Example:null

When commands such as /testfor, /testforblock, and /clear are used to match NBT tags, they only check for the presence of the given tags in the target entity/block/item. This means that the entity/block/item may have additional tags and will still match. This is true even for lists/arrays: the order of a list is not acknowledged, and as long as every requested element is in the list, it will match even if there are additional elements.

For a complete listing of defined tags (though not all can be modified by commands), see:

For a complete list of identifiers, see:

Raw JSON Text

The /tellraw command uses a specific lenient JSON format for raw chat messages. Similar to the NBT format notation above, concepts such as Strings, Objects (Compounds), and Lists are used to represent the various properties of raw chat.

For a direct tutorial to tellraw commands, see this thread. For a tool to easily create tellraw commands, see this. Note that both links are external to the Minecraft Wiki and may be outdated.

The format of "<raw JSON message>" is a JSON Object which supports the following (mostly optional) elements:

  • The base chat component Object
    •  text: A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names; use selector instead.
    •  extra: A list of additional objects, sharing the same format as the base object.
      • A list element with the same format as the base object (recursive). Note that all properties of this object are inherited by children except for text, extra, translate, with, and score. This means that children will retain the same formatting and events as this object unless they explicitly override them.
    •  color: The color to render this text in. Valid values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", "white", and "reset" (cancels out the effects of colors used by parent objects). Technically, "bold", "underline", "italic", "strikethrough", and "obfuscated" are also accepted, but it may be better practice to use the tags below for such formats.
    •  bold: Boolean (true/false) - whether to render text in bold. Defaults to false.
    •  underlined: Boolean (true/false) - whether to render text underlined. Defaults to false.
    •  italic: Boolean (true/false) - whether to render text in italics. Defaults to false.
    •  strikethrough: Boolean (true/false) - whether to render text with a strikethrough. Defaults to false.
    •  obfuscated: Boolean (true/false) - whether to render text obfuscated. Defaults to false.
    •  insertion: When the text is shift-clicked by a player, this string will be inserted in their chat input. It will not overwrite any existing text the player was writing.
    •  clickEvent: Allows for events to occur when the player clicks on text.
      •  action: The action to perform when clicked. Valid values are "open_url" (opens value as a URL in the player's default web browser), "run_command" (has value entered in chat as though the player typed it themselves. This can be used to run commands, but the command will fail if the player does not have the required permissions to use it), and "suggest_command" (similar to "run_command", but the text only appears in the player's chat input, and is not automatically entered. Unlike insertion, this will replace the existing contents of the chat input).
      •  value: The URL, chat, or command used by the specified action. Note that commands must be prefixed with the usual "/" slash.
    •  hoverEvent: Allows for a tooltip to be displayed when the player hovers their mouse over text.
      •  action: The type of tooltip to show. Valid values are "show_text" (shows raw JSON text), "show_item" (shows the tooltip of an item which can have NBT tags), "show_achievement" (shows formatted text describing an achievement or statistic. Normal achievement names are green, final achievement names are dark_purple, and statistic names are gray. In addition, a description is given for achievements), and "show_entity" (shows an entity's name, possibly its type, and its UUID).
      •  value: The formatting of this tag varies depending on the action. Note that "show_text" is the only action to support an Object as the value; all other action values are Strings and should thus be wrapped in quotes.
        • "show_text": Can be either a raw String of text, or an Object with the same formatting as this base object. Note that clickEvent and hoverEvent do not function within the tooltip, but the formatting and extra tags still work.
        • "show_item": A string formatted like item NBT data. Contains the "id" tag, and optionally the "Damage" tag and "tag" tag (which is the same compound used as "dataTag" in the /give command).
        • "show_achievement": The achievement or statistic's name. This uses the same format as achievement and statistic Scoreboard objective criteria and the /achievement command.
        • "show_entity": A string formatted like a compound with the string values "type" (such as "Zombie"), "name", and "id" (should be an entity UUID, but can actually be any string).
    •  translate: The translation identifier of text to be displayed using the player's selected language. This identifier is the same as the identifiers found in lang files from assets or resource packs. The translated text will only be displayed if the text string is not used.
    •  with: A list of chat component arguments and/or string arguments to be used by translate.
      • The arguments are text corresponding to the arguments used by the translation string in the current language, in order (for example, the first list element corresponds to "%1$s" in a translation string).
    •  score: A compound for displaying a player's score in an objective. Displays "?" if the player is not tracked in the given objective. Ignored completely if text or translate is present.
      •  name: The name of the player whose score should be displayed. Selectors (such as @p) cannot be used, but "fake" player names created by the scoreboard system can be used. In addition, if the name is "*", it will show the player's own score (for example, /tellraw @a {score:{name:"*",objective:"obj"}} will show every online player their own score in the "obj" objective).
      •  objective: The internal name of the objective to display the player's score in.
      •  value: Optional. A default value for the score. May never be used, however: although the game reads this value, it will be overwritten by the correct score or "?" when displayed.
    •  selector: A string containing a selector (@p,@a,@r, or @e) and, optionally, selector arguments. Unlike text, the selector will be translated into the correct player/entity names. If more than one player/entity is detected by the selector, it will be displayed in a form such as 'Name1 and Name2' or 'Name1, Name2, Name3, and Name4'. Ignored completely if text, translate, or score is present.

Due to the extra tag, the above format may be recursively nested to produce very complex and functional text strings. However, a raw json string doesn't have to be complicated at all: virtually all properties are optional and may be left out.

To be valid, each object must have at least either text, translate, or score (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted for a String. In this case, that string will be considered the value of the text property. For example, "This is raw text" is equivalent to {text:"This is raw text"}. This shorthand substitution is valid anywhere a raw text object is required (including the base <raw json message> argument of /tellraw, the elements of the extra list, and the value of a "show_text" hover_event).

Finally, unlike other commands using JSON, /tellraw Strings support Unicode via the notation \u####, where #### is the Unicode hexadecimal number for the desired character.

Video

Commands/video

History

c
0.0.15a_03Added /ban, /ban-ip, /banlist, /broadcast, /deop, /kick, /list, /op, /pardon, /pardon-ip,
/save-all, /save-on, /save-off, /stop, and /whitelist.
0.0.16a_01Changed /broadcast to /say.
0.0.17aAdded /setspawn.
0.0.20Added /solid.
r
1.3.112w16aAdded cheats mode and /gamemode, /give, /kill, /time, /toggledownfall, and /xp.
12w21aAdded /seed.
12w22aAdded /defaultgamemode.
12w24aAdded /publish.
12w25aCheats can now be turned on or off when opening a world to other players through LAN.
12w27aAdded /debug.
1.4.212w32aAdded /difficulty, /gamerule, /spawnpoint, and /weather.
Added target selectors.
12w37aAdded /clear.
12w38a/clear can now be used to remove specific blocks/items.
12w41aThe limit for /xp is now 2,147,483,647 instead of 5,000.
1.4.41.4.4preAdded /enchant.
1.513w03aAdded /testfor.
13w04aAdded /scoreboard.
13w09bAdded /effect.
1.613w23aAdded /spreadplayers.
Added gamerule naturalRegeneration.
13w24aAdded gamerule doDaylightCycle.
1.6preAdded clear argument to /effect.
1.6.1preAdded /playsound.
1.7.213w36aAdded /summon.
Added dataTag argument to /give.
13w37aAdded /setblock, /tellraw, and /testforblock.
13w38aAdded /setidletimeout.
13w43aAdded /setworldspawn.
u
1.814w02aAdded /blockdata.
Added @e selector.
Added optional player/entity argument to /kill.
Added additional arguments to /clear and /testfor.
/testfor is no longer exclusive to command blocks.
Added insertion tag to /tellraw.
14w03aAdded rotation arguments to /tp.
Added dx, dy, and dz to selector arguments.
Added /clone and /fill.
Added gamerule logAdminCommands.
14w04aAdded /particle.
14w05aAdded spectator to /gamemode and /defaultgamemode.
14w06aAdded hideParticles argument to /effect.
Added /trigger.
14w07aAdded /execute and /testforblocks.
/testfor can now test for partial NBT tag matches.
14w08aCommands run using /execute now pass their success value back to the command block running them.
14w10aAdded gamerule showDeathMessages.
Fixed a bug where using the score_name and score_name_min target selectors with @e would not work.
14w17aAdded /worldborder.
Added gamerule randomTickSpeed.
14w19aAdded damage and warning arguments to /worldborder.
14w20aAdded /title.
Added selector argument to /tellraw.

Issues

Issues relating to "Commands" are maintained on the bug tracker. Report issues there.

See also