Biome as data

This commit is contained in:
2026-10-08 13:34:32 -03:00
parent 9f0b049148
commit 7e7ac8f6f4
49 changed files with 913 additions and 224 deletions
+5 -2
View File
@@ -29,6 +29,7 @@ import {
} from "./mod_data.ts";
import type { ModData } from "./mod_loader.ts";
import { type LootTableJson, validate_loot_table } from "./loot.ts";
import { type BiomeJson, validate_biome } from "./worldgen/biomes.ts";
import { texture_animation, type TextureJson, validate_texture_json } from "./texture_animation.ts";
import { ENGINE_GLOBAL } from "./hooks.ts";
@@ -64,7 +65,8 @@ export class BmodError extends Error {
// the zip's layout:
// manifest.json the mod's manifest, with "scripts" and "credits" pointing into the zip
// data.json every block, model, item, recipe, ore, entity, entity model, effect, tag and loot table
// data.json every block, model, item, recipe, ore, entity, entity model, effect, tag, loot table and
// biome
// scripts/<side>.js
// textures/<name>.png the texture <mod id>:<name>
// textures/<name>.json its animation, if it has one
@@ -163,10 +165,11 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
effects: checked(raw_data.effects, "effects", validate_effect, problems) as EffectJson[],
tags: checked(raw_data.tags, "tags", validate_tag, problems) as TagJson[],
loot_tables: checked(raw_data.loot_tables, "loot_tables", validate_loot_table, problems) as LootTableJson[],
biomes: checked(raw_data.biomes, "biomes", validate_biome, problems) as BiomeJson[],
};
// a mod only registers ids in its own namespace
const registered = [...data.blocks, ...data.models, ...data.items, ...data.entities, ...data.entity_models];
for (const { id } of [...registered, ...data.effects, ...data.loot_tables!]) {
for (const { id } of [...registered, ...data.effects, ...data.loot_tables!, ...data.biomes!]) {
if (typeof id === "string" && id.split(":")[0] !== mod) problems.push(`${id} isn't in this mod's namespace`);
}