Tp From Relative Position to Another Relative Position
1.12
This is actually a surprisingly hard thing to do with 1.12 commands. The only way I found is with a marker entity, the command inside the command block is then:
summon armor_stand ~ ~ ~ {Tags:["teleportMarker"],NoAI:1,NoGravity:1,Invisible:1,Marker:1}
Execute this command inside the command block only once per block. How you do that depends on your system.
Then tag everybody in your first area:
/execute @e[tag=teleportMarker] ~123 ~456 ~789 scoreboard players tag @a[r=42] add toTeleport
Then teleport them to the second area:
/tp @a[tag=toTeleport] ~987 ~654 ~321
Then clean up:
/scoreboard players tag @a[tag=toTeleport] remove toTeleport
And when you're done teleporting people around, you can kill the marker amour stands again:
/kill @e[tag=teleportMarker]
Killing only one of the markers works best with whatever you use to place/activate the command blocks, since that already knows the coordinates of that command block and therefore also of the armour stand.
1.13
In 1.13 you don't need a marker entity, since there is now /execute positioned
. So you can just put
execute positioned ~123 ~456 ~789 run tag @a[distance=..42] add toTeleport
into the command block instead of summoning an entity and then executing from it.