Worlds and dimensions

Reach the running level, enumerate its dimensions, and work with locations and positions.

A Bedrock world is a level, and a level holds one or more dimensions - the overworld, the nether, and the end. Everything with a position - players, spawns, blocks - lives inside a dimension, addressed by x, y, z coordinates. This page covers reaching the level and its dimensions and working with locations; see Blocks to read and place the blocks inside them.

Reach the level and its dimensions

The server exposes the running world at getServer().getLevel(). From the level you read its name and seed, and you enumerate the dimensions inside it:

include/my_plugin.h
#include <endstone/endstone.hpp>

namespace es = endstone;

class MyPlugin : public es::Plugin {
public:
    void onEnable() override
    {
        es::Level *level = getServer().getLevel();
        getLogger().info("World: {}, seed {}", level->getName(), level->getSeed());

        for (es::Dimension *dimension : level->getDimensions()) {
            getLogger().info("  dimension {}", dimension->getId());
        }

        es::Dimension *overworld = level->getDimension(es::Dimension::Overworld);
    }
};
  • Level is the world as a whole - its getName(), getSeed(), the in-game getTime() / setTime(), and getActors() across every dimension.
  • Dimension is one space within that level. Get them all from getDimensions(), or fetch one by id with getDimension(es::Dimension::Overworld). The constants es::Dimension::Overworld, Nether, and TheEnd are DimensionIds (an alias for es::Identifier<Dimension>), and getDimension also accepts the raw string ("minecraft:overworld"). Each dimension's getId() returns that same DimensionId.

The in-game time lives on the level, not the dimension: read and write it with level->getTime() / level->setTime(ticks). Endstone's level API does not currently expose weather or game rules - drive those with the vanilla /weather and /gamerule commands through getServer().dispatchCommand if you need them.

Locations and positions

A Location is a point inside a dimension: a dimension plus x, y, z, and an optional pitch and yaw facing. It's what blocks report for their position and what teleports and spawns consume.

es::Location loc{*overworld, 100.0, 64.0, -200.0};

loc.getX();  loc.getY();  loc.getZ();             // the coordinates
loc.getBlockX();  loc.getBlockY();  loc.getBlockZ();  // floored to the block they sit in
loc.getDimension();                               // the dimension this location belongs to

The constructor takes the dimension by reference, then the coordinates. The getBlockX() / getBlockY() / getBlockZ() accessors floor each axis to the integer coordinate of the block that contains the point - exactly what you pass when looking a block up by coordinate.

Locations are how you address the blocks in a dimension - see Blocks to read and place them.

On this page