How to make a teleport command that does not work in the Nether?
The Dimension parameter does not exist as a target selector argument, but is present in the entity data.
Sadly, /tp
does not allow you to check for entity data, so you will have to create a workaround using a scoreboard objective.
/scoreboard objectives add inNether dummy
One the objective exists, create a fill/setblock clock and run the following two commands, in this order:
/scoreboard players set @a inNether 0
/scoreboard players set @a inNether 1 {Dimension:-1}
This will set the objective to 1 for everyone in the Nether and you can use this to limit your tp
command to
/tp @a[score_tpHome_min=1,score_inNether=0] 68 68 68
That being said, this would allow the use of the TP in the End, which almost definitely results in death. I suggest turning the logic around by doing
/scoreboard players set @a inOverworld 0
/scoreboard players set @a inOverworld 1 {Dimension:0}
instead, and check for score_inOverworld_min=1
.
This is almost a version of @MrLemon's answer. Run the following command once:
/scoreboard objectives add Dimension dummy
Put the following commands on a fill/fast clock:
/scoreboard players set @a Dimension -2 {Dimension:-2}
/scoreboard players set @a Dimension -1 {Dimension:-1}
/scoreboard players set @a Dimension 0 {Dimension:0}
Then do the tp as following:
/tp @a[score_tpHome_min=1,score_Dimension_min=0] 68 68 68
How this works is it gets the player dimension by setting the scoreboard objective Dimension
to the dimension that they are in.