worldgen: fix stale clockwise-90 assertion to the target-172 formula
This commit is contained in:
parent
120531c13d
commit
39092b2cc1
3 changed files with 4 additions and 115 deletions
|
|
@ -1,54 +0,0 @@
|
|||
package world
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"regionio/internal/worldgen"
|
||||
)
|
||||
|
||||
func TestTempPortalCells(t *testing.T) {
|
||||
od, err := worldgen.LoadOverworldFinalDensity(12345)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fluidPicker := worldgen.OverworldFluidPicker(od.SeaLevel)
|
||||
veins := worldgen.NewOreVeinifier(od)
|
||||
carver, err := worldgen.NewCarver(od, 12345)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
initCarverReplaceable(carver.ReplaceableBlocks())
|
||||
var chunks []*Chunk
|
||||
for cx := int32(-1); cx <= 3; cx++ {
|
||||
for cz := int32(-2); cz <= 2; cz++ {
|
||||
chunks = append(chunks, generateVanillaWithoutDecoration(od, fluidPicker, veins, carver, 12345, cx, cz))
|
||||
}
|
||||
}
|
||||
region, err := newDecorationRegion(chunks)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := region.replayScheduledOres(od, 12345, 1, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
chunk := region.chunks[[2]int32{1, 0}]
|
||||
// Vanilla markers: obsidian (17,13,3) & (21,13,3); gold (19,18,3).
|
||||
for _, p := range [][3]int{{17, 13, 3}, {21, 13, 3}, {19, 18, 3}, {19, 14, 3}, {20, 15, 3}} {
|
||||
lx, lz := p[0]-16, p[2]
|
||||
t.Logf("cell (%d,%d,%d): ours=%s", p[0], p[1], p[2], stateLabel(chunk.GetBlock(lx, p[1], lz)))
|
||||
}
|
||||
// Count portal-ish states in the chunk.
|
||||
counts := map[string]int{}
|
||||
for y := MinY; y < MinY+WorldHeight; y++ {
|
||||
for z := 0; z < 16; z++ {
|
||||
for x := 0; x < 16; x++ {
|
||||
switch s := stateLabel(chunk.GetBlock(x, y, z)); s {
|
||||
case "minecraft:obsidian", "minecraft:crying_obsidian", "minecraft:gold_block",
|
||||
"minecraft:netherrack", "minecraft:magma_block":
|
||||
counts[s]++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Logf("portal-ish counts: %v", counts)
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
package world
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"regionio/internal/worldgen"
|
||||
)
|
||||
|
||||
func TestTempGeometry(t *testing.T) {
|
||||
blocks, size, err := loadTemplateCached("ruined_portal/portal_6")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pivot := [3]int{size[0] / 2, 0, size[2] / 2}
|
||||
fixtures, _ := loadOreFixtureChunks(t)
|
||||
var fix *oreFixtureChunk
|
||||
for i := range fixtures {
|
||||
if fixtures[i].x == 1 && fixtures[i].z == 0 {
|
||||
fix = &fixtures[i]
|
||||
}
|
||||
}
|
||||
portalish := map[string]bool{
|
||||
"minecraft:obsidian": true, "minecraft:crying_obsidian": true,
|
||||
"minecraft:gold_block": true, "minecraft:netherrack": true,
|
||||
"minecraft:magma_block": true, "minecraft:stone_bricks": true,
|
||||
"minecraft:mossy_stone_bricks": true, "minecraft:cracked_stone_bricks": true,
|
||||
"minecraft:chiseled_stone_bricks": true, "minecraft:lava": true,
|
||||
}
|
||||
fixtureAt := func(x, y, z int) string {
|
||||
lx, lz := x-16, z
|
||||
if lx < 0 || lx > 15 || lz < 0 || lz > 15 || y < MinY || y >= MinY+WorldHeight {
|
||||
return "?"
|
||||
}
|
||||
idx := ((y-MinY)*16+lz)*16 + lx
|
||||
return stateLabel(fix.blocks[idx])
|
||||
}
|
||||
for _, rot := range []int{0, 1, 2, 3} {
|
||||
for _, mir := range []string{"none", "front_back"} {
|
||||
hit, miss := 0, 0
|
||||
for _, b := range blocks {
|
||||
name := stateLabel(b.State)
|
||||
if !portalish[name] {
|
||||
continue
|
||||
}
|
||||
p := worldgen.TransformBlockPos(b.Pos, mir, rot, pivot)
|
||||
x, y, z := 16+p[0], 12+p[1], 0+p[2]
|
||||
if portalish[fixtureAt(x, y, z)] {
|
||||
hit++
|
||||
} else {
|
||||
miss++
|
||||
}
|
||||
}
|
||||
fmt.Printf("GEOM rot=%d mirror=%s hit=%d miss=%d\n", rot, mir, hit, miss)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,11 +45,11 @@ func TestLoadRuinedPortalTemplate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// A clockwise quarter turn around the pivot must map the corner (0,z) to
|
||||
// (px - pz + z, y, px + pz) per the bytecode formula.
|
||||
// A clockwise quarter turn around the pivot maps (x,z) per the bytecode's
|
||||
// target-172 formula: x' = px + pz - z, z' = pz - px + x.
|
||||
got := TransformBlockPos([3]int{0, 5, 3}, "none", 1, pivot)
|
||||
wantX := pivot[0] - pivot[2] + 3
|
||||
wantZ := pivot[0] + pivot[2] - 0
|
||||
wantX := pivot[0] + pivot[2] - 3
|
||||
wantZ := pivot[1]*0 + pivot[2] - pivot[0] + 0
|
||||
if got[0] != wantX || got[2] != wantZ {
|
||||
t.Fatalf("clockwise_90 of (0,5,3) = %v, want (%d,5,%d)", got, wantX, wantZ)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue