User:Aeldrion/CommandGuide/Basic commands

In this section, we will a few simple command examples to understand their syntax and we will learn how to use command blocks.

Basic commands
These commands can be executed from the chat. To indicate that you are running a command and not sending a chat message, commands must start with a slash.

Giving an item
The command can be used to give an item to players. Its syntax is as follows:

give [count]

Arguments between chevrons ( and  ) are required and arguments between square brackets are optional. This means that a command can be valid whether or not  is specified. However, a  command missing an   argument is invalid.

The  argument can be the name of a player or a "target selector" (I will go into further detail about target selectors in the next section). Now, you can use your own username or.

The  argument corresponds to an item ID. Item IDs are strings of text that define the item (eg.  or  ). Item IDs are sometimes inconsistent with the item name ( for a chain helmet, for example); you can however see what the ID of a specific item is by enabling advanced item tooltips (F3+H) and hovering over an item in the inventory, or by looking at the Minecraft wiki. Note that Bedrock Edition item IDs and Java Edition item IDs are sometimes not the same. The namespace allows mods to add their own item IDs without conflicting with vanilla items. It is optional but it is a good practice to always specify it, because there are some situations in which specifying the namespace is required.

The  argument specifies the size of the stack of items you want to give. If this argument is not specified, it will default to 1, meaning that a single item will be given.

Here are examples of working  commands:

give @s minecraft:stick give Aeldrion minecraft:golden_apple 4 give @s diamond

Spawning a mob
The command allows to summon a specific type of mob. Similarly to the  command, the type of mob is specified by an ID (eg.  ). The namespace is still optional.

uses the following syntax:

summon  [position] [data]

Right now, we will not use the  and   arguments as we haven't seen coordinates and mob data yet. We will get there eventually.

As you may have noticed, when typing a command, a screen appears with suggestions for the next argument. You can use the tab key to autocomplete this argument and navigate through the list. This way, you can find any mob ID (or item ID) and see if an ID is invalid.

Here are examples of working  commands:

summon minecraft:llama summon minecraft:zombie_villager summon shulker

Displaying text in the chat
The command allows to display text in the chat. It is often used to verify if a command is working successfully while debugging as its syntax is very simple and the message can be seen by every player.

Its syntax is as follows:

say 

Unlike most arguments, the chat message in  can contain spaces.

Here are examples of working  commands:

say Hello world! say My name is Aeldrion say Why am I even bothering with these, it's impossible to have an invalid say command

Using command blocks
Command blocks are blocks that can run commands automatically when receiving any kind of redstone input. Command blocks are not obtainable in the creative inventory; they can however be obtained using a command:

give @s minecraft:command_block

Running a command
Once a command block is placed, you can right-click on it to access its UI. The top entry is where you can write the command that will be running. The second entry is the output: when the command runs, this entry will display the time it ran and what happened. If the command does not succeed, it will also output an error message in this entry.

Here's a little demonstration: by writing  in the command block, clicking on "Done" and placing a pressure plate next to the command block, I can get a stack of cobblestone every time I stand on the pressure plate.

Impulse/repeating/chain
Command blocks have three modes that will change their color and their functionality. By default, command blocks are on "Impulse" and are orange. This means that every time they receive a redstone signal, they will run a command. You can click on Impulse to change the mode of a single command block. When a command block is set to "repeating", it will turn purple and run its command every game tick the command block is powered. The game tick (or tick) is the shortest unit of time commands can run at; there are twenty ticks per second, which means that if a repeating command block is powered by a redstone block, it will run its command twenty times a second. You should be careful when using repeating command blocks: for example, if you were to leave a repeating command block running with one of the summon commands above, it could spam your world with a huge number of mobs quickly and you could lose control of the command block because of all the mobs between the command block and you.

A chain command block runs its command when an adjacent command block that points in its direction runs while it is powered. This is useful to make multiple commands execute at the same time. You could for example make a chain of command blocks that gives you several items from a kit. Note that nothing really happens at the same time: the commands in the chain will happen in the same game tick, but in the order of the chain.

Needs redstone/Always active
By default, command blocks need a redstone input to run. By clicking on Needs redstone, you can switch a command block to always active, making them able to run without a redstone signal. For impulse command blocks, this means that they will run once the player validates the command, then they will stop working. For chain command blocks, this means that they will run as soon as the previous block in the chain runs, making it possible to create command block chains without having to keep all chain command blocks activated. For repeating command blocks, this means that they will constantly run.

Command block chains
It is possible to run several commands every tick using a repeating command block followed by several chain command blocks facing one another. This is often used in command block projects because it allows command artists to keep their commands in the order they specified and because it is more efficient than using repeating command blocks for everything.