Fluid registry

This commit is contained in:
2026-10-25 14:05:57 -03:00
parent 0cfa4d9b4a
commit 17d83acfc8
18 changed files with 144 additions and 17 deletions
+15 -4
View File
@@ -11,6 +11,7 @@ import {
type EffectJson,
type EntityJson,
type EntityModelJson,
type FluidJson,
type ItemJson,
type ManifestJson,
type OreJson,
@@ -21,6 +22,7 @@ import {
validate_effect,
validate_entity,
validate_entity_model,
validate_fluid,
validate_item,
validate_manifest,
validate_model,
@@ -79,8 +81,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, loot table and
// biome, and the mod's config
// data.json every block, model, item, recipe, ore, entity, entity model, effect, fluid, tag, loot
// table and biome, and the mod's config
// scripts/<side>.js
// textures/<name>.png the texture <mod id>:<name>
// textures/<name>.json its animation, if it has one
@@ -177,6 +179,7 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
problems,
) as EntityModelJson[],
effects: checked(raw_data.effects, "effects", validate_effect, problems) as EffectJson[],
fluids: checked(raw_data.fluids, "fluids", validate_fluid, problems) as FluidJson[],
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[],
@@ -206,7 +209,15 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
problems.push("data.json: config must be an object");
}
// a mod only registers ids in its own namespace
const registered = [...data.blocks, ...data.models, ...data.items, ...data.entities, ...data.entity_models];
const registered = [
...data.blocks,
...data.models,
...data.items,
...data.entities,
...data.entity_models,
...data.effects,
...data.fluids,
];
const worldgen = [
...data.noises!,
...data.density_functions!,
@@ -214,7 +225,7 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
...data.biome_sources!,
...data.features!,
];
for (const { id } of [...registered, ...data.effects, ...data.loot_tables!, ...data.biomes!, ...worldgen]) {
for (const { id } of [...registered, ...data.loot_tables!, ...data.biomes!, ...worldgen]) {
if (typeof id === "string" && id.split(":")[0] !== mod) problems.push(`${id} isn't in this mod's namespace`);
}