I want to teleport a player to a location relative to another. For example, I might want to teleport Steve so that he's exactly 50 blocks on top of Joe.

I can't use /tp, since that will teleport Steve directly onto Joe's location. Is there a way I can teleport someone to somebody else's location, but with an offset? I'd like to do this with a single command, if possible.

6 Answers

The /tp command accepts relative arguments (~), but you won't be able to do it in a single command. You may wish to use a pair of command blocks to execute them quickly and more or less seamlessly.

The following will teleport Steve to Joe, then zero blocks forward (in the x direction), fifty blocks up (in the y direction), and zero blocks to the side (in the z direction).

/tp Steve Joe /tp Steve ~ ~50 ~ 

The format is as follows:

 /tp [player] <x> <y> <z> [<y-rot> <x-rot>] 

More information can be found on the Official Minecraft wiki:

execute Joe ~ ~ ~ teleport Steve ~ ~50 ~

for teleport command, the relative coordinate is of the executor, but not the teleported entity.

1
/execute Joe ~ ~50 ~ /tp Steve @p 

execute will make Joe execute it but the ~ ~50 ~ would make it execute 50 blocks above Joe's feet because relatives (~) on entities alway count from the bottom block (that is the case with blocks sometimes too, ie. doors and two-block plants). Steve is the parameter which tells the game who to teleport.

/execute Joe ~ ~50 ~ /tp Steve @p 
1

You can do the following:

/execute Joe ~ ~ ~ /tp Steve ~ ~50 ~ 

I hope this helped.

1

Well, you could teleport with coordinates.

/tp username (or @p, @a ect if you are making a custom map) x y z

XYZ are available to you when you press f3.