Difference between revisions of "Commands"
(7 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
== Using Commands == | == Using Commands == | ||
− | + | To use commands, the world must have cheats enabled. Cheats can only be enabled on the world creation screen, and cannot be enabled after a world has already been created. | |
The default key binding for opening the command console is "T". This can be changed in the game settings. When the console is open, the player can write a command, and execute it by pressing Enter. | The default key binding for opening the command console is "T". This can be changed in the game settings. When the console is open, the player can write a command, and execute it by pressing Enter. | ||
− | + | When commands are entered, the capitalization of letters does not matter. | |
− | |||
− | |||
− | + | === Reading Command Definitions === | |
+ | Below is a list of command definitions (instructions on how each command works). The definitions include two different types of brackets: | ||
+ | # Parameters between <code><</code> and <code>></code> angle brackets is a list of potential options. Each option is separated by a <code>|</code> "pipe" character. If an option contains multiple parameters, as seen in the <code>fill</code> command, it will be surrounded by parentheses. As an example, in <code>/gamemode <survival|creative|adventure|spectator></code>, you can write <code>/gamemode survival</code>, <code>/gamemode creative</code>, <code>/gamemode adventure</code>, or <code>/gamemode spectator</code>. | ||
+ | # Parameters between the <code>[</code> and <code>]</code> square brackets are ''optional'' parameters. When writing a command, you can skip optional parameters. For example, in <code>/lightning [[~]x [~]y]</code>, you can omit both the <code>[~]x</code> and <code>[~]y</code> parameters, like so: <code>/lightning</code>. Also, the <code>[~]</code> means you can use relative coordinates. | ||
+ | |||
+ | The <code>~</code> character can be added before certain coordinate numbers to make the coordinate relative to your position in the world, instead of relative to block (0, 0). For example, running <code>/explode 5 ~3 ~0</code> will perform a size 5 explosion, 3 blocks to the left of the player. | ||
== List of Commands == | == List of Commands == | ||
Line 52: | Line 55: | ||
| Removes items from the inventory, but also returns a message if the specified item is present. | | Removes items from the inventory, but also returns a message if the specified item is present. | ||
| | | | ||
− | <code>/clear itemname [quantity|-1] [damage] [data_tags]</code> | + | <code>/clear itemname [<quantity|-1>] [damage] [data_tags]</code> |
* <code>itemname</code>: The [[identifiers|identifier]] for the item to remove. | * <code>itemname</code>: The [[identifiers|identifier]] for the item to remove. | ||
* <code>itemname</code>: The quantity of items to be removed. -1 means all present in the inventory | * <code>itemname</code>: The quantity of items to be removed. -1 means all present in the inventory | ||
Line 71: | Line 74: | ||
| Clones part of the world and pastes it somewhere else, with data tags for blocks. | | Clones part of the world and pastes it somewhere else, with data tags for blocks. | ||
| | | | ||
− | <code>/clone [~]x1 [~]y1 width height [~]xDest [~]yDest [filtered|masked|replace] [force|move|normal] block_mask</code> | + | <code>/clone [~]x1 [~]y1 width height [~]xDest [~]yDest [<filtered|masked|replace>] [<force|move|normal>] block_mask</code> |
* <code>[~]x1 [~]y1</code>: The x and y coordinate to start cloning from. | * <code>[~]x1 [~]y1</code>: The x and y coordinate to start cloning from. | ||
* <code>width height</code>: How many blocks rightward (width) and upward (height) to clone. | * <code>width height</code>: How many blocks rightward (width) and upward (height) to clone. | ||
Line 97: | Line 100: | ||
! | ! | ||
=== enchant === | === enchant === | ||
− | | Applies an enchantment to the player's | + | | Applies an enchantment to the player's held item. A message will appear saying that the enchantment has been "added to selected item". If the player is holding nothing, the message that the held item has been enchanted will still appear. |
| | | | ||
− | <code>enchant enchantment_id</code> | + | <code>/enchant enchantment_id</code> |
− | * <code>enchantment_id</code>: See list of enchantment ID's here: [[ | + | * <code>enchantment_id</code>: See list of enchantment ID's here: [[Enchanting#Commands|Enchantments]] |
| | | | ||
* <code>/enchant Unbreaking4</code> | * <code>/enchant Unbreaking4</code> | ||
Line 120: | Line 123: | ||
! | ! | ||
=== fill === | === fill === | ||
− | | Fills a region of blocks with the specified block type | + | | Fills a region of blocks with the specified block type. |
| | | | ||
− | <code>fill block_type [~]x [~]y width height [(replace [replace_block_type])|keep|outline|hollow|destroy] [data_tags]</code> | + | <code>/fill block_type [~]x [~]y width height [<(replace [replace_block_type])|keep|outline|hollow|destroy>] [data_tags]</code> |
* <code>block_type</code>: The [[identifiers|identifier]] for the block to fill. | * <code>block_type</code>: The [[identifiers|identifier]] for the block to fill. | ||
* <code>[~]x [~]y</code>: The x and y coordinate to start filling from. | * <code>[~]x [~]y</code>: The x and y coordinate to start filling from. | ||
Line 162: | Line 165: | ||
| Sets global variables in the game world, such as the ability for players to keep their inventory when they die. | | Sets global variables in the game world, such as the ability for players to keep their inventory when they die. | ||
| | | | ||
− | <code>/gamerule < | + | <code>/gamerule rule <value></code> |
| | | | ||
* <code>/gamerule keepinventory true</code> | * <code>/gamerule keepinventory true</code> | ||
Line 181: | Line 184: | ||
| Gives the player any block or item. | | Gives the player any block or item. | ||
| | | | ||
− | <code>give item [amount] [damage] [data_tags]</code> | + | <code>/give item [amount] [damage] [data_tags]</code> |
* <code>item</code>: The [[identifiers|identifier]] for the item to give. | * <code>item</code>: The [[identifiers|identifier]] for the item to give. | ||
* <code>amount</code>: Specifies how many of the item to give. | * <code>amount</code>: Specifies how many of the item to give. | ||
Line 223: | Line 226: | ||
! | ! | ||
=== lightning === | === lightning === | ||
− | | Generates lightning | + | | Generates lightning. |
| | | | ||
<code>/lightning [[~]x [~]y]</code> | <code>/lightning [[~]x [~]y]</code> | ||
Line 234: | Line 237: | ||
! | ! | ||
=== say === | === say === | ||
− | | Returns the specified message in chat | + | | Returns the specified message in chat. |
| <code>/say message</code> | | <code>/say message</code> | ||
| | | | ||
*<code>/say hello world</code> | *<code>/say hello world</code> | ||
**Returns the message "hello world" in chat. | **Returns the message "hello world" in chat. | ||
+ | * <code>/say hello \n world</code> | ||
+ | *: Returns the message with a line break after \n. | ||
|- | |- | ||
! | ! | ||
Line 244: | Line 249: | ||
| Replaces the existing block with the specified block. | | Replaces the existing block with the specified block. | ||
| | | | ||
− | <code>/setblock block_type [~]x [~]y [replace|keep|destroy] [data_tags]</code> | + | <code>/setblock block_type [~]x [~]y [<replace|keep|destroy>] [data_tags]</code> |
* <code>block_type</code>: The [[identifiers|identifier]] for the block. | * <code>block_type</code>: The [[identifiers|identifier]] for the block. | ||
* <code>[~]x [~]y</code>: The x and y coordinate where the block is put. | * <code>[~]x [~]y</code>: The x and y coordinate where the block is put. | ||
Line 293: | Line 298: | ||
| Sets/shows the current time of the day, which is a value between 1 and 100. | | Sets/shows the current time of the day, which is a value between 1 and 100. | ||
| | | | ||
− | <code>/time <get|set | + | <code>/time <get|set <t|day|night>></code> |
| | | | ||
* <code>/time get</code> | * <code>/time get</code> | ||
Line 416: | Line 421: | ||
* Maximum horizontal tp coordinate is now 10000 instead of 1100 | * Maximum horizontal tp coordinate is now 10000 instead of 1100 | ||
* (Desktop) Gamerule command now accepts the value "true" | * (Desktop) Gamerule command now accepts the value "true" | ||
+ | |- | ||
+ | ! [[Version History#1.31.2|1.31.2]] | ||
+ | | Nov 9, 2024 | ||
+ | | | ||
+ | * Added the whisper command to the Scavenger Hunt Minigame | ||
|} | |} | ||
Latest revision as of 17:09, 16 November 2024
Commands (also known as Cheats) are scripted codes that the player can write in the game console that change the game directly.
Using Commands
To use commands, the world must have cheats enabled. Cheats can only be enabled on the world creation screen, and cannot be enabled after a world has already been created.
The default key binding for opening the command console is "T". This can be changed in the game settings. When the console is open, the player can write a command, and execute it by pressing Enter.
When commands are entered, the capitalization of letters does not matter.
Reading Command Definitions
Below is a list of command definitions (instructions on how each command works). The definitions include two different types of brackets:
- Parameters between
<
and>
angle brackets is a list of potential options. Each option is separated by a|
"pipe" character. If an option contains multiple parameters, as seen in thefill
command, it will be surrounded by parentheses. As an example, in/gamemode <survival|creative|adventure|spectator>
, you can write/gamemode survival
,/gamemode creative
,/gamemode adventure
, or/gamemode spectator
. - Parameters between the
[
and]
square brackets are optional parameters. When writing a command, you can skip optional parameters. For example, in/lightning [[~]x [~]y]
, you can omit both the[~]x
and[~]y
parameters, like so:/lightning
. Also, the[~]
means you can use relative coordinates.
The ~
character can be added before certain coordinate numbers to make the coordinate relative to your position in the world, instead of relative to block (0, 0). For example, running /explode 5 ~3 ~0
will perform a size 5 explosion, 3 blocks to the left of the player.
List of Commands
Command | Description | Definition | Examples |
---|---|---|---|
help |
This command is always available, even if cheats are disabled.
Lists all of the possible commands. |
/help
|
/help
|
seed |
This command is always available, even if cheats are disabled.
Shows the seed number of the current world. |
/seed
|
/seed
|
cheats |
This command will only exist if the world was created prior to 1.26.5 (when cheats were added to the game).
It allows players to permanently enable or disable cheats in their world. |
|
/cheats enable
|
clear |
Removes items from the inventory, but also returns a message if the specified item is present. |
|
|
clone |
Clones part of the world and pastes it somewhere else, with data tags for blocks. |
|
|
cls |
"cls" stands for "clear screen". This command clears console messages from the screen. | /cls
|
/cls
|
difficulty |
Sets the difficulty mode of the world. |
|
|
enchant |
Applies an enchantment to the player's held item. A message will appear saying that the enchantment has been "added to selected item". If the player is holding nothing, the message that the held item has been enchanted will still appear. |
|
|
explode |
Creates an explosion. |
|
|
fill |
Fills a region of blocks with the specified block type. |
|
|
gamemode |
Switches between the game modes. |
|
|
gamerule |
Sets global variables in the game world, such as the ability for players to keep their inventory when they die. |
|
|
give |
Gives the player any block or item. |
|
|
heal |
Instantly heals the player. | /heal
|
/heal
|
home |
Teleports to the player's spawn point. |
|
|
kill |
Instantly kills the player. | /kill
|
/kill
|
lightning |
Generates lightning. |
|
|
say |
Returns the specified message in chat. | /say message
|
|
setblock |
Replaces the existing block with the specified block. |
|
|
spawnskin |
Spawns in an NPC (non-player character) into the game. You need to have a skin ID for the NPC, which can be found on skin information in the skin database. |
|
|
summon |
Spawns in a mob. |
|
|
time |
Sets/shows the current time of the day, which is a value between 1 and 100. |
|
|
tp |
Teleports (TPs) the player to a specific location. |
|
|
weather |
Sets/shows whether it is raining in the world, or not. |
|
|
xp |
Sets the experience points of the player. |
|
|
History
Version | Date | Changes |
---|---|---|
1.26.5 | Jul 03, 2014 |
|
1.27 | Nov 13, 2015 |
|
1.28 | Oct 08, 2016 |
|
1.29 | Sep 27, 2019 |
|
1.29.1 | Oct 5, 2019 |
|
1.29.2 | Oct 20, 2019 |
|
1.30 | Nov 13, 2020 |
|
1.30.3b | Nov 21, 2021 |
|
1.30.3b_1 | Dec 5, 2021 |
|
1.31.2 | Nov 9, 2024 |
|