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 <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);
}
};Levelis the world as a whole - itsgetName(),getSeed(), the in-gamegetTime()/setTime(), andgetActors()across every dimension.Dimensionis one space within that level. Get them all fromgetDimensions(), or fetch one by id withgetDimension(es::Dimension::Overworld). The constantses::Dimension::Overworld,Nether, andTheEndareDimensionIds (an alias fores::Identifier<Dimension>), andgetDimensionalso accepts the raw string ("minecraft:overworld"). Each dimension'sgetId()returns that sameDimensionId.
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 toThe 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.