2
for players in the end
execute as @a[nbt={Dimension: "minecraft:the_end"}] in overworld run tp @s ~ ~ ~
for players in the nether
execute as @a[nbt={Dimension: "minecraft:the_nether"}] in overworld run tp @s ~ ~ ~
Note: this teleports you back to the world spawn point and NOT to the previous spawn point
(edit)
I didn't test if the nether command works as intended so it may not work
Create an account or sign in to comment.
4
That won't work if the player isn't an op who doesn't have access to server commands.
Another thing is that there's no need for such complex constructions in the first place because teleporting players across dimensions has already been implemented into vanilla Minecraft quite some time ago.
If my friend Aya is in the nether and I want to get her out all I have to do is: /tp AyanamiKun @p, and I'm done. This also applies to datapacks.
(edit)
I glossed over a detail... what if you don't have a specific destination, then coordinates obviously won't work. Yah, my bad!
But there's still a better solution: /execute in minecraft:overworld run tp AyanamiKun ~ ~ ~. However, this does not tp someone to any kind of spawn, but to their current location (~ ~ ~) yet in the other dimension. And of course, if you don't want to focus on one player but want to get all players out of the nether you'd use: /execute in minecraft:overworld run tp @a[nbt={Dimension:"minecraft:the_nether"}] ~ ~ ~
Hope this can help!
Another thing is that there's no need for such complex constructions in the first place because teleporting players across dimensions has already been implemented into vanilla Minecraft quite some time ago.
If my friend Aya is in the nether and I want to get her out all I have to do is: /tp AyanamiKun @p, and I'm done. This also applies to datapacks.
(edit)
I glossed over a detail... what if you don't have a specific destination, then coordinates obviously won't work. Yah, my bad!
But there's still a better solution: /execute in minecraft:overworld run tp AyanamiKun ~ ~ ~. However, this does not tp someone to any kind of spawn, but to their current location (~ ~ ~) yet in the other dimension. And of course, if you don't want to focus on one player but want to get all players out of the nether you'd use: /execute in minecraft:overworld run tp @a[nbt={Dimension:"minecraft:the_nether"}] ~ ~ ~
Hope this can help!
Hmm, it did work tho...
I tested multiple variations and this should always teleport you back to spawn since the functions of a data pack are always executed at the World Spawn Point.
Note: this is in the section of Data packs and not a command block execution.
since it's executed as @a and not @a
execute as @a[,nbt={Dimension: "minecraft:the_end"}] in overworld run tp @s ~ ~ ~
and it does work for multiple players.
Yours is still better since it requires fewer tests for the execution :)
execute in minecraft:overworld run tp @a[nbt={Dimension:"minecraft:the_nether"}] ~ ~ ~
Thanks for the comment tho!
I tested multiple variations and this should always teleport you back to spawn since the functions of a data pack are always executed at the World Spawn Point.
Note: this is in the section of Data packs and not a command block execution.
since it's executed as @a and not @a
execute as @a[,nbt={Dimension: "minecraft:the_end"}] in overworld run tp @s ~ ~ ~
and it does work for multiple players.
Yours is still better since it requires fewer tests for the execution :)
execute in minecraft:overworld run tp @a[nbt={Dimension:"minecraft:the_nether"}] ~ ~ ~
Thanks for the comment tho!
Pretty sure both use the same amount of tests as you're checking out of all possible players if any of them are currently in the nether/end.
Checking for nbt in general can get expensive especially if you're using it many times and on many entities).
Since you're using a datapack, I suggest using an 'entity properties' predicate
Checking for nbt in general can get expensive especially if you're using it many times and on many entities).
Since you're using a datapack, I suggest using an 'entity properties' predicate
I think it requires fewer tests but the amount of performance you get out of it is negligible.
I am aware that checking NBT isn't very efficient but it's just supposed to be a quick fix.
My skills in creating data packs aren't very developed and I'm not well versed with predictates.
I'll keep this in mind.
Thx for the comment!
I am aware that checking NBT isn't very efficient but it's just supposed to be a quick fix.
My skills in creating data packs aren't very developed and I'm not well versed with predictates.
I'll keep this in mind.
Thx for the comment!