User:Aeldrion/CommandGuide/Introduction to commands

The command system is a system that allows players to manipulate a Minecraft world without the use of mods. The first commands were added in Java Edition Classic 0.0.15a. Over the years, commands have gone throughout many changes and can now be used together to create impressive command contraptions. In this guide, I will explain how commands work and how you can make your own command creations.

'''Note: This guide is for Java Edition 1.14.2. Other versions and editions may be incompatible.'''

Commands
Commands are strings of text that can be executed to affect the world in different ways. There are different types of commands (eg. summon, give, teleport) who each have their own syntax.

Here is an example of a command thay will give a diamond to the nearest player:

give @p minecraft:diamond

Running a command
Commands can be ran or executed through different means. The oldest and easiest way of running a command is by writing it in the chat preceded by a slash. On a server, commands can solely be executed by players with operator rights. In Singleplayer mode, commands can be used if “Allow cheats” was set to ON when creating the world.

Command syntax and arguments
Commands are composed by a list of words called “arguments”. Some arguments are necessary, and some are optional and may be omitted. If a command written by a player does not have the correct syntax, it will fail to execute.

Chat
Commands can be executed from the chat. This method is very limited as it only allows users to execute commands ponctually and not dynamically, and as the length of a command is limited by the maximum length of a chat message. To create dynamic command contraptions, the use of command blocks or data packs is necessary.

Command blocks
Command blocks are blocks that can run commands when receiving a redstone signal. Added in Java Edition 1.4, they allow to create dynamic command mechanisms, unlike running commands manually from the chat.

Although data packs are a better alternative to command blocks in term of functionality, practicality and efficiency, we will use command blocks in the first chapter of this guide, as creating a data pack can be complicated.

A command block can be obtained using the following command:

give @s minecraft:command_block

Data packs
Data packs are folders created by users and located in a world's save folder. They contain various files (advancements, recipes, structures, loot tables, functions and tags) that may affect the world in different ways.

Functions are files contained in data packs that can run a list of commands without the necessity of a physical presence in the world. They have many advantages over command blocks and we will use them once we learn how to create datapacks.

Version
The command system hasn't always been the same and may change between versions. The syntax of some commands can be tweaked from a version to another, and commands can be added or removed. Therefore, a command that works in a specific version may not be able to run in a previous or future version.

Edition
The command system isn't the same in all Minecraft editions either. A command that works on Java Edition may not work on Bedrock Edition.

Mods
The use of mods and plugins may interfere with commands. This guide is only for vanilla Minecraft. "Vanilla" means the game is not modified by any mod or plugin.