Table of Contents
Table of Contents
- Command Tutorial
- Exporting a Map
- Functions Structure
Written by VideoCarp
Estimated Read Time: 6:58 (minutes)
Firstly, since you’re new I recommend reading to full.
Commands are bits of text that the game Minecraft understands, they can get quite advanced, but they’re easy to pick up and learn.
Commands are very useful, they’re great to work with, even when making addons, written in JSON, they can help.
Most maps are also made using Minecraft commands, they’re very helpful.
Firstly I’m going to cover some logic, this is probably the most important part. There’s a lot to cover, but I’m mostly going to be covering the beginner’s basics.
In Minecraft, there are 2 types of things, as a summary. Those 2 things are entities and blocks. You might’ve heard of those a lot, and they’re very important.
Here are some of the basics, read above for a bit of how to read this.
A block is essentially an object that takes up a 1x1 space. An example of a block would be say grass, dirt, etc. Everything in the below image is a block, don’t worry about the water just yet.
An entity as I like to think of it is any object that is not fixed to it’s position, and can take damage. Water isn’t fixed to it’s position, is it an entity? No, the reason for that is because water cannot take damage.
All mobs, but NOT only mobs are entities. Below is an example of an entity.
Now that you know what entities and blocks are, that’s a step forward.
A quick explanation I’ll give about syntaxes is that they’re the format of the command, if your command doesn’t
execute, then there’s a chance it’s that. Give all syntax errors a full read, if they don’t work, take reference
from either the wiki, gamepedia, or the
/help <command-name> command while in game.
An example of a syntax error is:
/kill @ e. That specific one will be raised because there is a space between the
@ and the
e. We’ll go deeper into these
@ things in a bit. Below is an example of a syntax error. This most likely happened because the person didn’t put an argument afterwards, but don’t worry too much.
Here’s a quick sumnary, it isn’t really accurate (I personally don’t read them and somehow know it):
Don’t try to memorize the
something: type ones if you don’t understand.
<text_here>. These brackets mean that this argument is required.
[text_here]. These brackets mean that this argument is optional.
(option1 | option2). These brackets mean that this argument must be one in the list.
|. This character in a bracket means ’or‘.
something: int. If
: intis after something, that means the argument must be a whole number, also known as integers.
something: string. If these are after something, that means the argument must be text, also known as string or str.
something: double. If these are after something, that means the argument has a decimal place.
This is a crucial part in commands.
To put it in my way, coordinates are really just the location of an object. But how do you know the coordinates?
How are coordinates formatted? Well, regarding both of them, there are three axes, namely X, Y, and Z.
How are they formatted?
They are formatted in the standard way,
x y z, and you’ll see more about those later.
How does one get the coordinates of something?
It’s quite simple to do this, you do not need to teleport yourself. You can simply run this command:
/gamerule showcoordinates true and your coordinates should show at the top left. Once they’re showing, read the numbers after
Position. It should look somewhat like this:
Position: X, Y, Z. If it doesn’t show exactly like that, don’t panic. X, Y, and Z are used to represent the number, whatever it is, is where your legs are. We’ll be getting into
tildes on the next section, they will be necessary.
Tildes are the
~ character, which in English means about, near, or here.
Same thing goes for coordinates in Minecraft.
Each tilde in a command represents from where the command is being executed, and math can be done on those.
To add to the coordinate:
~<number>. This goes for all X, Y, and Z axes. You can also use
To remove from the coordinate:
~-<number>. Note the
-. This goes for all axes.
Say you want the player to teleport 10 blocks upwards, remember the Y axis is vertical.
tp <target> ~ ~10 ~.
Now what is
target you may ask. Target means the entity the command is being executed on.
This command moves the player 10 blocks up from the command block if there is one, or the person who executed it.
Don’t worry yet about making the player do it, we’ll cover it now.
‘Caret Notation’ is another important part in Minecraft commands, it is local coordinates, it’s a bit like tildes, however it’s based on direction. Here’s a quick summary:
XThe X axis moves player to the left.
YThe Y axis moves player up.
ZThe Z axis moves player forward.
You may have thought that not all directions are covered in Caret notation, but really, they are. Tildes and Carets both take
-, so to go backwards, you can teleport the player using
^ ^ ^-1, and that will send the player 1 block backwards.
- in carets will go to the opposite direction of the axis,
down are done the same way as backwards, except with the different coordinate. Both carets and tildes are
X Y Z (
^ ^ ^).
This section is on how to manage entities. There are a lot of commands that can affect entities, but here I’ll cover the crucial ones.
It’s very easy to delete an entity, you can simply use the kill command to delete an entity. But what if you wanted to delete a dropped item, or perhaps a specific mob? Below is more info.
You can use the target selector argument, which I will be specifying information about right here. You can use the
@e targetting, but further than that is what we’ll be focusing on.
Target Selectors What are these? Well, I like to explain these as the main argument in selecting which entity to use.
A list of each one of them, and what they do is below:
@pThis selects the nearest player from where the command was executed.
@rThis selects a random player in the world who is online.
@sThis selects the entity that executed the command. All entities, not only players included.
@aThis selects all the players.
@eThis selects all entites.
For example, I want a creeper to say
Aww man in the chat, I’d use:
execute @e[type=creeper,name="creep.er"] ~ ~ ~ say Aww man.
You see those things in the
 brackets? They will be covered next.
