Remove duplicate code
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// biomes as data: worldgen/biomes/<name>.json in a mod, see docs/modding/worldgen/biomes.md. which biome a column
|
||||
// gets is the generator's biome rules (worldgen/biome_source), these say what a biome looks like once it's picked
|
||||
import { EverythingRegistry } from "../everything_registry.ts";
|
||||
import { ID_PATTERN } from "../mod_data.ts";
|
||||
import { ID_PATTERN, is_object } from "../mod_data.ts";
|
||||
import { farming_day } from "../time.ts";
|
||||
|
||||
export const SEASONS = ["spring", "summer", "autumn", "winter"] as const;
|
||||
@@ -164,7 +164,3 @@ export function validate_biome(json: unknown): string[] {
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
function is_object(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// world generation as data: noises, density functions, noise settings (a generator) and biome sources, see
|
||||
// docs/modding/worldgen/terrain.md. checked here, compiled by density.ts and generator.ts. the names follow
|
||||
// minecraft's (density functions, the noise router, surface rules) where the idea is the same
|
||||
import { ID_PATTERN, TAG_ID_PATTERN } from "../mod_data.ts";
|
||||
import { ID_PATTERN, is_object, TAG_ID_PATTERN } from "../mod_data.ts";
|
||||
|
||||
// ids of worldgen data can have folders, like "bworld:overworld/erosion"
|
||||
export const WORLDGEN_ID_PATTERN = TAG_ID_PATTERN;
|
||||
@@ -540,7 +540,3 @@ function block_id(value: unknown, field: string, refs: WorldgenRefs, problems: s
|
||||
if (typeof value === "string" && ID_PATTERN.test(value)) refs.blocks.add(value);
|
||||
else problems.push(`${field} must be a block's id`);
|
||||
}
|
||||
|
||||
function is_object(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { EverythingRegistry } from "../everything_registry.ts";
|
||||
import type { BlockRegistry } from "../everything_registry.ts";
|
||||
import { CHUNK_HEIGHT, CHUNK_SIZE } from "../constants.ts";
|
||||
import { ID_PATTERN, TAG_ID_PATTERN } from "../mod_data.ts";
|
||||
import { ID_PATTERN, is_object, TAG_ID_PATTERN } from "../mod_data.ts";
|
||||
import { list_matches } from "../tags.ts";
|
||||
import { can_stand_on } from "../utils.ts";
|
||||
import { AIR_ID } from "../protocol.ts";
|
||||
@@ -598,7 +598,3 @@ function height_provider(json: unknown): IntProvider {
|
||||
const span = anchor(object.max_inclusive) - min + 1;
|
||||
return (chunk) => min + Math.floor(chunk.rng.next() * span);
|
||||
}
|
||||
|
||||
function is_object(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user