Fluid registry
This commit is contained in:
+14
-3
@@ -9,6 +9,7 @@ import {
|
||||
type EffectJson,
|
||||
type EntityJson,
|
||||
type EntityModelJson,
|
||||
type FluidJson,
|
||||
type ItemJson,
|
||||
type OreJson,
|
||||
type RecipeJson,
|
||||
@@ -58,6 +59,7 @@ export interface LoadedMod {
|
||||
entities: { file: string; json: EntityJson }[];
|
||||
entity_models: { file: string; json: EntityModelJson }[];
|
||||
effects: { file: string; json: EffectJson }[];
|
||||
fluids: { file: string; json: FluidJson }[];
|
||||
tags: { file: string; json: TagJson }[];
|
||||
loot_tables: { file: string; json: LootTableJson }[];
|
||||
biomes: { file: string; json: BiomeJson }[];
|
||||
@@ -88,6 +90,7 @@ export function mod_data(mod: LoadedMod): ModData {
|
||||
entities: mod.entities.map((e) => e.json),
|
||||
entity_models: mod.entity_models.map((m) => m.json),
|
||||
effects: mod.effects.map((e) => e.json),
|
||||
fluids: mod.fluids.map((f) => f.json),
|
||||
tags: mod.tags.map((t) => t.json),
|
||||
loot_tables: mod.loot_tables.map((t) => t.json),
|
||||
biomes: mod.biomes.map((b) => b.json),
|
||||
@@ -159,8 +162,10 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
const entity_model_owners = new Map<string, string[]>();
|
||||
const entity_model_jsons = new Map<string, EntityModelJson>();
|
||||
const effect_owners = new Map<string, string[]>();
|
||||
const fluid_owners = new Map<string, string[]>();
|
||||
const tag_owners = new Map<TagRegistry, Set<string>>();
|
||||
const fluids = new Set<string>();
|
||||
// blocks that flow, which waterloggable blocks can hold
|
||||
const fluid_blocks = 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]);
|
||||
@@ -181,7 +186,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
for (const { json } of mod.blocks) {
|
||||
add(block_owners, json.id, mod.id);
|
||||
if (json.item !== false) add(item_owners, json.id, mod.id);
|
||||
if (json.fluid) fluids.add(json.id);
|
||||
if (json.fluid) fluid_blocks.add(json.id);
|
||||
}
|
||||
// one without a texture is the item of the mod's block, which is already counted
|
||||
for (const { json } of mod.items) if (json.texture !== undefined) add(item_owners, json.id, mod.id);
|
||||
@@ -198,6 +203,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
entity_model_jsons.set(json.id, json);
|
||||
}
|
||||
for (const { json } of mod.effects) add(effect_owners, json.id, mod.id);
|
||||
for (const { json } of mod.fluids) add(fluid_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.noises ?? []) add(worldgen_owners.noise, json.id, mod.id);
|
||||
@@ -279,7 +285,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
if (json.loot_table) uses(file, json.loot_table, "loot table");
|
||||
if (json.waterloggable) {
|
||||
uses(file, json.waterloggable, "block");
|
||||
if (block_owners.has(json.waterloggable) && !fluids.has(json.waterloggable)) {
|
||||
if (block_owners.has(json.waterloggable) && !fluid_blocks.has(json.waterloggable)) {
|
||||
errors.push(`${file}: waterloggable ${json.waterloggable} isn't a fluid`);
|
||||
}
|
||||
}
|
||||
@@ -474,6 +480,11 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
|
||||
}
|
||||
if (json.icon !== undefined) uses(file, json.icon, "texture");
|
||||
}
|
||||
for (const { file, json } of mod.fluids) {
|
||||
if ((fluid_owners.get(json.id)?.length ?? 0) > 1) {
|
||||
errors.push(`${file}: fluid ${json.id} is also defined by ${fluid_owners.get(json.id)!.join(", ")}`);
|
||||
}
|
||||
}
|
||||
for (const { file, json } of mod.spawns) {
|
||||
check_namespace(file, json.entity);
|
||||
const entity = entity_jsons.get(json.entity);
|
||||
|
||||
Reference in New Issue
Block a user