Skip to content
Master290Public

About

A Minecraft Java Edition server core written in Go

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

661 Commits

Folders and files

Repository files navigation

A zero-dependency Minecraft Java Edition server core written in Go 1.26.3 (standard library only), targeting version 26.1.2 (protocol 775). RegionIO implements the full protocol lifecycle (status → login → configuration → play), Overworld, Nether, and End dimensions with 100% vanilla terrain and feature parity on committed Overworld fixtures, crash-safe Anvil .mca persistence, and vanilla-faithful gameplay mechanics.

Capabilities

  • Zero external dependencies: go.mod uses only the Go 1.26.3 standard library — NBT, pooled zlib framing, RSA + AES/CFB8 encryption, Xoroshiro128++ / MD5 seeding, Perlin/Simplex noise, density-function interpreter, and datapack loaders are all in-tree.
  • Network & Administration:
    • Full handshake → status → login (offline mode and online mode with RSA + AES/CFB8 encryption and Mojang session verification) → configuration → play state machine.
    • Pooled zlib compression, keep-alive, chunk-batch flow control, and hardened RCON and Query servers.
    • Rate-limited Brigadier command tree (declare_commands) with entity selectors (@s, @p, @r, @a, @e) and full command dispatch (/execute, /gamemode, /tp, /time, /weather, /difficulty, /gamerule, /setblock, /fill, /clone, /fillbiome, /summon, /kill, /damage, /xp, /loot, /place, /locate, /forceload, /tick, /bossbar, /worldborder, /advancement, /recipe, /op, /deop, /whitelist, /kick, /ban, /pardon, /save-all, /stop, and more), plus interactive console stdin.
    • server.properties, ops.json, whitelist.json, and banned-players.json persistence.
  • Registries & Embedded Data:
    • 28 synchronized registries + tags (internal/registry/synced_tags.bin), captured verbatim from vanilla 26.1.2 and sent during configuration.
    • Runtime block properties (internal/world/block_properties.bin), embedded vanilla feature/biome datapack (internal/worldgen/feature_data.zip), structure templates (internal/worldgen/structure_data.zip), and crafting/smelting recipes (internal/server/recipe_data.zip).
  • Dimensions & Vanilla World Generation:
    • Overworld: full noise_router final_density interpreter (ImprovedNoise, PerlinNoise, BlendedNoise, NormalNoise, PerlinSimplexNoise), 3D multi-noise biomes with Voronoi BiomeManager zoom, seed-bound surface rules plus ErodedBadlandsExtension and FrozenOceanExtension, configured carvers, aquifers, noise-router ore veins, and complete datapack feature & structure replay (stage-1 lava lakes, stage-2 geodes/boulders/large dripstone, stage-3 monster rooms, stage-6 ores/underwater magma/disks, stage-7 infested stone/sculk/dripstone, stage-8 springs with 5-direction flowing spread, stage-9 lush-cave patches/multiface/vines/trees/mushrooms/fallen trees/flora, plus mineshafts, ruined portals, ocean ruins, strongholds, monuments, mansions, shipwrecks, scattered structures, and jigsaw structures including ancient cities).
    • 100.000% vanilla parity on both committed Overworld fixtures (393,216/393,216 blocks, 0 residual cells, 100% biomes, and 100% heightmaps on both ocean and land captures, including 789/789 tree cells above sea level), as well as 100% on both featureless base-terrain captures (393,216/393,216 ocean and 786,432/786,432 land).
    • Nether & End: dedicated Nether terrain, structures, and 5×5 FeatureSorter biome decoration parity (crimson_forest, warped_forest, basalt_deltas, soul_sand_valley), plus End islands, chorus/end cities, and Ender Dragon fight mechanics.
  • World Storage & Chunk Lifecycle:
    • Revisioned, concurrency-safe chunk snapshots; memoized level_chunk_with_light frames; ticket-aware bounded LRU cache with explicit Cache.Close() shutdown cleanup; shared frame admission limit; coalesced chunk generation.
    • Crash-safe Anvil .mca persistence with sector reuse, single-write Overworld storage, autosave, level.dat, player data, seed-mismatch rejection, and generatorVersion stamping so stale chunks regenerate safely while corrupt stored chunks are never silently overwritten.
    • Per-client view and prefetch tickets, strict near-first ring streaming, stale-recenter cutoff, explicit client unload packets, and eviction only after the final owner releases a chunk.
  • Lighting:
    • Vanilla nibble arrays for sky and block light, block-state dampening/emission/face-occlusion from block_properties.bin, horizontal and cross-chunk propagation, incremental edit updates, persisted SkyLight/BlockLight, load-time border reconciliation, and chunk-scoped light_update broadcasts.
  • Gameplay Mechanics:
    • Containers & Workstations: chests, barrels, shulker boxes, ender chests, hoppers, dispensers, droppers, crafters, furnaces/blast furnaces/smokers, crafting tables, smithing tables, anvils, enchanting tables, brewing stands, stonecutters, looms, cartography tables, grindstones, lecterns, beacons, conduits, chiseled bookshelves, decorated pots, and recipe book placement with HashedStack and stateId sync.
    • Combat, Survival & World Simulation: melee and ranged combat, potions and status effects, hunger, experience, enchantments, elytra, fireworks, vehicles, beds and respawn anchors, Nether/End portals, tool wear and oriented block placement, redstone circuits, pistons, observers, sculk sensors and shriekers, fluids, falling blocks, concrete powder, copper oxidation, archaeology, farming, fire, TNT, explosions, scoreboards, teams, advancements, stats, bossbars, and worldborder.
    • Mobs, Bosses & Villagers: passive, neutral, aquatic, Nether, End, and hostile mobs; bosses (Ender Dragon, Wither, Warden); villagers with POI, gossip, and trading; iron golems, patrols, and raids; chunk-scoped entity visibility with delta-movement encoding and batched remove_entities despawns.

