Configured carvers: caves and canyons
The router's noise caves are one kind of cave. The other kind -- the long
winding tunnels with rooms and side branches, and the ravines that cut down
through the terrain -- is walked, step by step, by a random source, and none of
it existed.
The shape of the work is unusual enough to state plainly. To carve one chunk,
vanilla replays every carver seeded in the 17x17 chunks around it and keeps only
what lands inside, so the same tunnel is walked up to 289 times across a world.
That redundancy is the point: it is what lets a chunk be carved without
generating its neighbours, which is the only way carving fits a generator that
produces one chunk at a time. A carve-once-write-into-neighbours design would be
cheaper and would not reproduce vanilla's mask and ordering.
Two primitives had to be right before any of it could be, and both are pinned
against values captured from the jar:
* setLargeFeatureSeed, which decides which chunks start a cave. It combines
its two products with XOR; setDecorationSeed, which it otherwise resembles,
uses addition and forces the low bit. Getting them the wrong way round moves
every tunnel in the world and nothing complains.
* Mth.sin and Mth.cos, which are a 65536-entry lookup table and not libm.
Mth.sin(-1.0) is -0.8414514 against Math.sin's -0.8414709848078965, and a
tunnel that walks by adding cos(yaw) a hundred times ends up somewhere else
entirely if that difference is smoothed away.
Carving lands between the surface pass and decoration, where vanilla puts it,
and both neighbours matter: the surface rules must already have placed grass for
a cave mouth to be retextured, and decoration must come after so nothing is
planted over a hole. The heights decoration plants against are recomputed
afterwards, which is why vanilla re-primes its heightmaps at the start of the
feature step.
The configs are extracted from the jar rather than transcribed, along with the
flattened #minecraft:overworld_carver_replaceables tag, so the probabilities and
Y ranges are data. Open volume below y=60 rises 28% over sixteen sampled chunks,
tunnels cut at or below y=-56 fill with lava rather than air (869 blocks, no
air), and the cost is inside the noise floor of the density pass.
This commit is contained in:
parent
0f76058db6
commit
c6185d88c8
13 changed files with 1402 additions and 9 deletions
|
|
@ -172,7 +172,28 @@ type Legacy struct{ seed uint64 }
|
|||
|
||||
// NewLegacy seeds a Legacy source, applying Java's seed scramble.
|
||||
func NewLegacy(seed int64) *Legacy {
|
||||
return &Legacy{seed: (uint64(seed) ^ lcgMultiplier) & lcgMask}
|
||||
r := &Legacy{}
|
||||
r.SetSeed(seed)
|
||||
return r
|
||||
}
|
||||
|
||||
// SetSeed is java.util.Random.setSeed, which worldgen reseeds in place.
|
||||
func (r *Legacy) SetSeed(seed int64) {
|
||||
r.seed = (uint64(seed) ^ lcgMultiplier) & lcgMask
|
||||
}
|
||||
|
||||
// SetLargeFeatureSeed is WorldgenRandom.setLargeFeatureSeed: seed from the
|
||||
// world seed, draw two longs, and reseed from those mixed with the chunk
|
||||
// coordinates.
|
||||
//
|
||||
// The two products are combined with XOR. setDecorationSeed, which looks almost
|
||||
// identical, uses addition and forces the low bit — they are different methods
|
||||
// and confusing them silently moves every carver in the world.
|
||||
func (r *Legacy) SetLargeFeatureSeed(seed int64, chunkX, chunkZ int) {
|
||||
r.SetSeed(seed)
|
||||
a := r.NextLong()
|
||||
b := r.NextLong()
|
||||
r.SetSeed(int64(chunkX)*a ^ int64(chunkZ)*b ^ seed)
|
||||
}
|
||||
|
||||
// next returns the top `b` bits of the next LCG state.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue