minecraft-worldgen
v0.0.1
Published
TypeScript port of Minecraft's noise world generation (1.21+/26.x) that runs vanilla and external worldgen datapacks, in Node and in the browser (web workers)
Maintainers
Readme
minecraft-worldgen
TypeScript port of Minecraft's noise world generation (26.x / 1.21+ data format) that runs vanilla worldgen and external worldgen datapacks (an explicit multi-noise biome table, custom noise settings, features and structures) in Node and in the browser. Verified chunk by chunk against a real 26.3 server (see docs/HANDOFF.md).
- biomes (multi-noise; vanilla's built-in table or a datapack's), terrain (noise router, aquifers, surface rules, carvers), features, structures (jigsaw, strongholds, monuments, mansions, fortresses...), Nether and End
- world recipes: custom dimensions described as data + a patch / script on top of the vanilla pipeline (
src/recipe) - worker pool with a staged pipeline (terrain and decoration computed once per chunk, spread over all workers; Node
worker_threadsor Web Workers), no SharedArrayBuffer needed
Usage
import { createChunkSource, parseWorldSeed } from 'minecraft-worldgen'
const src = await createChunkSource({ seed: String(parseWorldSeed('hello')) }, 3) // 3 workers; 0 = in-process
const chunk = await src.generate(0, 0) // { blocks: Uint16Array, palette: string[], biomes, surface, ... }
await src.close()Data: the vanilla client jar (~/.cache/mc-worldgen/client.jar) and optionally one or more datapack jars layered on top (default ~/.cache/mc-worldgen/datapack.jar; override: MC_WORLDGEN_VANILLA_JAR, MC_WORLDGEN_DATAPACK_JAR, or pass jars / zipBuffers). The package ships no Minecraft or datapack data; with only the vanilla jar it generates vanilla terrain.
Browser
Build the datapack zip the workers fetch (only the directories the generator reads), serve it, and create the workers with your bundler:
npx minecraft-worldgen-pack public/mc-worldgen-data.zip [client.jar] [datapack.jar ...]// worldgenWorker.ts
import 'minecraft-worldgen/dist/worker/web-entry'
// main thread
const src = await createChunkSource({ seed, datapackUrl: '/mc-worldgen-data.zip' }, undefined, i => new Worker(new URL('./worldgenWorker.ts', import.meta.url)))Development
pnpm install
pnpm type-check
pnpm test # oracle / golden-chunk tests: needs the jars and the cached fixtures (docs/HANDOFF.md), several minutes
pnpm test-ci # tests without external datasrc/tools has the oracle tooling (real server harness), benchmarks (pool-bench.mjs) and the recipe viewer.