Build & Run

go build ./...
go run ./cmd/regionio -seed 12345 -port 25565 -viewdistance 4

The server loads server.properties, ops.json, whitelist.json, and banned-players.json from the working directory when present, with CLI flags taking precedence. Changing the seed for an existing world directory is rejected.

CLI flags (cmd/regionio)

Flag Default Description
-seed REGIONIO_SEED / level-seed / 0 World seed (decimal or 0x hex; overrides REGIONIO_SEED)
-port 25565 TCP listen port
-world world (from config) World directory ("" = in-memory only, nothing read from or written to disk)
-maxcache from config Max cached chunks for LRU eviction (0 = unbounded)
-viewdistance from config (2–16) Maximum client chunk view radius
-workers CPU cores − 1 Parallel chunk generation workers
-online from config Enable Mojang authentication and link encryption (online mode)
-pregenerate 0 Pregenerate spawn chunk radius before listening (0 = disabled)

Testing & CI

make build        # go build ./...
make vet          # go vet ./...
make test         # go test -short ./...
make test-full    # go test ./... (includes heavy multi-chunk parity fixtures)
make test-race    # sharded go test -race -short (matches CI matrix, including ./internal/e2e)
make diagnostics  # compiles all test binaries and runs env-gated worldgen probes
make verify       # build, vet, test, test-race, and diagnostics

# Headless protocol-775 E2E integration suite:
go test -v -timeout 2m -count=1 ./internal/e2e

# Strict vanilla block/biome/heightmap parity against committed 26.1.2 fixtures:
make parity
# Regenerate fixtures from the official vanilla server jar (requires Java 25):
go run ./cmd/vanillacapture -server server.jar
  • Parity verification: TestVanillaBlockParity and TestVanillaLandBlockParity exhaustively compare 393,216 block states, 6,144 biome cells, and three heightmaps (WORLD_SURFACE, MOTION_BLOCKING, MOTION_BLOCKING_NO_LEAVES) across four fixed ocean chunks and four fixed land chunks against vanilla 26.1.2 captures. Both pass at 100.000% (393,216/393,216, 0 residual cells, 100% biomes and heightmaps), alongside TestVanillaBaseTerrainParity (393,216/393,216 ocean and 786,432/786,432 land) and TestVanillaLushClayDiff (0 missing, 0 anchor, 0 extra).
  • Integration & E2E coverage: internal/e2e drives a headless protocol-775 client through handshake, login, compression, configuration, chunk streaming, movement, block interaction, containers, and disk persistence (TestHeadlessClientFullLifecycle). Package tests cover multi-client visibility, concurrency under -race, RCON/Query, lighting propagation fixtures, crash-safe .mca storage, and doc/gate guards (TestDocumentationNamesExist and TestEveryDiagnosticGateIsReachable).
  • GitHub Actions CI:
    • .github/workflows/verify-linux.yml (ubuntu-latest): runs verify (go build ./..., go vet ./..., go test -short ./..., internal/e2e, dirty-working-tree guard) and sharded race (-race -short across 4 parallel matrix shards).
    • .github/workflows/verify.yml ([self-hosted, windows]): runs verify, sharded race, parity (ocean and land vanilla fixture checks), and diagnostics (mirroring make diagnostics).

Project Layout

cmd/regionio/        entry point (flags, server.properties, listener, console, graceful shutdown)
cmd/gendump/         client-free generator diagnostics (biomes, surface, bedrock, fluid census)
cmd/genblocks/       generates internal/worldgen/generated_blocks.go from the block report
cmd/genfeatures/     extracts the embedded feature/biome/tag datapack archive from server.jar
cmd/vanillacapture/  captures vanilla parity fixtures from the official 26.1.2 server (Java 25)
tools/               Java dumpers run against server.jar (block properties, biome zoom, chunk format)
internal/
  protocol/          wire primitives: VarInt, framing, pooled zlib compression, packet IDs
  nbt/               NBT encoder/decoder (with modified UTF-8)
  registry/          28 embedded synchronized registries + tags (synced_tags.bin)
  world/             chunk model, level_chunk encoder, cache, crash-safe .mca store, lighting,
                     Overworld/Nether/End generators, structures, redstone, sculk, block updates
  worldgen/          noise/density core, climate finder, aquifer, surface rules, embedded
                     feature_data.zip and structure_data.zip datapack runtimes
  network/           per-connection state machine (login/crypto, configuration, play,
                     chunk-batch flow control, Brigadier commands, RCON/Query)
  server/            shared core: config, server.properties, sessions, dimensions, embedded
                     recipe_data.zip, containers, workstations, combat, mobs, bosses, villagers, raids
  e2e/               headless protocol-775 client harness and end-to-end integration tests

Notes

The vanilla server.jar and its unpacked libraries//versions/ directories are not included (obtain them from Mojang). The embedded data under internal/ (registries, tags, block properties, biome parameters, worldgen features/structures, and recipes) is derived from vanilla 26.1.2 reports and is all that is required to build and run.

About

A Minecraft Java Edition server core written in Go

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages