Repository navigation
One World per dimension in mc-core - #25
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal #1 from the architecture review: one module owns everything that depends on the dimension.
Before
Dimensionenums, the finder's and the app's, with a conversion between them.StructureGenerator's three constructors.TerrainRefenum and aBiomeLookuptrait that only passed each call on to the right dimension's sources.After
mc_core::world.Dimensionis a single enum, shared by the app and the finder. It provides:idandfrom_id;label;level(), returning aLevel(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:biomeandbiome_at_block;base_heightandbase_column;strongholds();structures(), theStructureGeneratorfor that dimension.StructureGenerator::new(&World)replacesnew,netherandend;TerrainRefandBiomeLookupare removed.Net change: 130 lines added and 345 removed, plus the new module and its test.
Verification
tests/world.rschecks that:Worldanswers exactly like the sources it wraps (biomes, heights and columns in all three dimensions);World, and they still pass.structuresexample gives byte-identical output tomainon three seeds.No behaviour change, so no release.
Generated by Claude Code