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
+7 -1
View File
@@ -4,6 +4,7 @@ import {
block_from_json,
BlockJson,
choice_ids,
EffectJson,
EntityJson,
EntityModelJson,
grid_recipe_from_json,
@@ -34,6 +35,8 @@ export interface ModData {
spawns: SpawnJson[];
entities: EntityJson[];
entity_models: EntityModelJson[];
// status effects, see EffectJson
effects: EffectJson[];
// tag files, see common/tags.ts
tags: TagJson[];
}
@@ -75,7 +78,7 @@ export function is_registered(registry: TagRegistry, id: string): boolean {
return (registry === "blocks" && id === "bworld:air") || EverythingRegistry.get(registry, id) !== undefined;
}
// registers every mod's blocks, items, entities, tags and recipes, in the order given (dependencies first). tags load
// registers every mod's blocks, items, entities, effects, tags and recipes, in the order given (dependencies first). tags load
// once every mod's content has, since a tag can hold anything, and recipes after them, since they can use tags
export function register_mod_data(mods: { id: string; data: ModData }[]): RecipeBook {
const recipes = new RecipeBook();
@@ -101,6 +104,9 @@ export function register_mod_data(mods: { id: string; data: ModData }[]): Recipe
for (const json of data.entities) {
EverythingRegistry.register<EntityJson>("entities", json.id, json);
}
for (const json of data.effects) {
EverythingRegistry.register<EffectJson>("effects", json.id, json);
}
} catch (e) {
throw new ModLoadError(id, (e as Error).message);
}