The overworld noise_router ships fourteen keys; we read six. The eight left on the floor are exactly the ones the aquifer, the ore veins and the preliminary surface estimate need, so every one of those subsystems has been impossible to write. Wire the rest of the router into OverworldDensity: barrier, fluid_level_floodedness, fluid_level_spread and lava for the aquifer, vein_toggle/vein_ridged/vein_gap for the veins, and preliminary_surface_level for both. Two node types were missing and are added with them -- minecraft:invert (the reciprocal, not negation: Mapped.Type ordinal 5 is 1.0/input) and minecraft:find_top_surface, which walks down from an upper bound in cell_height steps looking for positive density. PreliminarySurfaceLevelAt wraps that node the way NoiseChunk does: quart-align the column, then memoise. The cache is per generator rather than per chunk because the aquifer samples columns up to three chunks away, so neighbours overlap heavily -- with a shared cache a chunk costs a few dozen evaluations instead of a few thousand. Also lifts sea_level, min_y, height and the aquifers/ore-veins flags out of the settings file, and adds PositionalRandomFactory.At for the aquifer cell centres (Mth.getSeed hashed into the low half of the factory seed). No generator output changes yet: nothing reads the new keys.
50 lines
2.1 KiB
Go
50 lines
2.1 KiB
Go
package worldgen
|
|
|
|
// RandomState seeds all worldgen noises from the world seed, mirroring the
|
|
// vanilla RandomState: a positional factory derived from XoroshiroRandomSource
|
|
// (overworld uses the non-legacy source), with each noise seeded by the MD5
|
|
// hash of its resource location.
|
|
type RandomState struct {
|
|
factory PositionalRandomFactory
|
|
noises map[string]*NormalNoise
|
|
// aquifer and ore are the positional factories vanilla derives up front for
|
|
// the aquifer cell centres and the ore-vein placement, each a forked
|
|
// positional factory seeded from a named hash of the root factory.
|
|
aquifer PositionalRandomFactory
|
|
ore PositionalRandomFactory
|
|
}
|
|
|
|
// NewRandomState builds the seeding context for the given world seed.
|
|
func NewRandomState(seed int64) *RandomState {
|
|
root := NewXoroshiro(seed).ForkPositional()
|
|
return &RandomState{
|
|
factory: root,
|
|
noises: make(map[string]*NormalNoise),
|
|
aquifer: root.FromHashOf("minecraft:aquifer").ForkPositional(),
|
|
ore: root.FromHashOf("minecraft:ore").ForkPositional(),
|
|
}
|
|
}
|
|
|
|
// AquiferRandom returns the positional factory the aquifer uses to place its
|
|
// cell centres (RandomState.aquiferRandom).
|
|
func (rs *RandomState) AquiferRandom() PositionalRandomFactory { return rs.aquifer }
|
|
|
|
// OreRandom returns the positional factory the ore-vein placement uses
|
|
// (RandomState.oreRandom).
|
|
func (rs *RandomState) OreRandom() PositionalRandomFactory { return rs.ore }
|
|
|
|
// Noise returns the NormalNoise for the named noise parameters, seeded as
|
|
// NormalNoise.create(factory.fromHashOf(name), params) and cached.
|
|
func (rs *RandomState) Noise(name string, firstOctave int, amplitudes []float64) *NormalNoise {
|
|
if n, ok := rs.noises[name]; ok {
|
|
return n
|
|
}
|
|
n := NewNormalNoise(rs.factory.FromHashOf(name), firstOctave, amplitudes)
|
|
rs.noises[name] = n
|
|
return n
|
|
}
|
|
|
|
// BlendedNoise builds the terrain blended noise, seeded from "minecraft:terrain".
|
|
func (rs *RandomState) BlendedNoise(xzScale, yScale, xzFactor, yFactor, smear float64) *BlendedNoise {
|
|
return NewBlendedNoise(rs.factory.FromHashOf("minecraft:terrain"), xzScale, yScale, xzFactor, yFactor, smear)
|
|
}
|