Teleport, kill, say, execute
Here are some basic commands that can be called by command blocks. Also, many commands have modifiers attached to them that narrow the scope of the command. Commands that modify items and inventory, summon entities and modify the environment will be covered in later lessons. You can generally check the syntax of a command by typing it in the console.
There are several parts of a command that are used frequently. They are:
This video shows the /teleport command being called by command blocks in a space facility. You can download the map here.
The /teleport or /tp command allows you to move a player, monster or other entity to another location. The command is /tp followed by X Y Z coordinates to teleport to a location (/tp 3 34 -12), /tp followed by a target selector and coordinates (/tp @a ~ ~ ~), or /tp followed by two target selectors to transport entities to another entity (/tp @e @s). You can't teleport to more than one entity though.
Syntax:
/teleport X Y Z
/teleport [target selector[argument=value]] X Y Z
/teleport [target selector[argument1=value1] [target selector 2[argument2=value2]]
You can also add a true or false to prevent it from telporting you into a block.
You can also add "facing" with a target (either entity or coordinate) to set the direction after teleporting.
Here are some examples:
Some times you just need to kill some things. This command makes it easy. The command is just "kill" followed by a target. Be careful though because some objects such as minecarts and armor stands are actually considered entities.
Syntax: /kill [target selector[argument=value]]
Here's some examples of kill commands:
The say command makes an entity say a phrase. The tell command has one entity whisper text to another entity. They are a great way to tell players what is happening when they activate a command block.
Syntax:
/say [target selector[argument=value]] [phrase]
/tell [target selector[argument=value]] [phrase]
Here's some examples:
The execute command is one of the most important commands. It allows you to create more complex actions by having entities be the ones who execute the commands. A command block can't modify its own inventory or enchant its own weapons. It uses the /execute command to call the commands on entities (or in relation to their positions in some cases). The format is /execute followed by XYZ coordinates and then the command.
Syntax:
/execute [target selector[argument=value]] X Y Z [command]
Previous lesson: Chaining blocks | Next lesson: Summoning entities