Minecraft:Commands
More actions
Template:For Template:Redirect Template:Redirect
Commands (also known as console commands or slash commands) are an advanced game mechanic that execute specific actions when entered as text or triggered by blocks or certain Minecraft:entities.
Usage
In the client, commands are entered via the Minecraft:chat window, which is displayed by pressing the Template:Key / Template:Key / File:Chat button.pngTemplate:Only / Template:XbuttonTemplate:Only or Template:Key key. Using the Template:Key key also enters the forward-slash that commands require as a prefix, so it is a useful shortcut. The Template:Key / Template:Xbutton and Template:Key / Template:Xbutton keys can be used to view previously entered text, including all previously executed commands.
When the cursor is at a location corresponding to some types of argument (such as an entity ID), a list of applicable values appears above the text box. If the argument already contains characters, the list displays only those values containing the typed text. Pressing Template:Key while entering commands cycles through possible commands or arguments, and can be used to auto-enter them.
Commands may also be entered in a multiplayer Minecraft:server's console but are not preceded by a Template:Key when entered this way. A server owner running commands in this way is often referred to as "ghosting".
Commands in Minecraft:command blocks can be preceded by a slash, but it is not required.
Commands can be executed in the following ways:
- Entered by a player in the chat screen.
- Executed by a Minecraft:command block or a Minecraft:minecart with command block.
- In a dedicated Minecraft:server, entered in the console.
- In Minecraft:functions, in a Minecraft:data pack or Minecraft:behavior pack.
- Clicking a Minecraft:text component that has "run_command" action.Template:Only
- Requested by a WebSocket server connected to a client.Template:Only
- Clicking a dialog's action button.Template:Only
- By an Minecraft:NPC dialogue.Template:Only
- In scripts, in a Minecraft:behavior pack.Template:Only
- In animation controllers, in a Minecraft:behavior pack.Template:Only
- In a block event response, in a Minecraft:behavior pack.Template:Only
- In an entity event response, in a Minecraft:behavior pack.Template:Only
Template:IN, commands can be executed through specified Minecraft:hotkeys on keyboard & mouse controls, known as command macros. The keybinds with commands can be customized below all other keybinds in the settings. For up to 10 macros, a command can be entered in a text input, which can be quickly executed in-game by pressing Template:Keys. Command macros can be preceded by a slash, but it is not required. This feature is not to be confused with Java Edition's function macros, where functions may reference additional parameters and use them in macro lines (see Template:Slink).
Commands guide
Syntax
Entry Meaning Template:Code Enter this literally, exactly as shown. Template:Code An argument, which should be replaced with an appropriate value. Note: the angle brackets should be replaced too; they only indicate the purpose of the text.
Decorator Meaning Template:Code This entry is optional. Template:Code
Template:Code
etc.Required. Pick one of these entries. Template:Code
Template:Code
etc.Optional. Pick one of these entries. Template:Code In the game, another full command is required.
In this wiki, some required parts are left out.
- For example: Template:Code is an optional argument. Template:Code is an optional plain text.
- For example: Template:Code, where Template:Code and Template:Code are plain texts that should be entered literally; Template:Code means we should pick one plain text from Template:Code and Template:Code; Template:Code and Template:Code are required arguments, which should be replaced with appropriate values; Template:Code is an optional argument.
Entry Meaning Template:Code Enter this literally, exactly as shown. Template:Code An argument, which should be replaced with an appropriate value. Template:Code Another full command is required. Template:Code
Template:Code
etc.Enter one of these texts literally.
Decorator Meaning Template:Code This entry is required. Template:Code This entry is optional. Template:Code In this wiki, some required parts are left out.
- The angle bracket decorator (Template:Code) is usually not used on a Template:Code. A required plain text does not need any decorator.
- For example, both Template:Code and Template:Code represent a required plain text, but the latter one is usually not used. Template:Code is a required argument.
In both Template:El and Template:El, square bracket decorator (Template:Code) mean that an entry is optional. Entries decorated with square brackets can only be at the end of a command. Multiple entries decorated with square brackets are allowed at the end of a command, for example, Template:Code at the end of a command indicates that only Template:Code, Template:Code, and Template:Code are valid.
Restrictions
Most commands require the executor to have a high enough Minecraft:permission level. That means most commands are only available in the singleplayer world if cheats are enabled, and are only available in multiplayer servers if the player is an operator. See Minecraft:permission level for details.
Some commands have restrictions on who can use the command or in what context.
- None: The command has no restriction.
- Cheats only: Applicable only to Template:El. When executed by the server, or a script, the command is available no matter whether cheats are enabled. (Commands from the console, a scheduled function or a ticking function are executed by the server.) When executed in other ways, the command is available only if cheats are enabled. When cheats are disabled, these commands can't be used unless executed by a server or a script, even if the executor has a high Minecraft:permission level.
- Template:IN, whether cheats are enabled only affects the permission level of a player. If an executor has a high enough permission level, it can use corresponding commands regardless of whether cheats are allowed.
- Dedicated server only: The command is available only on dedicated servers.
- No dedicated server: The command is not available on dedicated servers.
Cheats
Cheats can be enabled when creating a new world by Allow CommandsTemplate:Only / CheatsTemplate:Only options.
Template:IN, the "Allow Commands" option when creating a new world only affects the player in a singleplayer world or the owner of a LAN world. The "Allow Commands" option when opening a LAN world affects all players in the LAN world.
Template:IN, 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 ( Template:Key → "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, the player should get somewhere safe or reload their world before using the Game Menu. The player can disable the LAN world by reloading the world. To permanently enable cheats, the level.dat file has to be edited.
Template:IN, cheats can be toggled at any time in the "Cheats" tab of the settings menu. Enabling cheats in a world permanently prevents players from unlocking Minecraft:achievements in that world, even if cheats are later turned off. In Minecraft:Bedrock Dedicated Server, Template:Cmd command can be used to toggle cheats.
Argument types
Template:Main There are different argument types for arguments in commands. Minecraft:Coordinates, Minecraft:target selector, Minecraft:SNBT, Minecraft:text component, and so on are commonly used formats in arguments.
Parsing and execution
The command performing on the server side is divided into two stages: command parsing and command execution. During the command parsing stage, the game identifies the string as a command and checks whether the command is complete and whether arguments are specified correctly. During the command execution stage, the command fulfills its purpose.
When typing a command in the chat, or Minecraft:command block, the command is also be parsed in the client side first to provide autocompletion and help the player detect typing mistakes.
- When typing an argument into the chat, it's noticeable if an argument cannot be parsed in the client side. However, being able to be parsed in the client side does not guarantee that this argument can be parsed in the server side.
- Template:IN, if an argument can't be parsed by the client, the argument is marked in red, and a syntax error message is displayed above the chat bar.
- Template:IN, when typing in the chat, if an argument can be parsed in the client side, the next argument in syntax hint turns to white from gray. If all arguments (including optional arguments) are entered and parseable in the client side, the whole syntax hint turns to gray from white.
- Template:IN, typing a command in Minecraft:command block also behaves as above
- Template:IN, when typing a command in Minecraft:command block, autocompletion is provided without syntax hint.
Template:IN, when entering into a command block, the command is parsed on the server side once the command block screen is closed. If the command is unparseable in the server side, a syntax error message is outputted into its output box.
When attempting to execute an unparseable command, an error message is displayed.
- Template:IN, the message has a
<--[HERE]at its end. - Template:IN, the message is
Unknown commandorSyntax error: unexpected ... at ....
Commands in Minecraft:functions are all parsed when loading the function. If any command in a function file is unparseable, the function cannot be loaded by the game. Template:IN, macro lines are parsed when attempting to run the function, see also Template:Slink and Template:Slink.
Template:IN, if a command in a script is unparseable, an error is thrown when trying to execute the command.
Output
After trying to execute a command, it may yield output values, including success count and stored valuesTemplate:Only.
Success count is the value a command passes to the command block executing it. A command block can power a Minecraft:redstone comparator facing away from it (may be separated by a block) with signal strength being the success count. The signal strength reflects the success count of the last command executed. Even after the command block is deactivated, the success count is retained until the command is executed again. Template:IN, the success count is also returned to the script executing the command. Template:IN, commands that cannot be executed in command blocks have no success count. Template:IN, commands that cannot be executed in command blocks or scripts still have a success count, but it cannot be obtained. Template:IN, success count is always 0 or 1, except the Template:Cmd command. Template:IN, success count is an integer between 0 to 2,147,483,647 (both inclusive) related to the command (e.g., the number of players affected by the command, the number of blocks that were altered, etc.)
Stored valuesTemplate:Only include Template:Cd value and Template:Cd value, which are the values passed by other commands to the Template:Cmd command, when a command is executed by a Template:Cmd command. These two values can be stored to a specified location by the Template:Cd subcommand in the Template:Cmd command. The Template:Cd value is always 0 or 1. The Template:Cd value is an integer (rounded down if not). All commands may yield these two stored values after execution, with only two exceptions: Template:Cmd command itself does not yield these two stored values; Template:Cmd command may not yield these two stored values in certain situation.
Result
After trying to execute a command, it has a certain result. Possible results include "Unparseable", "Failed", "Successful", "Void"Template:Only, "Terminated"Template:Only, and "Error"Template:Only.
- Unparseable
- If the entered command is unable to be parsed in the server side, it is unparseable.
- ErrorTemplate:Only
- If an error occurs with a command, it means that there's a noticeable bug on the command. It may result in unintended side effects, and it jumps out the Template:Cmd command halfway through, causing some branches to not be executed.
- Technically, it means that an exception other than
brigadier.exceptions.CommandSyntaxExceptionis thrown during execution.
- VoidTemplate:Only
- Exclusive to Template:Cmd command. If it is void, the command has no Template:Code or Template:Code value to be stored by Template:Cmd.
- TerminatedTemplate:Only
- Exclusive to Template:Cmd command. When running a Template:Cmd command, if the number of execution branches becomes 0, the command terminates, ending before the last sub-command is executed.
- For example: Template:Cmd in a command block. The command block is not an entity, so it cannot be selected by a Minecraft:target selector. As a result, the command is terminated at Template:Cd.
- Failed and Successful
- If a command is not unparseable, erroring, void, nor terminated, it may be failed or successful.
- If the success count is 0, the command is failed. Otherwise, the command is successful.
- Template:IN, commands that cannot be executed in command blocks have no success count. It is failed when Template:Cmd stores 0, and successful when Template:Cmd stores 1.
- Template:IN, if the command cannot be executed in command blocks or scripts, it still has a success count, but it cannot be obtained.
- Note that when we say that a command is failed or successful, it must not be unparseable, error, void, or terminated. Though when being unparseable, error, void or terminated, the success count is 0, it is not considered as being failed nor successful.
- Note that not all "successful" commands actually do something, and not all "failed" commands fail to do something useful.
List of commands
The tables below will summarize all commands.
Available in Java Edition
Debugging commands
Debugging commands are not accessible by default, but can be enabled using Minecraft:debug properties.
Available in Bedrock Edition and Minecraft Education
Hidden commands
Template:Exclusive These commands are unavailable in general cases. Most of them can be accessed with a Websocket Server, NPC, the Scripting API or cheatsTemplate:Only. Note: You can easily check if a command is still in the game by typing Template:Cmd into a server console, or the ingame chat. If you do so, and it says Syntax error, then the command does not exist. If it either gives help on the command or says unknown command, then it is still in the game - for example, the command Template:Cmd will return Template:Code, while the command Template:Cmd will return Template:Code.
Removed commands
Removed from Java Edition
Removed from Bedrock Edition or Minecraft Education
Developer commands
Template:Main Template:Exclusive Developer commands are only enabled in internal development builds of Bedrock Edition, and are not normally accessible in release versions.
Agent commands
Template:Exclusive Superseded by Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
- Template:Cmd
Joke commands
Template:Exclusive These commands only exist in April Fools' Day joke versions of the game.
History
Template:See also Template:Info needed section
Command additions and changes
Java Edition
Bedrock Edition
April Fools commands
Issues
See also
References
External links
Template:Navbox commands Template:Navbox Java Edition technical Template:Navbox Bedrock Edition Template:Mojang featured
Minecraft:de:Befehl Minecraft:es:Comandos Minecraft:fr:Commandes Minecraft:hu:Szerverparancsok Minecraft:it:Comandi Minecraft:ja:コマンド Minecraft:ko:명령어 Minecraft:lzh:令 Minecraft:nl:Opdrachten Minecraft:pl:Polecenia Minecraft:pt:Comandos Minecraft:ru:Команды консоли Minecraft:th:คำสั่ง Minecraft:tr:Komutlar Minecraft:uk:Команди консолі Minecraft:zh:命令