Initial commit: RegionIO Minecraft server core (26.1.2/protocol 775)
Vanilla-faithful overworld generator (final_density + multi-noise biomes), full connection lifecycle (status/login/configuration/play), chunk streaming, creative block editing, and the protocol/nbt/registry infrastructure.
This commit is contained in:
commit
a7bb9496ae
146 changed files with 217621 additions and 0 deletions
34
internal/worldgen/randomstate.go
Normal file
34
internal/worldgen/randomstate.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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
|
||||
}
|
||||
|
||||
// NewRandomState builds the seeding context for the given world seed.
|
||||
func NewRandomState(seed int64) *RandomState {
|
||||
return &RandomState{
|
||||
factory: NewXoroshiro(seed).ForkPositional(),
|
||||
noises: make(map[string]*NormalNoise),
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue