Biome as data
This commit is contained in:
+12
-3
@@ -19,7 +19,7 @@ import { BUILTIN_MODELS, type ModelJson } from "./block_models.ts";
|
||||
import { resolve_tags } from "./tags.ts";
|
||||
import type { TextureJson } from "./texture_animation.ts";
|
||||
import { loot_references, type LootTableJson } from "./loot.ts";
|
||||
import { BIOMES } from "./worldgen/overworld.ts";
|
||||
import { biome_blocks, type BiomeJson } from "./worldgen/biomes.ts";
|
||||
|
||||
export interface ModReport {
|
||||
id: string;
|
||||
@@ -43,6 +43,7 @@ export interface LoadedMod {
|
||||
effects: { file: string; json: EffectJson }[];
|
||||
tags: { file: string; json: TagJson }[];
|
||||
loot_tables: { file: string; json: LootTableJson }[];
|
||||
biomes: { file: string; json: BiomeJson }[];
|
||||
textures: string[];
|
||||
// absolute paths by texture id
|
||||
texture_files: Map<string, string>;
|
||||
@@ -90,6 +91,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
const tag_owners = new Map<TagRegistry, Set<string>>();
|
||||
const liquids = new Set<string>();
|
||||
const loot_tables = new Set<string>();
|
||||
const biome_owners = new Map<string, string[]>();
|
||||
const add = (map: Map<string, string[]>, id: string, mod: string) => map.set(id, [...(map.get(id) ?? []), mod]);
|
||||
|
||||
const textures = new Set<string>(engine_textures);
|
||||
@@ -113,6 +115,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
}
|
||||
for (const { json } of mod.effects) add(effect_owners, json.id, mod.id);
|
||||
for (const { json } of mod.loot_tables ?? []) loot_tables.add(json.id);
|
||||
for (const { json } of mod.biomes ?? []) add(biome_owners, json.id, mod.id);
|
||||
for (const { json } of mod.tags) {
|
||||
if (!tag_owners.has(json.registry)) tag_owners.set(json.registry, new Set());
|
||||
tag_owners.get(json.registry)!.add(json.id);
|
||||
@@ -272,6 +275,12 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
// mods' conditions and functions are registered by scripts, the server checks them when it starts
|
||||
for (const id of refs.custom) check_namespace(file, id);
|
||||
}
|
||||
for (const { file, json } of mod.biomes ?? []) {
|
||||
if ((biome_owners.get(json.id)?.length ?? 0) > 1) {
|
||||
errors.push(`${file}: biome ${json.id} is also defined by ${biome_owners.get(json.id)!.join(", ")}`);
|
||||
}
|
||||
for (const id of biome_blocks(json)) uses(file, id, "block");
|
||||
}
|
||||
for (const { file, json } of mod.effects) {
|
||||
if ((effect_owners.get(json.id)?.length ?? 0) > 1) {
|
||||
errors.push(`${file}: effect ${json.id} is also defined by ${effect_owners.get(json.id)!.join(", ")}`);
|
||||
@@ -285,9 +294,9 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
else if (entity.behavior !== "monster") {
|
||||
errors.push(`${file}: ${json.entity} isn't a monster, only monsters spawn on their own for now`);
|
||||
}
|
||||
// biomes are the engine's, whatever their namespace
|
||||
for (const biome of json.biomes ?? []) {
|
||||
if (!(biome in BIOMES)) errors.push(`${file}: biome ${biome} doesn't exist`);
|
||||
check_namespace(file, biome);
|
||||
if (!biome_owners.has(biome)) errors.push(`${file}: biome ${biome} doesn't exist`);
|
||||
}
|
||||
}
|
||||
for (const { file, json } of mod.entity_models) {
|
||||
|
||||
Reference in New Issue
Block a user