Move effects into the modding api
This commit is contained in:
+6
-2
@@ -5,6 +5,7 @@ import type { ModelJson } from "./block_models.ts";
|
||||
import { MAX_TEXTURE_SIZE } from "./constants.ts";
|
||||
import {
|
||||
type BlockJson,
|
||||
type EffectJson,
|
||||
type EntityJson,
|
||||
type EntityModelJson,
|
||||
ID_PATTERN,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
type SpawnJson,
|
||||
type TagJson,
|
||||
validate_block,
|
||||
validate_effect,
|
||||
validate_entity,
|
||||
validate_entity_model,
|
||||
validate_item,
|
||||
@@ -57,7 +59,7 @@ 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 and tag
|
||||
// data.json every block, model, item, recipe, ore, entity, entity model, effect and tag
|
||||
// scripts/<side>.js
|
||||
// textures/<name>.png the texture <mod id>:<name>
|
||||
// credits.md
|
||||
@@ -149,10 +151,12 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
|
||||
validate_entity_model,
|
||||
problems,
|
||||
) as EntityModelJson[],
|
||||
effects: checked(raw_data.effects, "effects", validate_effect, problems) as EffectJson[],
|
||||
tags: checked(raw_data.tags, "tags", validate_tag, problems) as TagJson[],
|
||||
};
|
||||
// a mod only registers ids in its own namespace
|
||||
for (const { id } of [...data.blocks, ...data.models, ...data.items, ...data.entities, ...data.entity_models]) {
|
||||
const registered = [...data.blocks, ...data.models, ...data.items, ...data.entities, ...data.entity_models];
|
||||
for (const { id } of [...registered, ...data.effects]) {
|
||||
if (typeof id === "string" && id.split(":")[0] !== mod) problems.push(`${id} isn't in this mod's namespace`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user