Restore the subsurface layers: real above_preliminary_surface and surface depth

Every land column was one block of grass sitting straight on stone. No dirt
under grass, no sandstone under sand, nothing. Two stubs did it together:

above_preliminary_surface compared blockY against the column's actual top block,
so of every position in the column exactly one passed -- and the entire
biome-specific half of the surface rule tree hangs under that condition.
Vanilla compares against a minimum surface level: the preliminary surface level
sampled at the four corners of the 16-block cell, bilinearly interpolated, plus
the surface depth less 8. That is about twenty blocks of reach on ordinary
terrain, which is what the biome subtree is written against.

Surface depth was hardcoded to 0. Vanilla is surfaceNoise*2.75 + 3 with a
per-column jitter, so it comes out around three; it sets how thick the band is
and feeds every add_surface_depth term in the tree. Zero collapsed them all.

Also samples surface_secondary, so stone_depth's secondary_depth_range widens
its band instead of being parsed and dropped.

Grass columns now read grass, two to four dirt, stone -- the histogram over 256
columns is {2: 223, 3: 33}, against vanilla's 2..4. gendump prints it and fails
if the band collapses again; TestGrassColumnsHaveDirt guards it in the suite.
This commit is contained in:
Master290 2026-07-27 02:15:14 +03:00
parent e77fe3dc07
commit 1083e47211
9 changed files with 231 additions and 32 deletions

View file

@ -52,6 +52,10 @@ type OverworldDensity struct {
// AquiferRandom places the aquifer cell centres.
AquiferRandom PositionalRandomFactory
// Surface samples the noises SurfaceSystem reads per column, before the
// rule tree runs.
Surface *SurfaceSampler
prelim *levelCache
}
@ -148,6 +152,22 @@ func LoadOverworldFinalDensity(seed int64) (*OverworldDensity, error) {
// Interpolated nodes are collected as the whole router is parsed, so the
// list has to be taken after the loop, not just after final_density.
od.Interpolated = l.interpolated
// SurfaceSystem's own noises. They are not router keys: vanilla pulls them
// straight out of the noise registry when it builds the SurfaceSystem.
surfaceNoise, err := l.noiseField("minecraft:surface")
if err != nil {
return nil, fmt.Errorf("surface noise: %w", err)
}
secondaryNoise, err := l.noiseField("minecraft:surface_secondary")
if err != nil {
return nil, fmt.Errorf("surface_secondary noise: %w", err)
}
od.Surface = &SurfaceSampler{
surfaceNoise: surfaceNoise,
secondaryNoise: secondaryNoise,
positionalRand: l.rs.Positional(),
}
return od, nil
}