Level Stem Editor
The LevelStemEditor swaps the
chunk generator and/or the
dimension type of the already-loaded world at runtime.
We don’t recommend using it for production servers, but it can be useful for testing or debugging worldgen.
How it works
Section titled “How it works”Create an editor with LevelStemEditor.create(), queue the pieces you want to swap, then apply(World) it to each world
you want to affect. Only chunks generated after the swap use the new generator. Already-generated chunks keep their existing terrain.
Example Usage
Section titled “Example Usage”import dev.wyck.registry.level.LevelStemEditor;
import dev.wyck.worldgen.biome.BiomeSource;
import dev.wyck.worldgen.chunk.ChunkGenerator;
import dev.wyck.worldgen.chunk.NoiseBasedChunkGenerator;
import dev.wyck.worldgen.noise.Noise;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
// Nether-style terrain and biomes.
ChunkGenerator generator = NoiseBasedChunkGenerator.of(BiomeSource.nether(), Noise.nether());
LevelStemEditor editor = LevelStemEditor.create()
.chunkGenerator(generator);
// Apply to every loaded world (newly generated chunks use the new generator).
for (World world : Bukkit.getWorlds()) {
editor.apply(world);
}
}
} Reverting an Edit
Section titled “Reverting an Edit”Keep a reference to the editor and call restore(World) to put a world back the way it was.
import dev.wyck.registry.level.LevelStemEditor;
import org.bukkit.Bukkit;
import org.bukkit.World;
World world = Bukkit.getWorlds().get(0);
LevelStemEditor editor = LevelStemEditor.create()
.chunkGenerator(generator)
.apply(world);
// ...later, restore the original generator and dimension type:
editor.restore(world);