How to make a teleport command that does not work in the Nether?

How to make a teleport command that does not work in the Nether? - Content female customer with long curly hair wearing casual outfit sitting at wooden table with netbook in classic interior restaurant while making online order

I have a vanilla server 1.8.7 that uses a book to tp players to spawn or to their home (an invisible armor stand with their uuid connected to it). Problem is, if they set home (place their armor stand) in the overworld and go to the nether and try to tp home (activated using a trigger), it sends them to the same co-ordinates in the nether, and most likely kills them.

I did some digging, and there seems to be a dimension parameter, but I can't quite figure out the syntax or how to get it to work.

I updated the command block to:

/tp @a[score_tpHome_min=1,Dimension=0] 68 68 68

I was hoping it would only tp the player when they were in the overworld (Dimension 0), but it seems to be ignoring that parameter in the nether and still teleporting to those co-ordinates in the nether.

I also tried:

/tp @a[score_tpHome_min=1,Dimension:0] 68 68 68

Which is the way other people were using the parameter in other ways, but that gave an error.



Best Answer

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.




Pictures about "How to make a teleport command that does not work in the Nether?"

How to make a teleport command that does not work in the Nether? - Concentrated redhead female wearing light apron kneading clay in baking pan while creating in modern apartment
How to make a teleport command that does not work in the Nether? - Crop anonymous cook in apron sifting flour while preparing baking dish against gray background
How to make a teleport command that does not work in the Nether? - Woman with branches of roses in hands



Can you teleport to the nether with commands?

In Java Edition, when used via the execute command, can teleport between the Overworld, the Nether and the End: To teleport the executing player to the same coordinates, but in the Nether: execute in minecraft:the_nether run teleport ~ ~ ~

How do I teleport myself from the nether to the overworld?

  • Use the following command to summon a Nether Portal block. /setblock ~ ~ ~ nether_portal.
  • You will immediately be registered as in the Nether Portal, and teleport to the Nether.
  • Light a nether portal normally or run the above command again and it will take you to the Overworld.


  • Is there a way to teleport in Minecraft without commands?

    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 back to the overworld?

    if you're playing single player, typing /tpx 0 should send you to the overworld spawn.



    HOW TO: TELEPORT WHEN STEPPING ON CERTAIN BLOCKS Minecraft PE Nether Update(command block tutorial)




    More answers regarding how to make a teleport command that does not work in the Nether?

    Answer 2

    Minecraft 1.13's addition of NBT to the selector argument syntax means the general technique described in the other answers can be done without scoreboards:

    /tp @a[score_tpHome_min=1,nbt={Dimension:0}] 68 68 68
    

    That said, /tp can now teleport players across dimensions, so it may be better to do that instead of disabling the teleport ability entirely in the nether.


    Additionally, Minecraft 1.16 changed the NBT format so that the Dimension tag is stored as a string, meaning that you have to use:

     /tp @a[score_tpHome_min=1,nbt={Dimension:"minecraft:overworld"}] 68 68 68
    

    instead if you are playing the most recent version.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Yan Krukov, Monstera, Klaus Nielsen, Teona Swift