Add various generic models

This commit is contained in:
2026-10-12 17:56:47 -03:00
parent e5baeab193
commit d4eff11f3e
34 changed files with 786 additions and 251 deletions
+12 -4
View File
@@ -29,13 +29,13 @@ import { type BiomeJson, register_biome } from "./worldgen/biomes.ts";
import type { BiomeSourceJson, DensityFunctionJson, NoiseJson, NoiseSettingsJson } from "./worldgen/data.ts";
import type { FeatureJson } from "./worldgen/features.ts";
import { register_block_item } from "./utils.ts";
import type { ModelJson } from "./block_models.ts";
import { find_model, type ModelFileJson, type ModelJson, resolve_models } from "./block_models.ts";
// everything a mod's json files hold, merged into one file by the build (build/mods/<id>/<hash>/data.json)
export interface ModData {
blocks: BlockJson[];
// block models, see common/block_models.ts
models: ModelJson[];
// block models as mods write them, parents not merged in yet. see common/block_models.ts
models: ModelFileJson[];
items: ItemJson[];
recipes: RecipeJson[];
ores: OreJson[];
@@ -107,7 +107,15 @@ export function register_mod_data(mods: { id: string; data: ModData }[]): Recipe
for (const { id, data } of mods) {
try {
for (const model of data.models) {
// parents are this mod's or an earlier one's, which are already registered with theirs merged in
const { models, problems } = resolve_models(
data.models,
(model_id) => find_model(model_id, {}) ?? EverythingRegistry.get<ModelJson>("models", model_id),
);
if (problems.length > 0) {
throw new Error(problems.map(({ id, problem }) => `model ${id}: ${problem}`).join("\n"));
}
for (const model of models) {
EverythingRegistry.register<ModelJson>("models", model.id, model);
}
for (const json of data.blocks) {