Dimension spec & handle
RuntimeDimensionSpec describes the world RuntimeDimensions.create should build. RuntimeDimensionHandle is the live reference it returns.
When to use it
Section titled “When to use it”- Pick the world shape: a void arena (the common case for prefab-built minigames) or a copy of an existing level’s terrain rules.
- Decide whether the world’s files survive teardown (
persist). - Hold the handle for the match’s lifetime; pass it back to
releasewhen done.
public record RuntimeDimensionSpec( Holder<DimensionType> dimensionType, ChunkGenerator chunkGenerator, long seed, boolean persist) {
// The Void biome, no terrain, overworld lighting/height. Discarded // on release. The common case for prefab-built arenas. static RuntimeDimensionSpec voidWorld(MinecraftServer server);
// Mirror an existing level's dimension type + generator + seed. static RuntimeDimensionSpec copyOf(ServerLevel template);
// Copy with persist overridden. RuntimeDimensionSpec withPersist(boolean persist);}
public record RuntimeDimensionHandle(ResourceKey<Level> key) { ServerLevel level(MinecraftServer server); // null once released boolean isActive();}persist defaults to false on both builders — the dimension’s region files are deleted on release so temp worlds don’t pile up. Set it true to keep the world across a restart: persistent dimensions are recorded to a manifest and recreated on the next boot with their saved region data intact.
Data-driven factories
Section titled “Data-driven factories”Beyond voidWorld / copyOf, a spec can be built from a serialized dimension definition — handy when the dimension is authored as data rather than code:
// From a LevelStem you already have.RuntimeDimensionSpec.fromStem(stem, seed, persist);
// Decode a LevelStem from JSON (same shape as a datapack dimension/*.json).RuntimeDimensionSpec.fromStemJson(server, json, seed, persist);
// Reference a dimension registered in the datapack `dimension` registry.RuntimeDimensionSpec.fromDatapackStem(server, stemKey, seed, persist);Example
Section titled “Example”import me.zlex.conduit.instance.runtime.RuntimeDimensionSpec;import me.zlex.conduit.instance.runtime.RuntimeDimensions;
// A blank void canvas to build an arena on.var spec = RuntimeDimensionSpec.voidWorld(server);var handle = RuntimeDimensions.create(server, spec);
// Or: a throwaway world that reuses the overworld's terrain rules.var overworldCopy = RuntimeDimensionSpec.copyOf(server.overworld());var natural = RuntimeDimensions.create(server, overworldCopy);
// Check liveness before using the handle.if (handle.isActive()) { ServerLevel level = handle.level(server); // …}Related
Section titled “Related”- Runtime dimensions — the create/release lifecycle.
- Void world helper — the generator
voidWorldbuilds on.