Can I use command blocks to teleport to my /spawnpoint without killing me?

Essentially, I am trying to make a /sethome function in command blocks. I want to use a 'Command Book' where the command block tests if I have written /sethome, and then it /spawnpoints me to my current location. Then, if I write /home, I want it to be able to teleport me to my /spawnpoint without killing me. I really don't know how to do this or if it is even possible, any advice?


Solution 1:

If you go through an end portal whilst in the end, you are returned to your spawn point.

Prerequisites:

  1. Set an end_portal block at a specific coordinate in every dimension (E.G: 350000, 0, 350000).
  2. Set up an objective to track whether players are in the end already: /scoreboard objectives add isInEnd dummy

Then, whenever you want to teleport a player:

  1. /scoreboard players set @a isInEnd 0
  2. /scoreboard players set @a isInEnd 1 {Dimension:1}
  3. /tp @a[score_isInEnd=0] 350000 0 350000
  4. /tp @a 350000 0 350000