Loading schematics

This commit is contained in:
2026-11-15 19:54:08 -03:00
parent 6bb2c87373
commit 0564275f58
15 changed files with 142 additions and 17 deletions
+14
View File
@@ -42,6 +42,7 @@ import {
import { feature_refs, type FeatureJson } from "./worldgen/features.ts";
import { cell_height_problem } from "./world_shape.ts";
import type { ModData } from "./mod_loader.ts";
import type { Schematic } from "./schematic.ts";
export interface ModReport {
id: string;
@@ -74,6 +75,8 @@ export interface LoadedMod {
biome_sources: { file: string; json: BiomeSourceJson }[];
dimensions: { file: string; json: DimensionJson }[];
features: { file: string; json: FeatureJson }[];
// schematics/<name>.cbsm, decoded and with their ids
schematics: { file: string; json: Schematic }[];
// config.json's settings, see docs/modding/misc/config.md
config?: Record<string, unknown>;
textures: string[];
@@ -105,6 +108,7 @@ export function mod_data(mod: LoadedMod): ModData {
biome_sources: mod.biome_sources.map((b) => b.json),
dimensions: mod.dimensions.map((d) => d.json),
features: mod.features.map((f) => f.json),
schematics: mod.schematics.map((s) => s.json),
config: mod.config,
};
}
@@ -503,6 +507,16 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
}
if (json.texture !== undefined) uses(file, json.texture, "texture");
}
// cubi: entities, like dropped items, are the engine's
for (const { file, json } of mod.schematics) {
for (const { id } of json.palette) uses(file, id, "block");
for (const { id } of json.entities) {
check_namespace(file, id);
if (!id.startsWith("cubi:") && !entity_owners.has(id)) {
errors.push(`${file}: entity ${id} doesn't exist`);
}
}
}
for (const { file, json } of mod.spawns) {
check_namespace(file, json.entity);
const entity = entity_jsons.get(json.entity);