Instance manager
InstanceManager owns a fixed pool of eight pre-registered instance dimensions (conduit:instance-0 through conduit:instance-7). You acquire one with a WorldTemplate (void, flat, or overworld with seed), the engine creates the ServerLevel, and you release it when the game ends — the world is destroyed, the saved data wiped, and the slot returned to the pool.
When to use it
Section titled “When to use it”- You’re starting a fresh round and need an isolated dimension to play in.
- You want concurrent lobbies playing the same minigame in parallel without seeing each other.
- You’re tracking slot state (free vs active) for an admin / debug UI.
package me.zlex.conduit.instance;
public final class InstanceManager { public static final int POOL_SIZE = 8;
public static void init(); // call once from your ModInitializer
public static @Nullable GameInstance acquire(MinecraftServer server, WorldTemplate template); public static void release(GameInstance instance);
public static List<GameInstance> getActive(); public static @Nullable GameInstance get(int slot);}
public final class GameInstance { public int slot(); public ResourceKey<Level> dimension(); public WorldTemplate template(); public @Nullable ServerLevel level(); public boolean isActive(); public void release();}acquire returns null if the pool is full. The pool size is fixed at 8 in the source; configure expectations accordingly.
Example
Section titled “Example”import me.zlex.conduit.instance.GameInstance;import me.zlex.conduit.instance.InstanceManager;import me.zlex.conduit.instance.WorldTemplate;import me.zlex.conduit.teleport.SafeTeleport;import net.minecraft.server.MinecraftServer;import net.minecraft.server.level.ServerPlayer;import net.minecraft.world.phys.Vec3;
public final class MyRoundStart {
public static @Nullable GameInstance startRound(MinecraftServer server, Collection<ServerPlayer> players) { GameInstance inst = InstanceManager.acquire(server, WorldTemplate.VOID); if (inst == null) { announceFull(players); return null; }
Vec3 spawn = new Vec3(0.5, 65, 0.5); for (ServerPlayer p : players) { SafeTeleport.teleport(p, inst.level(), spawn); } return inst; }
public static void endRound(GameInstance inst) { inst.release(); // wipes the world, returns the slot }}- Releasing destroys the world’s chunks and removes its saved data. Don’t release a slot you still want to read state from.
- Slot state persists across server restarts (the pool is rebuilt and active slots reattached), but if your mod cares about which slot it had, store the slot index in your own SavedData.
- Seed overrides are consulted via a mixin (
ServerLevelSeedMixin) so the seed you pass toWorldTemplate.Overworld(seed)is what generation uses, regardless of how the dimension was originally registered.