Mod config
This commit is contained in:
+17
-5
@@ -12,6 +12,7 @@ import {
|
||||
type EntityJson,
|
||||
type EntityModelJson,
|
||||
ID_PATTERN,
|
||||
is_object,
|
||||
type ItemJson,
|
||||
type ManifestJson,
|
||||
type OreJson,
|
||||
@@ -80,7 +81,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, effect, tag, loot table and
|
||||
// biome
|
||||
// biome, and the mod's config
|
||||
// scripts/<side>.js
|
||||
// textures/<name>.png the texture <mod id>:<name>
|
||||
// textures/<name>.json its animation, if it has one
|
||||
@@ -200,7 +201,11 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
|
||||
problems,
|
||||
) as BiomeSourceJson[],
|
||||
features: checked(raw_data.features, "features", validate_feature, problems) as FeatureJson[],
|
||||
config: raw_data.config,
|
||||
};
|
||||
if (raw_data.config !== undefined && !is_object(raw_data.config)) {
|
||||
problems.push("data.json: config must be an object");
|
||||
}
|
||||
// a mod only registers ids in its own namespace
|
||||
const registered = [...data.blocks, ...data.models, ...data.items, ...data.entities, ...data.entity_models];
|
||||
const worldgen = [
|
||||
@@ -277,14 +282,21 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
|
||||
return { manifest, data, scripts, textures, texture_json, credits };
|
||||
}
|
||||
|
||||
// the same mod without its server and worldgen scripts and the terrain's data, what players get. the server sends
|
||||
// them the world
|
||||
// the same mod without its server and worldgen scripts, the terrain's data and its config, what players get. the
|
||||
// server sends them the world
|
||||
export function client_copy(bmod: Bmod): Bmod {
|
||||
const scripts = { ...bmod.scripts };
|
||||
delete scripts.server;
|
||||
delete scripts.worldgen;
|
||||
const { noises: _n, density_functions: _d, noise_settings: _s, biome_sources: _b, features: _f, ...data } =
|
||||
bmod.data;
|
||||
const {
|
||||
noises: _n,
|
||||
density_functions: _d,
|
||||
noise_settings: _s,
|
||||
biome_sources: _b,
|
||||
features: _f,
|
||||
config: _c,
|
||||
...data
|
||||
} = bmod.data;
|
||||
return { ...bmod, scripts, data };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user