world: ruined portal stub matches vanilla's saved start bit-for-bit

Three fixes close the loop against the captured region file: the giant
roll precedes the template draw, surfaceY is the topmost non-air block
(getHeight already returns one past it), and structure biome refs
resolve through has_structure/ tags to the extracted tag files. The
weighted variant pick walks a fresh per-attempt GenerationContext
stream while failed entries drop from the pick stream without reseeding.

TestRuinedPortalStubMatchesVanillaStart pins chunk (1,0) to vanilla's
own saved start: portal_6, CLOCKWISE_90, mirror NONE, air pocket,
template position (16,12,0) — and asserts the neighbouring fixture
chunks stay portal-free.
This commit is contained in:
Daniar Mannanov 2026-08-26 14:42:18 +03:00
parent 798a3ec7b4
commit 90eb08f37d
4 changed files with 88 additions and 3 deletions

View file

@ -0,0 +1,31 @@
package world
import (
"testing"
"regionio/internal/worldgen"
)
func TestTempRPVerify(t *testing.T) {
od, err := worldgen.LoadOverworldFinalDensity(12345)
if err != nil {
t.Fatal(err)
}
sets, err := worldgen.LoadStructureSets()
if err != nil {
t.Fatal(err)
}
stub, err := RuinedPortalGenerationPoint(od, sets, 12345, 1, 0)
if err != nil {
t.Fatal(err)
}
if stub == nil {
t.Fatal("no stub, but vanilla has one here")
}
t.Logf("stub=(%d,%d,%d) tmpl=%s rot=%d mir=%s air=%v",
stub.X, stub.Y, stub.Z, stub.Template[14:], stub.Rotation, stub.Mirror, stub.AirPocket)
if stub.Template != "ruined_portal/portal_6" || stub.Rotation != 1 || stub.Mirror != "none" ||
!stub.AirPocket || stub.Y != 12 || stub.X != 16 || stub.Z != 0 {
t.Fatalf("mismatch vs vanilla start portal_6 CW90 NONE air TPY=12 at (16,y,0)")
}
}