/tp Relative Coordinates
As most minecraft command makers know, entering ~
instead of a coordinate number results in the relative position of the executing entity. Apparently, the /tp
command has a special property with relative coordinates.
I am trying to make a command that teleports all other entities to the same position as the player, but on a absolute Z value. This will make a third person, 2D-looking effect. Here's my command:
execute @p ~ ~ ~ /tp @e[type=!Player,r=20] ~ ~ -645
This does not work. In the /tp
command, it appears that the ~
s are no longer relative to the executing entity, but the entity being teleported.
A similar command works like I expect it to. It places a block at the player's position, but again at a fixed z position:
execute @p ~ ~ ~ /setblock ~ ~ -650 minecraft:stone
I am wondering how to make the ~
s in the /tp
command to execute relative to the executing entity, not the entity being teleported.
Both the commands are inside a repeating, non-conditional, redstone-requiring command blocks. They are both powered by levers.
I am on Minecraft 1.12 Mac edition, singleplayer world.
Any help is appreciated! Thanks in advance!
execute @p ~ ~ ~ /teleport @e[type=!player,r=20] ~ ~ -645
teleport
is a command added in 1.10 that behaves exactly like tp
, except that coordinates are relative to the executor.