Skip to content

One World per dimension in mc-core - #25

Merged
byRandom merged 1 commit into
mainfrom
refactor/world
Nov 14, 2026
Merged

byRandom merged 1 commit into
mainfrom
refactor/world

Conversation

@byRandom

Copy link
Copy Markdown
Owner

Proposal #1 from the architecture review: one module owns everything that depends on the dimension.

Before

  • Two Dimension enums, the finder's and the app's, with a conversion between them.
  • The Nether and End level heights written inside StructureGenerator's three constructors.
  • A TerrainRef enum and a BiomeLookup trait that only passed each call on to the right dimension's sources.
  • The finder building its Nether and End sources by hand.
  • The app's marker workers building all six biome sources and terrains for every seed, even when only one dimension was shown.
  • The structures example skipping Nether and End sets by their names.

After

  • New module mc_core::world.
  • Dimension is a single enum, shared by the app and the finder. It provides:
    • id and from_id;
    • label;
    • level(), returning a Level (level range, sea level, generated range);
    • biomes();
    • has_set(set). Ruined portals belong to both the Overworld and the Nether.
  • World::new(seed, dimension) owns that dimension's biome source and terrain. It provides:
    • biome and biome_at_block;
    • base_height and base_column;
    • strongholds();
    • structures(), the StructureGenerator for that dimension.
  • StructureGenerator::new(&World) replaces new, nether and end; TerrainRef and BiomeLookup are removed.
  • The finder builds the Nether and End worlds only when a filter needs them.
  • The app's marker workers build one world per dimension the first time it is needed.

Net change: 130 lines added and 345 removed, plus the new module and its test.

Verification

  • New tests/world.rs checks that:
    • World answers exactly like the sources it wraps (biomes, heights and columns in all three dimensions);
    • every structure set belongs to the right dimensions;
    • dimension ids survive a round trip.
  • All parity tests now go through World, and they still pass.
  • The structures example gives byte-identical output to main on three seeds.
  • The app, run under a virtual display, shows the same map and markers as before.

No behaviour change, so no release.


Generated by Claude Code

Before, the dimension was spread out: two Dimension enums (the finder's and
the app's, converted into each other), the Nether and End level heights
written inside StructureGenerator's constructors, a TerrainRef enum and a
BiomeLookup trait re-dispatching to each dimension's sources, the finder
building its Nether and End sources by hand, the app building all six
sources for every seed, and the structures example skipping Nether and End
sets by name.

mc_core::world now owns all of it:
- Dimension (one enum): id, label, level heights (Level), its biomes, and
  whether a structure set has structures there (has_set).
- World::new(seed, dimension): its biome source and terrain, with biome,
  biome_at_block, base_height, base_column, strongholds() and
  structures(), the StructureGenerator for that dimension.

StructureGenerator::new now takes a &World; its three per-dimension
constructors, TerrainRef and BiomeLookup are gone. The finder builds the
Nether and End worlds only when a filter needs them; the app's marker
workers build a world per dimension when first needed; the app and the
finder share mc-core's Dimension. Tests and examples use World, and a new
test checks that World answers exactly like the sources it wraps and that
every set belongs to the right dimensions. The structures example gives
byte-identical output to before on three seeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SenGxDDRwLejx8nir8GXKG
@byRandom
byRandom merged commit 30964da into main Nov 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant