World gen stuff
This commit is contained in:
+13
-3
@@ -13,6 +13,7 @@ import { generate_noise_chunk } from "./worldgen/noise_chunk.ts";
|
||||
import { get_biome } from "./worldgen/biomes.ts";
|
||||
import type { Generator } from "./worldgen/generator.ts";
|
||||
import { named_noise_2d, named_noise_3d } from "./worldgen/noise.ts";
|
||||
import { Tags } from "./tags.ts";
|
||||
|
||||
export { named_noise_2d, named_noise_3d };
|
||||
|
||||
@@ -115,8 +116,17 @@ function generate_ores(
|
||||
default_values: number[] | undefined,
|
||||
) {
|
||||
const usable = ores
|
||||
.map((ore) => ({ ...ore, nid: block_ids[ore.id], replaces_nid: block_ids[ore.replaces] }))
|
||||
.filter((ore) => ore.nid !== undefined && ore.replaces_nid !== undefined);
|
||||
.map((ore) => ({
|
||||
...ore,
|
||||
nid: block_ids[ore.id],
|
||||
replaces_nids: new Set(
|
||||
[ore.replaces].flat()
|
||||
.flatMap((id) => id.startsWith("#") ? Tags.get("blocks", id) : [id])
|
||||
.map((id) => block_ids[id])
|
||||
.filter((nid) => nid !== undefined),
|
||||
),
|
||||
}))
|
||||
.filter((ore) => ore.nid !== undefined && ore.replaces_nids.size > 0);
|
||||
if (usable.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -132,7 +142,7 @@ function generate_ores(
|
||||
}
|
||||
for (let i = 0; i < usable.length; i++) {
|
||||
const ore = usable[i];
|
||||
if (current !== ore.replaces_nid || y < ore.min_y || y > ore.max_y) {
|
||||
if (!ore.replaces_nids.has(current) || y < ore.min_y || y > ore.max_y) {
|
||||
continue;
|
||||
}
|
||||
const wx = chunk_x * CHUNK_SIZE + lx;
|
||||
|
||||
Reference in New Issue
Block a user