45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package world
|
|
|
|
import "testing"
|
|
|
|
func TestPlacedOresUseStoneAndDeepslateTargets(t *testing.T) {
|
|
gen := NewVanillaGenerator(12345)
|
|
want := map[uint16]string{
|
|
131: "iron ore",
|
|
132: "deepslate iron ore",
|
|
5307: "diamond ore",
|
|
5308: "deepslate diamond ore",
|
|
}
|
|
counts := make(map[uint16]int)
|
|
for cx := int32(-8); cx <= 8; cx += 4 {
|
|
for cz := int32(-8); cz <= 8; cz += 4 {
|
|
chunk := gen(cx, cz)
|
|
for y := MinY; y < 128; y++ {
|
|
for x := 0; x < 16; x++ {
|
|
for z := 0; z < 16; z++ {
|
|
counts[chunk.GetBlock(x, y, z)]++
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for state, name := range want {
|
|
if counts[state] == 0 {
|
|
t.Errorf("no %s generated by placed ore features", name)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPlacedOresAreDeterministic(t *testing.T) {
|
|
gen := NewVanillaGenerator(4242)
|
|
a, b := gen(3, -2), gen(3, -2)
|
|
for y := MinY; y < MinY+WorldHeight; y++ {
|
|
for x := 0; x < 16; x++ {
|
|
for z := 0; z < 16; z++ {
|
|
if got, want := a.GetBlock(x, y, z), b.GetBlock(x, y, z); got != want {
|
|
t.Fatalf("block (%d,%d,%d): first %d second %d", x, y, z, got, want)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|