Menu
This feature is exclusive to Java Edition, Bedrock Edition and Education Edition. |
/. Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press 'Run' button to execute it.
This article is about console commands. For the block that executes commands, see Command Block. For the minecart that executes commands, see Minecart with Command Block. For the similar system found in the Legacy Console Edition, see host privileges.
Commands are advanced features activated by typing certain strings of text.
- Online Java Compiler. Write you java code and compile it online. The java compiler or java editor tool helps you to create, compile and run java program. Our aim is to provide you a free online java compiler so you can test you java code anywhere and anytime. By the help of our online java editor tool, you can edit your java code.
- Why Robot Class? In certain Selenium Automation Tests, there is a need to control keyboard or mouse to interact with OS windows like Download pop-up, Alerts, Print Pop-ups, etc. Or native Operation System applications like Notepad, Skype, Calculator, etc.
- You can compile any java source using javac in command line; eg, javac CopyFile.java. To run: java CopyFile. You can also compile all java files using javac.java as long as they're in the same directory. If you're having an issue resulting with 'could not find or load main class' you may not have jre in your path.
- Online Java Compiler, Online Java Editor, Online Java IDE, Java Coding Online, Practice Java Online, Execute Java Online, Compile Java Online, Run Java Online, Online Java Interpreter, Compile and Execute Java Online (JDK 1.8.0).
- OpenCode appears to be a project at the MIT Media Lab for running Java Code online in a web browser interface. Years ago, I played around a lot at TopCoder. It runs a Java Web Start app, though, so you would need a Java run time installed.
- 1Usage
- 1.2Target selectors in Java Edition
- 2List and summary of commands
- 3Command guide
Usage[edit]
In the client, commands are entered via the chat window, which is displayed by pressing the T key (default) or / key. Using the / key also enters the forward slash that commands require as a prefix, so it is a useful shortcut. The ↑ and ↓ keys can be used to view previously entered text, including all previously executed commands. Pressing Tab ↹ while entering commands cycles through possible commands or arguments, and can be used to auto-enter the coordinates of the block looked at before entering chat.
When the cursor is at a location corresponding to some types of argument (such as an ID), a list of applicable values appear above the text box. If the argument is already containing some characters, the list displays only those values containing the typed text.
Commands may also be entered in a multiplayer server's console, but are not preceded by a / when entered this way. A server admin running commands in this way is often referred to as 'ghosting'.
Commands in command blockscan be preceded by a slash, but it is not required. Commands in a command block usually also require an argument, like a player's username.
The majority of commands are available only in the following situations:
- In a multiplayer 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'). The player does not actually need to be on a LAN or have others join. This is not permanent, but allows the use of commands until the player quits the world, and changes the player makes via commands (items spawned, etc.) are saved with the world. The player can do this each time the player starts playing the world again. Note that this disables game pausing for the duration, so while open to LAN, you should get somewhere safe or reload your world before using the Game Menu. The player can disable the LAN world by reloading the world.
Tilde and caret notation[edit]
Many commands allow relative coordinates to be specified using tildes (
~
) or carets (^
). A number following a tilde or caret specifies an offset from a certain origin rather than a coordinate. The origin depends on the command. For example, in /tp
the offset is from the target's starting position. Other common offsets include from the position of the command's execution or from another coordinate specified by the command.For tilde notation, the offsets are in the positive directions of the world coordinate axes:
~Δx ~Δy ~Δz
. For caret notation, they are along axes originating in the center of the target's head and pointing leftwards, upwards, and forwards, respectively, changing with the head's rotation. In terms of a TNB frame: ^(-ΔB) ^ΔN ^ΔT
. For both, the sign of the offset specifies whether the offset is in the positive or negative direction along that axis. A single tilde or caret by itself is shorthand for ~0
or ^0
, meaning no offset in that direction.For example,
/tp 0 64 0
teleports the user to the coordinate (0, 64, 0), while /tp ~3 ~ ~-3
teleports the user to a position +3 blocks in the 'x' direction (i.e., east), keep their current height, and -3 blocks in the 'z' direction (i.e., north) and /tp ^ ^ ^3
teleports the user to a position +3 forwards in the direction the player is looking.Usually absolute coordinates can be mixed with relative coordinates. For example,
/tp ~ 64 ~
keeps the user's 'x' and 'z' coordinates unchanged, but teleports the user to absolute height of 64. Similarly, /tp ^-5 ^ ^
teleports the player 5 blocks to the right, based on the tilt of their head.Target selectors in Java Edition[edit]
This section needs updating. Description: Does not account for differences between Java 1.14 and Bedrock |
In most commands where a player may be specified as an argument, it is possible to 'target' one or more players satisfying certain conditions instead of specifying players by name. To target players by condition, choose a target selector variable and, optionally, one or more target selector arguments to modify the conditions to be satisfied.
For example, to change the game mode of all players on team Red to creative mode, instead of specifying them by name individually:
/gamemode creative @a[team=Red]
Target selector variables[edit]
Variable | Function |
---|---|
@p | nearest player |
@r | random player |
@a | all players |
@e | all entities |
@s | the entity executing the command |
@c | your agent |
@v | all agents |
A target selector variable identifies the broad category of targets to select. There are five variables:
@p
- Target the nearest player. When run by the console, the origin of selection is (0, 0, 0). If there are multiple nearest players, caused by them being precisely the same distance away, the player who most recently joined the server is selected.
- Target selector arguments may be used to reduce the set of players from which the nearest player is selected. For example,
@p[team=Red]
targets the nearest player on team Red even if there are other players closer.
- The
c
[Bedrock Edition only] orlimit
[Java Edition only] target selector argument can be used to increase the number of nearest players targeted (for example,@p[c=3]
[Bedrock Edition only] or@p[limit=3]
[Java Edition only] targets the three nearest players).
@r
- Target a random player.
- Target selector arguments may be used to reduce the set of players from which a random player is targeted. For example,
@r[team=Red]
targets a random player from team Red.
- The
limit
target selector argument can be used to increase the number of random players targeted. For example,@r[limit=3]
targets three random players.
- The
type
argument is not allowed on@r
. To select a random entity, use@e[sort=random,limit=1]
instead.
@a
- Target all players, including dead players. The only other selector that can find dead players is
@s
.
- Target selector arguments may be used to reduce the set of players targeted. For example,
@a[team=Red]
targets players on team Red.
@e
- Target all entities (including players).
- Target selector arguments may be used to reduce the set of entities targeted. For example,
@e[type=cow]
targets cows.
@s
- Target only one entity—the entity that executed the command, including dead players. If the executor was not an entity, for instance if the executor was a command block or a server console, then this selector finds nothing.
- Target selector arguments may be used to specify whether the executor is actually eligible to be targeted. For example,
@s[type=cow,team=Red]
targets the executor of the command if the executor was a cow on team Red.
@c
- Target your agent only.
limit
[Education Edition only]
- Target selector arguments may be used to target your agent. For example,
/tp @c 50 60 40
teleports your agent only to the specified location.
@v
- Target all agents.
limit
[Education Edition only]
- Target selector arguments may be used to target all agents. For example,
/remove @v
removes all agents.
Target selector arguments[edit]
Selection by Position | |
---|---|
Argument(s) | Selection criteria |
x , y , z | coordinate |
distance [Java Edition only]r , rm [Bedrock Edition only] | distance |
dx , dy , dz | volume dimensions |
Selection by Scoreboard Values | |
Argument(s) | Selection criteria |
scores | scores |
tag | scoreboard tag |
team | team name |
Selection by Traits | |
Argument(s) | Selection criteria |
limit ,sort [Java Edition only]c [Bedrock Edition only] | limit |
level [Java Edition only]l ,lm [Bedrock Edition only] | experience level |
gamemode [Java Edition only]m [Bedrock Edition only] | game mode |
name | entity name |
x_rotation [Java Edition only]rx ,rxm [Bedrock Edition only] | vertical rotation |
y_rotation [Java Edition only]ry ,rym [Bedrock Edition only] | horizontal rotation |
type | entity type |
nbt [Java Edition only] | nbt |
advancements [Java Edition only] | advancements |
predicate [Java Edition only][upcoming:JE 1.15] | predicate |
After a target selector, optional arguments can be used to modify the set of targets selected. When used with
@a
or @e
, arguments narrow down the number of targets from the full list to a specific few. When used with @p
or @r
, arguments narrow the number of targets down from the full list to a smaller set from which the nearest or random player is selected. When used with @s
, the command user is targeted only if all arguments pass, otherwise the command fails.Add argument-value pairs as a comma-separated list contained within square brackets after the target selector variable:
@<variable>[<argument>=<value>,<argument>=<value>,...]
.
Arguments and values are case-sensitive. Spaces are allowed around the brackets, equal signs, and commas, except in between the target variable and the first bracket. Commas must be used to separate argument-value pairs.
- Position arguments
[x=<value>,y=<value>,z=<value>]
- Define a position in the world for use with either the
distance
argument or the distance component arguments,dx
,dy
anddz
. Defining position alone has no use without these, so applying it (and only it) to@e
still selects all entities in the world. - The positional components are doubles, allowing for values like
+12.34
, and they are not center-corrected, meaningx=0
is no longer corrected tox=0.5
- tilde notation is available for selector argument coordinates[Bedrock Edition only].
- Selecting targets by distance
[<x>,<y>,<z>,distance=<value>]
- Filter target selection based on their Euclidean distances from some point. If the positional arguments are left undefined, radius/i is calculated relative to the postion of the command's execution. Only unsigned values are allowed.@e[distance=10]
— Target all entities exactly 10 blocks away.@e[distance=10..12]
— Target all entities more than 10 blocks but less than 12 blocks away (inclusive).@e[distance=5..]
— Target all entities at least 5 blocks away.@e[distance=..15]
— Target all entities at most 15 blocks away.
- Selecting targets by volume
[<x>,<y>,<z>,dx=<value>,dy=<value>,dz=<value>]
- Filter target selection based on their x-difference, y-difference, and z-difference from some point, as measured from the closest corner of the entities' hitboxes.dx
,dy
,dz
specify signed differences from the given coordinate. They do not specify a separate coordinate, nor do they extend in both the positive and negative directions.@e[x=1,dx=4,y=2,dy=5,z=3,dz=6]
— Select all entities whose hitbox collects with the block region (1~5, 2~7, 3~9) (or, mathematically speaking, the region that is {(x,y,z)∈R3|x∈[1.0,5.0),y∈[2.0,7.0),z∈[3.0,9.0)}).@e[x=1,y=2,z=3,dx=0,dy=0,dz=0]
— Select all entities whose hitbox contains the point (1,2,3).
- Selecting targets by scores
[scores={<objective>=<value>,...}]
- Filter target selection based on their scores in specified objectives.@e[scores={myscore=10}]
— Select all entities with a score in objective myscore of exactly 10.@e[scores={myscore=10..12}]
— Select all entities with a score in objective myscore of between 10 and 12 (inclusive).@e[scores={myscore=5..}]
— Select all entities with a score in objective myscore of 5 or greater.@e[scores={myscore=..15}]
— Select all entities with a score in objective myscore of 15 or less.
@e[scores={foo=10,bar=1..5}]
— Select all entities with a score in objective foo of exactly 10, and a score in objective bar of between 1 and 5 (inclusive).
- Selecting targets by team[Java Edition only]
[team=<teamName>]
- Filter target selection to those who are on a given team.[team=!<teamName>]
— Filter to those who are not on a given team.[team=]
— Filter to those who are teamless.[team=!]
— Filter to those who have some team.
See also: Scoreboard § Teams
- Limiting and sorting target selection
[limit=<value>]
- Limit the number of targets selected to be no higher than the given value.@p
and @r
, this argument defaults to 1. Applying the limit
argument to them may artificially increase the number of nearest or random targets selected. When applying this argument to @a
or @e
, this argument returns only a limited number of targets.[limit=<value>,sort=(nearest|furthest|random|arbitrary)]
- Limit the number of targets, and specify selection priority.sort=nearest
— Sort by increasing distance. (Default for@p
)sort=furthest
— Sort by decreasing distance.sort=random
— Sort randomly. (Default for@r
)sort=arbitrary
— Do not sort. (Default for@e
,@a
)@a[limit=3,sort=nearest]
[Java Edition only] or@p[limit=3]
[Java Edition only] or@p[c=3]
[Bedrock Edition only] — Select the nearest 3 players.@a[limit=4,sort=furthest]
[Java Edition only] or@p[c=-3]
[Bedrock Edition only] — Select the furthest 4 players.@a[limit=2,sort=random]
[Java Edition only] or@r[c=2]
[Bedrock Edition only] — Select 2 players, chosen randomly.
- Selecting targets by experience level
[level=<value>]
- Filter target selection based on their experience levels. This naturally filters out all non-player targets.@a[level=10]
— Select all players who have exactly 10 levels.@a[level=10..20]
— Select all players who have between 10 and 20 levels (inclusive).@a[level=30..]
— Select all players who have at least 30 levels.@a[level=..29]
— Select all players who have at most 29 levels.
- Selecting targets by game mode
[gamemode=<gamemodeName>]
— Filter target selection to those who are in the specified game mode.[gamemode=!<gamemodeName>]
— Filter target selection to those who are not in the specified game mode.spectator
[Java Edition only], adventure
, creative
, and survival
.@a[gamemode=survival]
[Java Edition only] or@a[m=1]
[Bedrock Edition only] or@a[m=s]
[Bedrock Edition only] — Select all players who are in Survival mode.@a[gamemode=!spectator]
[Java Edition only] — Select all players who are not in Spectator mode.
- Selecting targets by name
[name=<givenName>]
— Filter target selection to all those with a given name.[name=!<givenName>]
— Filter target selection to all those without a given name.This is a string, so spaces are allowed only if quotes are applied. This cannot be a JSON text compound.
@e[name=!Steve]
- Select all entities that are not named 'Steve'.
- Selecting targets by vertical rotation
[x_rotation=<value>]
— Filter target selection based on their pitch, or more specifically their declination from the horizon, measured in degrees. Values range from -90 (straight up) to 0 (at the horizon) to +90 (straight down).@e[x_rotation=0]
— Select all entities that are looking directly at the horizon.@e[x_rotation=30..60]
— Select all entities that are looking between 30° and 60° (inclusive) below the horizon.@e[x_rotation=45..]
— Select all entities that are looking 45° or more below the horizon.@e[x_rotation=..0]
— Select all entities that are looking at or above the horizon.
- Selecting targets by horizontal rotation
[y_rotation=<value>]
— Filter target selection based on their rotation in the horizontal XZ-plane, measured clockwise in degrees from due south (or the positive Z direction). Values vary from -180 (facing due north) to -90 (facing due east) to 0 (facing due south) to +90 (facing due west) to +180 (facing due north again).@e[y_rotation=0]
— Select all entities that are facing due south.@e[y_rotation=45]
— Select all entities that are facing 45°west of south.@e[y_rotation=96]
— Select all entities that are facing 6°north of west.@e[y_rotation=-90..0]
— Select all entities that are facing in the 90° between due east and due south (inclusive).@e[y_rotation=-90..90]
— Select all entities that are facing between due east and due west (inclusive), through south.@e[y_rotation=0..]
— Select all entities that are not facing at all east.
- Selecting targets by type
[type=<entityType>]
— Filter target selection to those of a specific entity type.[type=!<entityType>]
— Filter target selection to those not of a specific entity type.minecraft:
namespace. (For example, creeper
for creepers, minecart
for regular minecarts, tnt
for primed TNT, etc.) Entity IDs or tags are case-sensitive.@r
parameter, this argument defaults to the type player
. Defining a type for this parameter can filter the random selection to entities only.@e[type=skeleton]
— Select all skeletons.@e[type=!chicken,type=!cow]
— Select all entities except chickens and cows.@e[type=chicken,type=cow]
- Not applicable; select all entities that are simultaneously a chicken and a cow.@e[type=#skeletons]
— Select all skeletons, wither skeletons, and strays.
- Selecting targets by data tag
[tag=<string>]
— Filter target selection to those that have at least one tag of the given name.[tag=!<string>]
— Filter to those that have no tags of the given name.[tag=]
— Filter to those that have exactly zero tags.[tag=!]
— Filter to those that have at least one tag.@e[tag=a,tag=b,tag=!c]
— Select all entities that have tags a and b but not tag c.@r[tag=a]
— Select one random player who has tag a.
- Selecting targets by NBT[Java Edition only]
[nbt=<compoundTag>]
— Select all targets that have the specified NBT. The NBT is written in its command definition.[nbt=!<compoundTag>]
— Select all targets that does not have the specified NBT.@a[nbt={OnGround:true}]
— Select all players on the ground.@e[type=sheep,nbt={Color:0b}]
— Select all sheep that are dyed white.@e[type=item,nbt={Item:{id:'minecraft:slime_ball'}}]
— Selects all slime ball drops.@e[nbt={Tags:[a,b]}]
is the same as@e[tag=a,tag=b]
. The latter is simpler and reduces CPU load.
- Hence
@e[type=item,nbt={Item:{id:slime_ball}}]
cannot find any drop as the id field always contains a namespaced ID-converted string.
- Selecting targets by advancements[Java Edition only]
This section needs expanding |
/advancement test
. The argument name is the advancement id (namespace can be left out when namespaced minecraft
). The value is true, false or so.@a[advancements={story/form_obsidian=true}]
— Selects players who have achieved the advancement minecraft:story/from_obsidian.@a[advancements={story/form_obsidian=false}]
— Selects players who haven't achieved the advancement minecraft:story/from_obsidian.@a[advancements={story/obtain_armor={iron_helmet=true}}]
— Selects players who had armored with iron helmet. The selected players needn't be wearing iron helmet when selected, and needn't have achieved the advancement minecraft:story/obtain_armor.@a[advancements={story/follow_ender_eye=true}]
is the same as@a[advancements={story/follow_ender_eye={in_stronghold=true}}]
.
- Selecting targets by predicate[Java Edition only][upcoming:JE 1.15]
[predicate=<namespaced ID>]
— Select all targets that match the specified predicate.[predicate=!<namespaced ID>]
— Select all targets that fail to match the specified predicate.
@a[predicate=example:test_predicate]
— Selects players who match the example:test_predicate predicate.@e[predicate=!minecraft-wiki:smart_entity]
— Selects entities who doesn't match the minecraft-wiki:smart_entity predicate.
Data tags[edit]
Main article: NBT format
A data tag is a tree-shaped data structure that can be described starting with attribute-value pairs enclosed in curly braces. One common usage of data tags in Java Edition is in commands, used to specify complex data for any entity.
A data tag consists of zero or more attribute-value pairs delimited by commas and enclosed in curly braces. Each attribute-value pair consists of an attribute name and the attribute's value, separated by a colon. Some values, however, may themselves contain attribute-value pairs, allowing a data tag to describe a hierarchical data structure.
- Example:
{name1:123,name2:'sometext',name3:{subname1:456,subname2:789}}
The data structures that data tags describe are the same ones used in Minecraft's save files. These data structures are described in other articles and commands expect data tags to use the same attribute names (which are case-sensitive):
Objects | Examples |
---|---|
Block entities | chests, furnaces, command blocks, mob spawners, signs, etc. |
Items | items in inventories (includes specifications for enchantments, lore, custom names, etc.) |
Item entities | items on the ground |
Mobs | creepers, cows, villagers, etc. |
Projectiles | arrows, fireballs, thrown potions, etc. |
Vehicles | boats, minecarts, etc. |
Dynamic tiles | primed TNT, falling sand/gravel/anvils |
Other entities | firework rockets, paintings, and item frames |
The defined data structures also expect the values to be of the correct type.
Type | Description |
---|---|
Byte | A signed 8-bit integer, ranging from -128 to 127 (inclusive). |
Short | A signed 16-bit integer, ranging from -32,768 to 32,767 (inclusive). |
Int | A signed 32-bit integer, ranging from -2,147,483,648 and 2,147,483,647 (inclusive). |
Long | A signed 64-bit integer, ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive). |
Float Double | Float: A 32-bit, single-precision floating-point number, ranging from -3.4E+38 to +3.4E+38.
Double: A 64-bit, double-precision floating-point, ranging from -1.7E+308 to +1.7E+308.
See IEEE floating point for details. |
String | A sequence of characters, enclosed in quotes. For strings without commas, brackets, braces or spaces, quote enclosure is optional. Nested quotes can be included within a string by escaping the character with the ' escape sequence.
|
List | An ordered list of tags, enclosed in square brackets and delimited by commas. The tags must be of the same type, determined by the first tag in the list.
|
Compound | An ordered list of attribute-value pairs, enclosed in curly braces and delimited by commas.
Each tag may be of any type. |
Byte Array | B; followed by an ordered list of 8-bit integers, delimited by commas. Tag is enclosed in square brackets.
|
Int Array | I; followed by an ordered list of 32-bit integers, delimited by commas. Tag is enclosed in square brackets.
|
Long Array | L; followed by an ordered list of 64-bit integers, delimited by commas. Tag is enclosed in square brackets.
|
Boolean | A value, expressed as 'true' or 'false'. This is seen only in JSON formatting, as a Byte tag is usually used in NBT data to determine a boolean value as 0 (for false) and 1 (for true).
|
Some commands may require that a number's type be specified by adding a letter (B, S, L, F, D) to the end of the value. For example,
3s
for a short, 3.2f
for a float, etc. (This doesn't work with I for int.) The letter can be uppercase or lowercase. When no letter is used and Minecraft can't tell the type from context, it assumes double if there's a decimal point, int if there's no decimal point and the size fits within 32 bits, or string if neither is true. A square-bracketed literal is assumed to be a list unless an identifier is used: [I;1,2,3]
for an int array and [L;1L,2L,3L]
for a long array.When commands such as
/clear
are used to match data tags, they check only for the presence of the provided tags in the target entity/block/item. This means that the entity/block/item can have additional tags and still match. This is true even for lists and arrays: the order of a list is not acknowledged, and as long as every requested element is in the list, it matches even if there are additional elements.Raw JSON text[edit]
It has been suggested that the contents of this section be split into its own page.Discuss Reason: Not just for commands |
For raw JSON text in Bedrock Edition, see Bedrock Edition raw JSON text format.
The
/tellraw
and /title
commands use strict JSON syntax.Scores and target selectors are evaluated for a Sign when it is placed or edited and for a Written Book when it is 'resolved' (opened for the first time after signing). They won't update after that, and they won't work if edited onto an existing sign with an NBT editor, or onto a book that's already marked resolved. There's no way to wrap text onto the next line of a sign or the next page of a book during resolution; instead, the extra text simply disappears.
The format of raw JSON text is a JSON string, a JSON array, or a JSON Object that supports the following (mostly optional) elements:
- A string representing raw text to display directly in chat. Same as having only a text tag in the base object.
- Same as having all elements except the first in this array appended to the end of the extra array of the first chat component in this array. Each element repeats this raw JSON text structure.
- 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. Can use escape characters, such as
n
for newline (enter),t
for tab, etc. - 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. Ignored when text exist in the root object.
- score: A player's score in an objective. Displays nothing if the player is not tracked in the given objective. Ignored when any of the previous fields exist in the root object.
- name: The name of the player whose score should be displayed. Selectors (such as @p) can be used, in addition to 'fake' player names created by the scoreboard system. In addition, if the name is '*', it shows the reader's own score (for example,
/tellraw @a {'score':{'name':'*','objective':'obj'}}
shows 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. If present, this value is used regardless of what the score would have been.
- name: The name of the player whose score should be displayed. Selectors (such as @p) can be used, in addition to 'fake' player names created by the scoreboard system. In addition, if the name is '*', it shows the reader's own score (for example,
- selector: A string containing a selector (@p,@a,@r,@e or @s) and, optionally, selector arguments. Unlike text, the selector is translated into the correct player/entity names. If more than one player/entity is detected by the selector, it is displayed in a form such as 'Name1 and Name2' or 'Name1, Name2, Name3, and Name4'. Ignored when any of the previous fields exist in the root object. Clicking a player's name inserted into a /tellraw command this way suggests a command to whisper to that player. Shift-clicking a player's name inserts that name into chat. Shift-clicking a non-player entity's name inserts its UUID into chat.
- keybind: A string that can be used to display the key needed to preform a certain action. An example is
key.inventory
which always displays 'E' unless the player has set a different key for opening their inventory. Ignored when any of the previous fields exist in the root object. - nbt: A string indicating the NBT path used for looking up NBT values from an entity or a block entity. Ignored when any of the previous fields exist in the root object.
- with: A list of chat component arguments and/or string arguments to be used by translate. Useless otherwise.
- 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). Argument structure repeats this raw JSON text structure.
- interpret: A boolean to indicate whether the game should interpret the SNBT value at the path indicated by nbt as a raw JSON text (according to this raw JSON text structure). Useless otherwise.
- block: A string specifying the coordinates of the block entity from which the NBT value is obtained. The coordinates can be absolute or relative. Useless if nbt is absent.
- entity: A string specifying the target selector for the entity from which the NBT value is obtained. Useless if nbt is absent.
- storage[upcoming:JE 1.15]: A string specifying the namespaced ID of the command storage from which the NBT value is obtained. Useless if nbt is absent.
- extra: A list of additional objects, sharing the same format as the base object.
- A list element whose structure repeats this raw JSON text structure. Note that all properties of this object are inherited by children except for text, extra, translate, with, and score. This means that children 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', 'italic', 'underlined', '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.
- italic: Boolean (true/false) - whether to render text in italics. Defaults to false.
- underlined: Boolean (true/false) - whether to render text underlined. 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 is inserted in their chat input. It does 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), 'open_file' (opens the value file on the user's computer), 'run_command' (has value entered in chat as though the player typed it themselves. This can be used to run commands, provided the player has the required permissions), 'change_page' (can be used only in written books) changes to page value if that page exists, and 'suggest_command' (similar to 'run_command' but it cannot be used in a written book, the text appears only in the player's chat input and it is not automatically entered. Unlike insertion, this replaces the existing contents of the chat input). 'open_file' is used in messages automatically generated by the game (e.g. on taking a screenshot) and cannot be used in commands or signs.
- value: The URL, file, chat, command or book page 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 that can have NBT tags), 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' can be 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_entity' can be 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).
- 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. Can use escape characters, such as
Due to the extra tag, the above format may be recursively nested to produce very complex and functional text strings. However, a raw json text 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, score, selector or keybind (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted with a String. In this case, that string is 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)./tellraw
also accepts an array of objects and/or strings; they are concatenated. It even accepts a tree of nested arrays; they are traversed depth-first. For example:Finally, unlike other commands using JSON,
/tellraw
Strings support Unicode via the notation u####
, where #### is the Unicode hexadecimal number for the desired character.- External links
- List of all Keybinds
Block/item/entity... names[edit]
Many commands have arguments that identify particular types of blocks, items, entities, advancements, bossbars, effects, enchantments and so on. In the command syntax below, these typically appear as elements named
<block>
, <item>
, or the like, which are replaced with identifiers such as minecraft:stone
in the examples. These IDs all have namespaces. All original Minecraft contents are namespaced minecraft
while contents from mods or data packs have other namespaces. Namespace prefix of IDs namespaced minecraft
can be omitted for most situations; however, in certain cases, such as NBT data tag matching, full namespaced ids are required.List of argument types in Java Edition[edit]
Main article: Java Edition list of argument types
These are the argument types in Minecraft: Java Edition.
List and summary of commands[edit]
The table below summarizes all commands, including upcoming ones. Click a column heading to sort by that column. Click the link in the first unit of each row to get detailed usage of each command.
Command | Description | BE | EE | JE | OP level | MP Only | ||||
---|---|---|---|---|---|---|---|---|---|---|
/ability | Grants or revokes a player ability. | Removed | Yes | -- | 2 | -- | -- | -- | -- | |
/advancement | Gives, removes, or checks player advancements. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/ban | Adds player to banlist. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/ban-ip | Adds IP address to banlist. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/banlist | Displays banlist. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/bossbar | Creates and modifies bossbars. | -- | -- | Yes | 2 | -- | -- | -- | ||
/classroommode | Ability to edit restricted blocks. | -- | Yes | -- | 3 | -- | -- | -- | -- | -- |
/clear | Clears items from player inventory. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/clone | Copies blocks from one place to another. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/data | Gets, merges, modifies and removes block entity and entity NBT data. | -- | -- | Yes | 2 | -- | -- | |||
/datapack | Controls loaded data packs. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/debug | Starts or stops a debugging session. | -- | -- | Yes | 3 | -- | -- | -- | -- | -- |
/defaultgamemode | Sets the default game mode. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/deop | Revokes operator status from a player. | Yes | Yes | Yes | 3 | MP | -- | -- | -- | |
/difficulty | Sets the difficulty level. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/effect | Add or remove status effects. | Yes | Yes | Yes | 2 | -- | -- | -- | ||
/enchant | Enchants a player item. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/execute | Executes another command. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | -- |
/experience | Adds or removes player experience. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/fill | Fills a region with a specific block. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/forceload | Forces chunks to constantly be loaded or not. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/function | Runs a function. | Yes | -- | Yes | 2 | -- | -- | -- | -- | -- |
/gamemode | Sets a player's game mode. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/gamerule | Sets or queries a game rule value. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/give | Gives an item to a player. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/help | Provides help for commands. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | -- |
/immutableworld | Allows setting immutable state of a world. | -- | Yes | -- | 3 | -- | -- | -- | -- | |
/kick | Kicks a player off a server. | -- | Yes | Yes | 3 | MP | -- | -- | -- | |
/kill | Kills entities (players, mobs, items, etc.). | Yes | Yes | Yes | 2 | -- | -- | -- | ||
/list | Lists players on the server. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | |
/locate | Locates closest structure. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/loot | Drops items from an inventory slot onto the ground. | -- | -- | Yes | 2 | -- | ||||
/me | Displays a message about the sender. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | |
/mixer | Mixer interactivity control. | Yes | -- | -- | 2 | -- | -- | -- | -- | -- |
/mobevent | Enables/disables a specified mob event. | Yes | Yes | -- | 2 | -- | -- | -- | -- | |
/msg | Displays a private message to other players. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | |
/op | Grants operator status to a player. | Yes | Yes | Yes | 3 | MP | -- | -- | -- | |
/pardon | Removes entries from the banlist. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/particle | Creates particles. | Yes | -- | Yes | 2 | -- | -- | -- | -- | |
/playsound | Plays a sound. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/publish | Opens single-player world to local network. | -- | -- | Yes | 4 | SP only | -- | -- | -- | |
/recipe | Gives or takes player recipes. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/reload | Reloads loot tables, advancements, and functions from disk. | Yes | -- | Yes | 2 | -- | -- | -- | -- | |
/remove | Removing agent. | -- | Yes | -- | 3 | -- | -- | -- | -- | |
/resupply | Resupply villagers. | Removed | -- | -- | 2 | -- | -- | -- | -- | |
/replaceitem | Replaces items in inventories. | Yes | Yes | Yes | 2 | -- | -- | |||
/save | Prepares a backup, queries its status, or resumes. | BDS only | -- | -- | -- | MP | -- | -- | -- | |
/save-all | Saves the server to disk. | -- | -- | Yes | 4 | MP | -- | -- | -- | |
/save-off | Disables automatic server saves. | -- | -- | Yes | 4 | MP | -- | -- | -- | |
/save-on | Enables automatic server saves. | -- | -- | Yes | 4 | MP | -- | -- | -- | |
/say | Displays a message to multiple players. | Yes | Yes | Yes | 1 | -- | -- | -- | -- | -- |
/schedule | Delays the execution of a function. | -- | -- | Yes | 2 | -- | -- | -- | -- | -- |
/scoreboard | Manages scoreboard objectives and players | Yes | -- | Yes | 2 | -- | -- | -- | ||
/seed | Displays the world seed. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/setblock | Changes a block to another block. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/setidletimeout | Sets the time before idle players are kicked. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/setmaxplayers | Sets the maximum number of players allowed to join. | Yes | Yes | -- | 0 | -- | -- | -- | -- | |
/setworldspawn | Sets the world spawn. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/spawnpoint | Sets the spawn point for a player. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/spreadplayers | Teleports entities to random locations. | Yes | Yes | Yes | 2 | -- | -- | -- | ||
/stop | Stops a server. | -- | -- | Yes | 4 | MP | -- | -- | -- | |
/stopsound | Stops a sound. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/summon | Summons an entity. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/tag | Controls entity tags. | Yes | -- | Yes | 2 | -- | -- | -- | ||
/team | Controls teams. | -- | -- | Yes | 2 | -- | -- | -- | ||
/teleport | Teleports entities. | Yes | Yes | Yes | 2 | -- | -- | -- | ||
/teammsg | Specifies the message to send to team. | -- | -- | Yes | 0 | -- | -- | -- | -- | |
/tell | Displays a private message to other players. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | |
/tellraw | Displays a JSON message to players. | Yes | -- | Yes | 2 | -- | -- | -- | -- | |
/testfor | Counts entities matching specified conditions. | Yes | Yes | -- | 2 | -- | -- | -- | ||
/testforblock | Tests whether a block is in a location. | Yes | Yes | -- | 2 | -- | -- | -- | -- | |
/testforblocks | Tests whether the blocks in two regions match. | Yes | Yes | -- | 2 | -- | -- | -- | -- | |
/tickingarea | Add, remove, or list ticking areas. | Yes | Yes | -- | 2 | -- | -- | -- | -- | |
/time | Changes or queries the world's game time. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/title | Manages screen titles. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/toggledownfall | Toggles the weather. | Yes | Yes | -- | 2 | -- | -- | -- | -- | |
/tp | Teleports entities. | Yes | Yes | Yes | 2 | -- | -- | -- | ||
/transferserver | Transfer player to a server. | Yes | Yes | -- | 0 | -- | -- | -- | -- | -- |
/trigger | Sets a trigger to be activated. | -- | -- | Yes | 0 | -- | -- | -- | -- | |
/w | Displays a private message to other players. | Yes | Yes | Yes | 0 | -- | -- | -- | -- | |
/weather | Sets the weather. | Yes | Yes | Yes | 2 | -- | -- | -- | -- | |
/whitelist | Manages server whitelist. | -- | -- | Yes | 3 | MP | -- | -- | -- | |
/worldborder | Manages the world border. | -- | -- | Yes | 2 | -- | -- | -- | -- | |
/worldbuilder | Ability to edit restricted blocks. | Yes | Yes | -- | 3 | -- | -- | -- | -- | |
/wsserver | Connects to a WebSocket server. | Yes | Yes | -- | 0 | -- | -- | -- | -- | -- |
/xp | Adds or removes player experience. | Yes | Yes | Yes | 2 | -- | -- | -- | -- |
Removed commands[edit]
Command | Description | Reason for Deletion | BE | EE | JE | OP level | MP Only | ||||
---|---|---|---|---|---|---|---|---|---|---|---|
/achievement | Gives or takes an achievement from a player. | Achievements were removed in Java Edition 1.12. | -- | -- | Removed | 2 | -- | -- | -- | -- | |
/blockdata | Modifies the data tag of a block. | Repurposed as /data in Java Edition 1.13. | -- | -- | Removed | 2 | -- | -- | -- | -- | |
/broadcast | Broadcasts a message across the entire server. | Repurposed as /say in Java Edition Classic 0.0.16a_01. | -- | -- | Removed | 2 | -- | -- | -- | -- | -- |
/entitydata | Modifies the data tag of an entity. | Repurposed as /data in Java Edition 1.13. | -- | -- | Removed | 2 | -- | -- | -- | -- | |
/home | Teleports player to the world spawn. | World spawn became based on spawn chunks instead of a singular location. | -- | -- | Removed | 0 | -- | -- | -- | -- | -- |
/setspawn | Sets the current location as the default spawn location for new players. | World spawn became based on spawn chunks instead of a singular location. | -- | -- | Removed | 2 | -- | -- | -- | -- | -- |
/solid | Toggles between placing stone and placing bedrock. | Feature removed during Java Edition Indev, placing blocks became inventory based. | -- | -- | Removed | 2 | -- | -- | -- | -- | -- |
/stats | Update objectives from command results. | Became part of /execute in Java Edition 1.13. | -- | -- | Removed | 2 | -- | -- | |||
/unban | Pardons a banned player. | Repurposed as /pardon in Java Edition Alpha 1.0.16. | -- | -- | Removed | 3 | MP | -- | -- | -- | |
/toggledownfall | Toggles the weather. | Removed in Java Edition 1.13 due to redundancy with the /weather command. | Yes | Yes | Removed | 2 | -- | -- | -- | -- |
Command guide[edit]
Syntax[edit]
If you see... | Then |
---|---|
plain text | Enter this literally, exactly as shown. |
<angle brackets> | Replace this with an appropriate value. |
[square brackets] | This is an optional argument. |
(<entry>|<entry>) | (Required) Pick one of the entries shown, often literal words. |
[<entry>|<entry>] | (Optional) Pick one of the entries shown, often literal words. |
ellipsis ... | This entry may repeat more than once. |
<argument>: <int> | The argument is expected to be an integer. |
<argument>: <double> | The argument is expected to be a double-precision float. |
<argument>: <string> | The argument is expected to be a string. Quotes must be applied if any non-alphanumeric characters show up in the string. |
Success Conditions[edit]
- 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 a command block with a command. Note that not all 'successful' commands actually do something, and not all 'failed' commands fail to do something useful.
Restrictions[edit]
Describes restrictions on who can use the command or in what context.- None: The command can be used by any player in any world. The following commands have no restrictions:
/help
,/me
,/tell
, and/trigger
. - Operator: The command may be used only by an operator or in singleplayer mode with cheats enabled. On multiplayer servers, the results of these commands are broadcast to other ops online.
- Multiplayer: The command is available only on a multiplayer server. The following commands are restricted to multiplayer servers:
/ban
,/ban-ip
,/banlist
,/deop
,/kick
,/list
,/op
,/pardon
,/pardon-ip
,/save-all
,/save-off
,/save-on
,/setidletimeout
,/stop
,/whitelist
.
- No multiplayer commands permit target selectors in arguments.
- Except for
/list
, multiplayer commands cannot be used in command blocks. - Many of these commands can be used on players who have never been to the server, or even on names that are not (or cannot be) registered as Minecraft accounts.
- No command blocks: The command cannot be executed by a command block.
Video[edit]
Video made by slicedlime:
History[edit]
Java Edition Classic | |||||
---|---|---|---|---|---|
0.0.15a (Multiplayer Test 3) | Added commands. | ||||
Java Edition Indev | |||||
0.31 | Removed all commands. | ||||
Java Edition Alpha | |||||
v1.0.16 | Re-added several commands. | ||||
Java Edition | |||||
1.3.1 | 12w16a | Added cheats mode. | |||
12w25a | Cheats can now be turned on or off when opening a world to other players through LAN. | ||||
1.4.2 | 12w32a | Added target selectors. | |||
1.8 | 14w02a | Added the @e target selector variable. | |||
Added insertion attribute to raw JSON text specification. | |||||
14w03a | Added dx , dy , and dz to target selector arguments. | ||||
NBT data now supports using string IDs rather than numerical IDs. | |||||
Numerical IDs no longer work in other parts of commands, though they still work for NBT data. | |||||
14w20a | Added selector attribute to raw JSON text specification. | ||||
1.9 | 16w02a | The m selector now accepts the standard literal gamemode values and abbreviations, such as a and adventure , and these may be negated as well. | |||
1.11 | 16w32a | Added block state support to commands. | |||
16w38a | Removed implicit target selectors (for example, @e[167,28,454] ). | ||||
Invalid target selectors (such as @e[Type=creeper] , @e[asdf=nonexistent] , and @e[malformed] ) now generate an error instead of being silently ignored. | |||||
1.12 | 17w16b | Added the @s target selector variable | |||
1.13 | 17w45a | A new library named Brigadier is now used to parse commands. Different components of commands are displayed in different colors, and errors are displayed in red without having to run the command. Commands, for the most part, do not allow uppercase letters, and are now much faster and more efficient. | |||
Added the nbt target selector argument. | |||||
17w46a | The player now has the option to toggle automatic command suggestions. | ||||
The command UI has a new prototype, and now works in multiplayer. | |||||
17w47a | Added an option in chat to toggle automatic command suggestions. | ||||
17w48a | Tweaked the command suggestion UI. | ||||
Reworked tab-completion for coordinates. | |||||
17w50a | Local coordinates can now be specified in commands using ^ . | ||||
Tab-completing when not targeting a block suggests ~ ~ ~ . | |||||
18w01a | |||||
Changed all custom names (blocks, items, entities, block entities) to translatable text components. | |||||
Thrower and Owner nbt keys of item entities are no longer strings but are instead compounds with two longs named L and M . | |||||
owner nbt key of snowballs, eggs and ender pearls are no longer strings but are instead compounds with two longs named L and M . | |||||
18w02a | Errors during a command are now a nicer error message (with a tool tip for more info). | ||||
Server commands now run from world spawn in the Overworld, instead of at 0,0,0 . | |||||
18w03a | Improved performance of command parsing and command execution. | ||||
18w05a | Added basic entity selector suggestions in the command UI. | ||||
A warning is now logged for ambiguous commands. | |||||
18w06a | Added command suggestions for entity selectors. | ||||
Whitespaces are now allowed in entity selectors & block state arguments. | |||||
September 26, 2018 | Brigadieropen-sourced under the MIT license. (Source code previously was available on the library site, with no license specified). | ||||
Pocket Edition Alpha | |||||
0.7.4 | Added support for commands, though none are implemented yet. | ||||
0.16.0 | build 1 | Added commands. | |||
Functionality of most commands is equivalent to Java Edition 1.10 usage. Differences include: no support for data tags. |
Code In Java Online
Issues[edit]
Issues relating to 'Commands' are maintained on the bug tracker. Report issues there.
See also[edit]
Java Edition | ||||
---|---|---|---|---|
Versions |
| |||
Development |
| |||
Technical |
| |||
Multiplayer | ||||
Game customization |
|
Bedrock Edition | ||||||||
---|---|---|---|---|---|---|---|---|
Editions |
| |||||||
Development | ||||||||
Technical |
| |||||||
Multiplayer | ||||||||
Exclusive features |
| |||||||
Removed |
Retrieved from 'https://minecraft.gamepedia.com/index.php?title=Commands&oldid=1438852'
Execute MATLAB/Octave Online - The best online IDE and Terminals in the cloud where you can Edit, Compile, Execute and Share your source code with the help of simple clicks. You can save your projects at Dropbox, GitHub, GoogleDrive and OneDrive to be accessed anywhere and any time. We support almost all the popular programming languages including Java, JSP, Cold Fusion, C, C++, Hadoop, PL/SQL, SQL, NumPy, SymPy, Octave, CentOS, iPython, Pascal, Fortran, PHP, Perl, Ruby, Python and many more other programming languages using your browsers, iPhones, iPads or any other online device like smart TV.