@e[type=<entity_type> will select a specific type of entity, this could be TNT, a dropped item, a specific mob type, etc, it can find any entity type. But what if you wanted a specific entity?
@e[type=<entity_type>,name=<name>. With that, you’ll find one of a name.
A very common issue I find others doing is when they’re getting the name, they usually forget to add quotes after the
= sign. If the mob has a space in the name, simply instead of
<name>, imagine it becomes
name argument may be ugly, and so here is an alternative, this is also a way to group entities.
/tag <target> (add | remove) <name: string>.
This will add a new group to the targetted entity, after adding it you can remove the name, if there is one.
string means to add quotes, just like the name in the target selector. In commands, and programming,
string is just text data, which in most cases are set by
". In Minecraft, use
An example of a string is:
"Hello World!". In Minecraft, if you wrap with these quotes, you can use any character for any argument, including spaces. You may want to check for the range, here’s how:
In most guides,
number will be represented as
integer. They both mean a number. However, an
int is not
double (if you’re unsure ignore those two words), it cannot take a decimal value.
1.01 for example, is not an integer. An integer is just a whole number.
This is an extremely important section! This section is fully dedicated to making entities execute a command, think of it as
sudo, but for commands.
The execute command is the most powerful command in the entire game, but don’t worry, it isn’t hard to pick up on.
/execute <target> <location> <selected command syntax> is the syntax.
<selected command syntax>
refers to the command you’re getting the entity to execute. I always have my location as
~ ~ ~ and when it’s
like that, it executes anywhere, that’s at least what I use for myself.
But what if you wanted to check if someone was on a specific block type?
execute <target> <position> detect <detectPos> <block_to_detect> <data value> <command>.
That would be your syntax.
detect isn’t in brackets, this means to just put it there, regardless.
Say you wanted a creeper walking on grass to kill nearby ocelots, you’d use this: ` /execute @e[type=creeper] ~ ~ ~ detect ~ ~-1 ~ grass kill @e[type=ocelot]`
Quick notice, when stuck, try to use use effect, armor stands, tags and names.
Visit here to see how to.
Functions are very simple to make, here’s a basic folder structure: Functions are a way to kinda import a ton of commands into new worlds easily, unlike command blocks however, they cannot be conditional.
When you run the
function command, it executes the .mcfunction file named by your argument.
For example, a file named
cool_file.mcfunction will execute if you return the argument as
cool_file in other words,
/function cool_file , however, if a different argument is written, the game will search for the
.mcfunction file named by that, if none, the command will fail.
.mcfunction files are always filled with nothing but commands.
Now for the folder setup.
Function Pack Structure:
(your pack name)📂
Here are some open-source examples of raw commands on GitHub.