3

I want to check a player's current dimension using a scoreboard. For example, if a player is in the overworld, scoreboard would be set to 1. Nether would be 2. And the End would be 3.

I have tried execute if entity @a in minecraft:the_nether but that actually changes the coordinate's dimension.

Do you know any way to detect a player's current dimension?

2 Answers 2

3

It's saved in NBT. Quote from the Minecraft wiki (archive):

Dimension: The dimension the player is in. -1 is the Nether, 0 is the Overworld, 1 is the End.


Alternatively, you could still use /execute in, but also check for a radius of 0 or more (which sounds useless, but can be used as a dimension check):

/execute in the_nether if entity @a[distance=0..] run …

This executes if there is a player in the Nether.


There is also an advancement trigger called "changed_dimension" (archive) that can be used to detect a change to a specified dimension and trigger something at that moment. Alternatively you could use the dimension field in the location trigger (archive).

1
execute store result score @s dimension run data get entity @s Dimension

This will set the scoreboard value based on the length of the entity's dimension string.

20 - "minecraft:the_nether", 19 - "minecraft:overworld", 17 - "minecraft:the_end"

You can either have your functions handling dimensions instead with these numbers, or you can convert them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .