How do you teleport a player to a moving objective?

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.


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.


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.