Bind the surface rule tree to the world seed
The tree was parsed once, globally, and shared by every world -- so every condition that needs the seed simply did not work. Compiling it per RandomState fixes four of them at once. noise_threshold sampled a per-column random draw and pretended it was "minecraft:surface"; the other six noises it names were unsupported and returned false. Each condition now holds its own seeded noise, sampled once per column into a small cache the way vanilla's LazyXZCondition does. Powder snow, packed ice and ice appear in the dump for the first time; calcite, swamp water windows and gravel patches have their conditions back too. vertical_gradient tapered through a per-column RNG shared with the other rules. Vanilla rolls a positional random at the exact block, from a factory named by the rule. More importantly the anchor decoder read only above_bottom and discarded which kind of anchor it was, so the deepslate rule's absolute 0..8 collapsed onto y=-64 and **no deepslate existed anywhere in the world**. Anchors now carry their kind and resolve against the real height bounds -- which also retires a hardcoded 384 in y_above. Two more stubs land with them: hole is surfaceDepth <= 0 rather than a constant false, and steep reads the neighbouring column heights. steep needs the whole chunk's heightmap, so the column pass is now two passes -- terrain and fluids for all 256 columns, then surface rules -- which is the order vanilla uses anyway (doFill, then buildSurface). Deepslate was also missing from the block-ID table, and an unknown name resolved to 0, which the caller read as "no block" and skipped. So even a correct rule would have placed nothing. Unknown names are now a parse error, deepslate and mud are in the table, and a rule that resolves to air genuinely places air -- the frozen-ocean surface asks for exactly that. Below y=0 is now entirely deepslate, y=1..7 a scatter, above y=8 none.
This commit is contained in:
parent
1083e47211
commit
c19e5f0e4f
9 changed files with 478 additions and 255 deletions
52
internal/world/deepslate_verify_test.go
Normal file
52
internal/world/deepslate_verify_test.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package world
|
||||
|
||||
import "testing"
|
||||
|
||||
// StateDeepslate is minecraft:deepslate with axis=y, the upright default the
|
||||
// surface rule places.
|
||||
const StateDeepslate uint16 = 27924
|
||||
|
||||
// TestDeepslateLayer guards the stone/deepslate boundary. The rule that draws
|
||||
// it is a vertical_gradient over absolute anchors 0 and 8; the anchor decoder
|
||||
// only read above_bottom, so both collapsed onto y=-64 and the whole world was
|
||||
// stone from bedrock to sky. The block name was missing from the ID table too,
|
||||
// so even a firing rule resolved to 0 and was dropped.
|
||||
func TestDeepslateLayer(t *testing.T) {
|
||||
gen := NewVanillaGenerator(12345)
|
||||
deepBelow, stoneBelow := 0, 0
|
||||
deepAbove := 0
|
||||
transition := 0
|
||||
for _, p := range [][2]int32{{0, 0}, {5, -7}, {-13, 21}} {
|
||||
ch := gen(p[0], p[1])
|
||||
for lx := 0; lx < 16; lx++ {
|
||||
for lz := 0; lz < 16; lz++ {
|
||||
for wy := MinY; wy <= 40; wy++ {
|
||||
switch b := ch.GetBlock(lx, wy, lz); {
|
||||
case b == StateDeepslate && wy < 0:
|
||||
deepBelow++
|
||||
case b == StateDeepslate && wy >= 0 && wy < 8:
|
||||
transition++
|
||||
case b == StateDeepslate && wy >= 8:
|
||||
deepAbove++
|
||||
case b == StateStone && wy < 0:
|
||||
stoneBelow++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Logf("deepslate below y=0: %d (stone there: %d), in y=0..7: %d, above y=8: %d",
|
||||
deepBelow, stoneBelow, transition, deepAbove)
|
||||
if deepBelow == 0 {
|
||||
t.Error("no deepslate below y=0")
|
||||
}
|
||||
if stoneBelow != 0 {
|
||||
t.Errorf("%d plain stone blocks survive below y=0; the gradient is not reaching them", stoneBelow)
|
||||
}
|
||||
if deepAbove != 0 {
|
||||
t.Errorf("%d deepslate blocks above y=8; the upper anchor is not holding", deepAbove)
|
||||
}
|
||||
if transition == 0 {
|
||||
t.Error("the y=0..7 stone/deepslate scatter is empty")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue