How do you teleport a player to a moving objective?

I created a big adventure map and I was able to do lots of amazing things I never thought possible with redstone, but I came across a problem I was baffled by.
I have a house in minecraft that is movable. I want to know of a way I can teleport directly to my house using a command block. The catch is that my house is never in the same spot so the x,y,z coordinates are constantly changing.
One way I thought of that might possibly work would maybe have a clock set up to record my radius around my house using /setspawn so I'll constantly have my spawn position recorded; however, this isn't very good for teleporting as I would have to kill myself. There's a possible way of keeping your inventory after you die, but you would still lose exp. I don't really like the idea of dying to re-spawn as a "tele". It seems as though I'm trying to fit a square peg into a round hole.
Anyone have any ideas of a way to actually teleport using a command block to some how record your current x,y,z position in a certain radius? I am also open to plugin suggestions;however, I don't like releasing a map that requires a bunch of plugins.
Oh btw I'm on a 1.7.10 build. I know the 1.8.0 added a lot of new commands.
Best Answer
To teleport a player to a movable location, you'll need to use an entity. Summon a custom named entity, such as a WitherSkull, like this:
/summon WitherSkull ~ ~ ~ {CustomName:"HomeMarker",direction:[0.0,0.0,0.0]}
You haven't detailed how your house moves, but when it does, move this WitherSkull too.
Then, whenever you need to teleport back home, run something like this:
/tp @p @e[name=HomeMarker,type=WitherSkull]
Keep in mind that you cannot teleport to an unloaded entity, although if this house is "constantly" moving then you must already have it loaded.
Pictures about "How do you teleport a player to a moving objective?"



What is the command to teleport a player to you?
You can teleport other players, too. Just type their username before the coordinates \u2014 so if you're trying to teleport a player named JohnDoe, you'll type: /tp JohnDoe 70 70 70. And if all you want is to teleport yourself to JohnDoe (or any other player), just type: /tp JohnDoe.How do I teleport a player to an object in unity?
This works in both creative and survival modes. On Xbox 360/ Xbox One press B, on PS3/4 press circle, and on WiiU/ Switch press B. Press the 'back/select button on your controller. Select the player you want to teleport to from the list and you will be sent straight to their location.HOW TO TELEPORT OBJECTS IN UNITY 🎮 | Teleport Player and GameObjects in Unity | Unity Tutorial
More answers regarding how do you teleport a player to a moving objective?
Answer 2
I thought of a different solution, this one should work in 1.7.
One way I thought of that might possibly work would maybe have a clock set up to record my radius around my house using /setspawn so I'll constantly have my spawn position recorded; however, this isn't very good for teleporting as I would have to kill myself. There's a possible way of keeping your inventory after you die, but you would still lose exp. I don't really like the idea of dying to re-spawn as a "tele".
Rather than killing yourself to return to spawn, you could teleport yourself to the end's overworld portal, which returns you to your spawnpoint.
You'll need to have an end portal block somewhere in the overworld to get players to the end. Teleport players to that first, then from the end teleport them to the overworld portal. This should return them home, although it will cause two loading screens.
Answer 3
Get singleplayer commands. (or another thing that does similar stuff.) have a clock repeating /setspawn to teleport there via command block simply use /home command added by singleplayer commands.
Answer 4
Same concept as the last answer, though using the /spreadplayers
command. Note this will teleport the player to the highest Y coordinate possible, so then you need another command block to teleport the players down.
Setup:
/scoreboard objectives add teleport dummy
Command ran in house:
/spreadplayers ~ ~ 0 1 false @a[score_teleport_min=1]
/scoreboard players set @a[<Area in which the player is teleported>] teleport 0
Teleport Command Block:
/scoreboard players set @p teleport 1
Answer 5
While I recognize that the existing answers provide all the details needed to accomplish this for Java edition (and that the question itself is focused on Java edition), this can also be achieved in Bedrock edition, though it's not immediately obvious on how. As such, this answer targets Bedrock edition exclusively, based on the currently, most popular answer.
The underlying concept is the same:
To teleport a player to a movable location, you'll need to use an entity. Summon a custom named entity, such as a WitherSkull, like this:
/summon WitherSkull ~ ~ ~ {CustomName:"HomeMarker",direction:[0.0,0.0,0.0]}
However, in Bedrock edition, skulls aren't considered entities. It's common to use an armor_stand
instead:
summon armor_stand HomeMarker ~ ~ ~
This command summons an armor_stand
at the command's execution location, named "HomeMarker". From here, the concept stays the same in that you'd use the tp
command to teleport to the armor_stand
:
tp @s @e[type=armor_stand,name=HomeMarker]
Answer 6
Use relative coordinates of a command block to teleport all marked players to the desired area
SetUp:
/scoreboard objectives add teleport dummy
Command ran in house:
/tp @a[score_teleport_min = 1] ~ ~ ~
/scoreboard players set @a[<Area in which the player is teleported>] 0
Teleport Command Block:
/scoreboard players set @p 1
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pixabay, Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto