New modding system

This commit is contained in:
2026-09-26 17:33:07 -03:00
parent 86d5c39eab
commit 243ff52063
25 changed files with 1089 additions and 512 deletions
+8 -19
View File
@@ -17,33 +17,22 @@ import type { ModelJson } from "./block_models.ts";
export interface ModData {
blocks: BlockJson[];
// block models, see common/block_models.ts
models?: ModelJson[];
models: ModelJson[];
items: ItemJson[];
recipes: RecipeJson[];
ores: OreJson[];
}
// a mod as the server lists it to clients, in load order. paths are relative to the server's root
// a mod as the server lists it to clients, in load order: the .bmod players download, without its server script
export interface ModListing {
id: string;
name: string;
version: string;
// short hash of everything public, the folder it's served from
hash: string;
data: string;
client?: string;
worldgen?: string;
// the manifest's credits file, markdown, shown on the credits screen
credits?: string;
// sha-256 in hex of each file, clients check these before using them
sha256: { data: string; client?: string; worldgen?: string; credits?: string };
}
// the texture atlas with every mod's textures, built by the server
export interface AtlasListing {
png: string;
json: string;
sha256: { png: string; json: string };
// sha-256 in hex of the .bmod, clients check it before using anything in it
sha256: string;
// where it's served from, relative to the server's root. named by its hash, so it never changes
file: string;
size: number;
}
export class RecipeBook {
@@ -70,7 +59,7 @@ export function register_mod_data(mods: { id: string; data: ModData }[]): Recipe
throw new ModLoadError(id, message);
};
try {
for (const model of data.models ?? []) {
for (const model of data.models) {
EverythingRegistry.register<ModelJson>("models", model.id, model);
}
for (const json of data.blocks) {