Use world coordinates for ore placement
This commit is contained in:
parent
a23650fc0b
commit
a73b689449
1 changed files with 10 additions and 8 deletions
|
|
@ -54,8 +54,8 @@ func placeVanillaOres(c *Chunk, seed int64, cx, cz int32, biomes *[16][16]string
|
||||||
}
|
}
|
||||||
attempts := plan.Count.Sample(random)
|
attempts := plan.Count.Sample(random)
|
||||||
for attempt := 0; attempt < attempts; attempt++ {
|
for attempt := 0; attempt < attempts; attempt++ {
|
||||||
x := int(random.NextIntN(16))
|
x := int(cx)*16 + int(random.NextIntN(16))
|
||||||
z := int(random.NextIntN(16))
|
z := int(cz)*16 + int(random.NextIntN(16))
|
||||||
y := plan.SampleY(random, MinY, WorldHeight)
|
y := plan.SampleY(random, MinY, WorldHeight)
|
||||||
placeOreEllipsoid(c, random, x, y, z, config.Size, config.DiscardAirExposure, targets)
|
placeOreEllipsoid(c, random, x, y, z, config.Size, config.DiscardAirExposure, targets)
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,8 @@ func placeOreEllipsoid(c *Chunk, random worldgen.RandomSource, originX, originY,
|
||||||
minY, maxY := int(math.Floor(sphere.y-sphere.radius)), int(math.Floor(sphere.y+sphere.radius))
|
minY, maxY := int(math.Floor(sphere.y-sphere.radius)), int(math.Floor(sphere.y+sphere.radius))
|
||||||
minZ, maxZ := int(math.Floor(sphere.z-sphere.radius)), int(math.Floor(sphere.z+sphere.radius))
|
minZ, maxZ := int(math.Floor(sphere.z-sphere.radius)), int(math.Floor(sphere.z+sphere.radius))
|
||||||
for x := minX; x <= maxX; x++ {
|
for x := minX; x <= maxX; x++ {
|
||||||
if x < 0 || x >= 16 {
|
localX := x - int(c.X)*16
|
||||||
|
if localX < 0 || localX >= 16 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dx := (float64(x) + 0.5 - sphere.x) / sphere.radius
|
dx := (float64(x) + 0.5 - sphere.x) / sphere.radius
|
||||||
|
|
@ -173,21 +174,22 @@ func placeOreEllipsoid(c *Chunk, random worldgen.RandomSource, originX, originY,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for z := minZ; z <= maxZ; z++ {
|
for z := minZ; z <= maxZ; z++ {
|
||||||
if z < 0 || z >= 16 {
|
localZ := z - int(c.Z)*16
|
||||||
|
if localZ < 0 || localZ >= 16 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dz := (float64(z) + 0.5 - sphere.z) / sphere.radius
|
dz := (float64(z) + 0.5 - sphere.z) / sphere.radius
|
||||||
pos := [3]int{x, y, z}
|
pos := [3]int{localX, y, localZ}
|
||||||
if dx*dx+dy*dy+dz*dz >= 1 || visited[pos] {
|
if dx*dx+dy*dy+dz*dz >= 1 || visited[pos] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
visited[pos] = true
|
visited[pos] = true
|
||||||
current := c.GetBlock(x, y, z)
|
current := c.GetBlock(localX, y, localZ)
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
if !target.replaceables[current] || discard > 0 && random.NextFloat() < float32(discard) && exposedToAir(c, x, y, z) {
|
if !target.replaceables[current] || discard > 0 && random.NextFloat() < float32(discard) && exposedToAir(c, localX, y, localZ) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.SetBlock(x, y, z, target.state)
|
c.SetBlock(localX, y, localZ, target.state)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue