Coordinates
Everything in minecraft has coords (Coordinates) and with commands you can execute or specify where a absolute, relative, or local position is.
With using coords in minecraft it always has 3 values x, y, and z. When pressing F3 on your keyboard it pops up and the upper left hand side
there should be a XYZ coord display.
Axis directions
| Axis | Direction |
|---|---|
| X+ | East |
| X- | West |
| Y+ | Up |
| Y- | Down |
| Z+ | South |
| Z- | North |
Absolute coordinates
Running a simple /tp command like so:
tp @p 100 64 -20
Means:
- X = 100
- Y = 64
- Z = -20
This teleports you to that exact location in world space. That means it won't change and will stay absolute in any setting or dimension.
Relative coordinates
Lets run another /tp command but use the relative symbol~.
tp @p ~0 ~2 ~0
What this command does is it executes at your position, thats what ~ does!
Mixing relative with absolute
You can mix both relative coords with absolute coords as they use the same world coordinate system.
An example of this would be:
tp @p 100 ~5 -20
Aligning with block grid
You can use execute align with the coordinate system, though just using that will align with the block grid.
An example of snapping the nearest player to the middle top/bottom of a block face:
execute align xyz run tp @p ~.5 ~ ~.5
The snapping points are X, Y, and Z respectivly.
Local coordinates
These are coordinates that directly use your pitch and yaw for entities. To start out the coordinates use ^ for all three positions.
This command is up 2 blocks relative to where the player is looking at:
tp @p ^ ^2 ^
Here is an example of how local coordinates ^ effect where its position is.
| Axis | Direction |
|---|---|
| X+ | Right |
| X- | Left |
| Y+ | Up |
| Y- | Down |
| Z+ | Forward |
| Z- | Backward |
Local coords limitation
Due to the different coordinate spaces being used, we can't mix world coordinates with entity coordinates.
That is why this command fails to load:
tp @p ~ ~ ^5
Or even
tp @p 0 0 ^5
Rotational coordinates
Entities with having coordinates also can look anywhere. When using it, usually it's only offered up in the /tp command or any command that can execute as an entity.
These coordinates are yaw and pitch.
Yaw Rotations
| Value | Direction |
|---|---|
| 0 | South |
| 90 | West |
| 180 | North |
| -90 | East |
Pitch Rotations
| Value | Direction |
|---|---|
| -90 | Up |
| 0 | Horizontal |
| 90 | Down |
Using Rotation in the /tp command looks something like this:
tp @p ~ ~ ~ 90 0
Relative rotation
You can also use the relative ~ coordinates with rotational coordinates.
And example of a 45 degree turn would be:
tp @p ~ ~ ~ ~45 ~
Facing coords/entities
You can also force an entity to look at a block or entity.
This example shows a player looking at block 0 100 0.
tp @p ~ ~ ~ facing 0 100 0
You can also use relative coords with this too,
tp @p ~ ~ ~ facing 0 ~ 0
This is an example of an entity with type= zombie facing the nearest player
execute as @e[type=zombie] at @s run tp @s ~ ~ ~ facing entity @p eyes
Reference
Information:
https://apexminecrafthosting.com/guides/general/how-to-tp-to-coordinates-in-minecraft/
https://minecraft.wiki/w/Commands/execute
https://minecraft.wiki/w/Coordinates
https://minecraft.makecode.com/courses/csintro/coordinates/overview