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.
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package world
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"regionio/internal/worldgen"
|
|
)
|
|
|
|
// TestRuinedPortalStubMatchesVanillaStart pins the whole placement chain —
|
|
// grid claim, weighted variant pick, setup/template/rotation/mirror draws,
|
|
// findSuitableY against pre-carve heights, and the 3D-biome filter — to the
|
|
// start vanilla itself saved into the captured chunk (1,0): template
|
|
// ruined_portal/portal_6, CLOCKWISE_90, mirror NONE, air pocket on,
|
|
// template position (16,12,0).
|
|
func TestRuinedPortalStubMatchesVanillaStart(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's captured start lives here")
|
|
}
|
|
if stub.Template != "ruined_portal/portal_6" ||
|
|
stub.Rotation != 1 || stub.Mirror != "none" ||
|
|
!stub.AirPocket || stub.X != 16 || stub.Y != 12 || stub.Z != 0 {
|
|
t.Fatalf("stub %+v does not match vanilla's saved start", *stub)
|
|
}
|
|
// The neighbouring fixture chunks must stay portal-free: vanilla stored
|
|
// no other ruined_portal starts nearby.
|
|
for _, c := range [][2]int32{{0, 0}, {0, 1}, {-1, -1}} {
|
|
other, err := RuinedPortalGenerationPoint(od, sets, 12345, c[0], c[1])
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if other != nil {
|
|
t.Fatalf("unexpected extra stub at (%d,%d): %+v", c[0], c[1], *other)
|
|
}
|
|
}
|
|
}
|