Skip to content

Add spawn-centered projection options - #52

Open
TimStewartJ wants to merge 2 commits into
Yucareux:mainfrom
TimStewartJ:spawn-projection
Open

Add spawn-centered projection options#52
TimStewartJ wants to merge 2 commits into
Yucareux:mainfrom
TimStewartJ:spawn-projection

Conversation

@TimStewartJ

@TimStewartJ TimStewartJ commented Aug 26, 2026

Copy link
Copy Markdown

Summary

This draft adds two independent, off-by-default world settings:

  • Scale Measured At Spawn interprets the selected metres-per-block scale as the local ground scale at the selected spawn latitude.
  • Center World On Spawn translates the Mercator world origin so the selected spawn generates near Minecraft X=0, Z=0.

It introduces a saved WorldProjection and routes terrain, climate, canopy, OSM, previews, preloads, teleports, realtime queries, normalized elevation caching, full chunks, and Fast Distant Horizons LODs through the same projection model.

Related prior implementation: #28 by @ForMooN-0118. That PR demonstrated the value of a local-origin mode and has a report that Distant Horizons did not align. This implementation was developed independently before I discovered #28; I am explicitly linking it here to credit the prior work and coordinate rather than silently compete with it.

Motivation

At non-equatorial spawns, the historical scale value is an equatorial Mercator scale rather than the scale players experience around the selected location. Large absolute coordinates also make origin-centered gameplay and some physics/rendering mods less practical around the chosen spawn.

These settings address those concerns separately:

  • Scale normalization makes the requested scale locally accurate around spawn.
  • Origin translation keeps the selected region near small Minecraft coordinates and makes origin-centered mechanics surround that region.

This remains a conventional spherical Mercator projection; it is not an oblique projection and does not change Mercator angles.

Implementation notes

  • Existing worlds decode both settings as false and preserve historical coordinates.
  • Default-false fields are canonicalized out of preload fingerprints for legacy package compatibility.
  • Longitude wrapping, the moved antimeridian seam, polar bounds, wrapped preload rectangles, and OSM geometry crossing the seam are handled centrally.
  • Full Minecraft chunks and Fast DH LODs use equivalent projection paths.
  • The legacy biome-provider SPI remains available through a projection-aware adapter.
  • checkProjectionUsage rejects new direct block/geographic conversions that bypass WorldProjection.
  • English, Spanish, and Japanese UI text is included for both toggles.

Commit structure

  1. 056ac3fa - Phase A: add off-by-default Scale Measured At Spawn
  2. cc957e1c - Phase B: add off-by-default Center World On Spawn projection

The commits are intentionally separated for review. Phase B is cross-cutting because every geographic/block coordinate path must agree; I am happy to adjust the review or split strategy based on maintainer preference.

Automated validation

A clean gradlew.bat clean build completed successfully across all supported targets. All 77 Gradle tasks executed from clean outputs.

Target Tests Failures Errors Skips
1.20.1 Fabric 484 0 0 1
1.20.1 Forge 465 0 0 2
1.21.1 Fabric 484 0 0 1
1.21.1 NeoForge 484 0 0 1
26.2 Fabric 517 0 0 1
26.2 NeoForge 484 0 0 1
Total 2,918 0 0 7

All six production jars were generated.

Manual release-candidate checklist

Initial Yosemite runtime smoke testing passed. Unchecked items remain useful non-blocking follow-ups:

  • Create a new Yosemite world with both settings enabled.
  • Verify the selected scale is measured locally at spawn (saved local scale: 1:1 at 37.7466 N).
  • Verify spawn X/Z are near zero (saved spawn: X=0, Z=0).
  • Verify strongholds are distributed around the spawn-centered origin (nearest: X=1616, Z=-896; 1,531 blocks away; entered successfully).
  • Verify Tellus map selection and surface teleport to a distant destination.
  • Verify full chunks align with Fast DH LODs.
  • Inspect nearby roads, bridges, buildings, shorelines, and water.
  • Reload the world and confirm both settings persist.
  • Confirm disabled settings retain legacy behavior.

AI assistance

Implementation, codebase tracing, and review were AI-assisted under human direction. The branch was manually inspected and the complete clean build/test matrix above was executed locally.

Initial runtime result

Minecraft 26.2 Fabric successfully generated and saved a Yosemite world with both settings enabled. The saved world data confirms local 1:1 scale normalization at 37.7466 N, exact centered spawn at X=0/Z=0, and both settings persisted. Fast Distant Horizons generated 1,090 full-data rows and 798 chunk hashes; Tellus, DH, Iris, and OpenGL initialized without a Tellus/DH exception. Visual generation looked correct in the initial play test.

TimStewartJ and others added 2 commits August 26, 2026 13:53
Adds the persisted boolean `world_scale_at_spawn` (codec fallback false, so
existing worlds decode unchanged). When enabled, the World Scale control in the
customize and terrain-preload screens is interpreted as real-world metres per
block at the spawn point instead of at the equator; the stored `world_scale`
remains the equatorial value (displayed * sec(spawnLat)), so terrain
generation itself is untouched.

- EarthGeneratorSettings: new component, codec field, DEFAULT, with* helpers,
  groundScaleAtSpawn/displayedWorldScale/equatorialWorldScale conversions,
  plus withSpawn/withWorldScale convenience constructors.
- EarthCustomizeScreen (pre-26, mc262): toggle under World Scale; slider is
  converted on toggle so the generated world does not change; roads/buildings
  gate and auto-adjust use the equatorial value.
- TerrainPreloadScreen (pre-26, mc262, mc262-neoforge): scale box edits the
  displayed value and re-derives the stored scale when the area centre (future
  spawn) moves.
- Lang (en/es/ja), README, codec + conversion tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the persisted `center_world_on_spawn` setting (codec fallback false) and
a per-world WorldProjection that translates the existing spherical Mercator
origin to the selected spawn without changing Mercator distortion. Existing
worlds remain on the historical 0N 0E origin bit-for-bit.

- Put spawn at block X=0, Z=0 when enabled, so vanilla origin-centered
  mechanics (including stronghold rings) and normal play remain near spawn.
- Route terrain, elevation, land cover/mask, climate, canopy, OSM geometry,
  roads/buildings/water, previews, preloads, map teleport coordinates,
  real-time lookups, full chunks, and fast DH LODs through WorldProjection.
- Keep normalized elevation caches keyed in global projected metres, with
  valid antimeridian wrapping and canonical polar bounds.
- Handle moved-seam tile queries, preload bounds, and seam-crossing geometry
  without planet-spanning roads, bridges, buildings, or water polygons.
- Preserve legacy preload fingerprints for both default-false UI fields and
  retain binary compatibility for the biome classification provider SPI.
- Add the off-by-default UI toggle to both customize screens, propagate it
  through all three preload screens, and document/localize it (en/es/ja).
- Add checkProjectionUsage to prevent future block/geographic bypasses.
- Add codec, projection, cache, seam, preload, and compatibility tests.

Validation: ./gradlew build (all six targets; 2,918 tests, zero failures)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TimStewartJ
TimStewartJ marked this pull request as ready for review August 26, 2026 23:59
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