Move effects into the modding api

This commit is contained in:
2026-10-02 11:53:44 -03:00
parent 4309c700d2
commit e5dcb97643
33 changed files with 458 additions and 109 deletions
+9
View File
@@ -3,6 +3,7 @@
import {
type BlockJson,
choice_list,
type EffectJson,
type EntityJson,
type EntityModelJson,
type ItemJson,
@@ -37,6 +38,7 @@ export interface LoadedMod {
spawns: { file: string; json: SpawnJson }[];
entities: { file: string; json: EntityJson }[];
entity_models: { file: string; json: EntityModelJson }[];
effects: { file: string; json: EffectJson }[];
tags: { file: string; json: TagJson }[];
textures: string[];
// absolute paths by texture id
@@ -79,6 +81,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
const entity_jsons = new Map<string, EntityJson>();
const entity_model_owners = new Map<string, string[]>();
const entity_model_jsons = new Map<string, EntityModelJson>();
const effect_owners = new Map<string, string[]>();
const tag_owners = new Map<TagRegistry, Set<string>>();
const add = (map: Map<string, string[]>, id: string, mod: string) => map.set(id, [...(map.get(id) ?? []), mod]);
@@ -99,6 +102,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
add(entity_model_owners, json.id, mod.id);
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.tags) {
if (!tag_owners.has(json.registry)) tag_owners.set(json.registry, new Set());
tag_owners.get(json.registry)!.add(json.id);
@@ -233,6 +237,11 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
if (json.model !== undefined) uses(file, json.model, "entity model");
uses(file, json.texture, "texture");
}
for (const { file, json } of mod.effects) {
if ((effect_owners.get(json.id)?.length ?? 0) > 1) {
errors.push(`${file}: effect ${json.id} is also defined by ${effect_owners.get(json.id)!.join(", ")}`);
}
}
for (const { file, json } of mod.spawns) {
check_namespace(file, json.entity);
const entity = entity_jsons.get(json.entity);