Loading schematics
This commit is contained in:
+6
-2
@@ -50,6 +50,7 @@ import {
|
||||
import { type FeatureJson, validate_feature } from "./worldgen/features.ts";
|
||||
import { texture_animation, type TextureJson, validate_texture_json } from "./texture_animation.ts";
|
||||
import { ENGINE_GLOBAL } from "./hooks.ts";
|
||||
import { type Schematic, validate_schematic } from "./schematic.ts";
|
||||
|
||||
export const MOD_EXTENSION = ".cubi";
|
||||
|
||||
@@ -81,7 +82,7 @@ export class ModError extends Error {
|
||||
// the zip's layout:
|
||||
// manifest.json the mod's manifest, with "main" and "credits" pointing into the zip
|
||||
// data.json every block, model, item, recipe, ore, entity, entity model, effect, fluid, tag, loot
|
||||
// table and biome, and the mod's config
|
||||
// table, biome and schematic, and the mod's config
|
||||
// script.js
|
||||
// textures/<name>.png the texture <mod id>:<name>
|
||||
// textures/<name>.json its animation, if it has one
|
||||
@@ -214,6 +215,7 @@ export function read_mod(bytes: Uint8Array, file: string): Mod {
|
||||
) as BiomeSourceJson[],
|
||||
dimensions: checked(raw_data.dimensions, "dimensions", validate_dimension, problems) as DimensionJson[],
|
||||
features: checked(raw_data.features, "features", validate_feature, problems) as FeatureJson[],
|
||||
schematics: checked(raw_data.schematics, "schematics", validate_schematic, problems) as Schematic[],
|
||||
config: raw_data.config,
|
||||
};
|
||||
if (raw_data.config !== undefined && !is_object(raw_data.config)) {
|
||||
@@ -236,6 +238,7 @@ export function read_mod(bytes: Uint8Array, file: string): Mod {
|
||||
...data.biome_sources!,
|
||||
...data.dimensions!,
|
||||
...data.features!,
|
||||
...data.schematics!,
|
||||
];
|
||||
for (const { id } of [...registered, ...data.loot_tables!, ...data.biomes!, ...worldgen]) {
|
||||
if (typeof id === "string" && id.split(":")[0] !== mod) problems.push(`${id} isn't in this mod's namespace`);
|
||||
@@ -299,7 +302,7 @@ export function read_mod(bytes: Uint8Array, file: string): Mod {
|
||||
return { manifest, data, script, textures, texture_json, credits };
|
||||
}
|
||||
|
||||
// the same mod without the terrain's data and its config, what players get. the server sends them the world. its
|
||||
// the same mod without the terrain's data, its schematics and its config, what players get. the server sends them the world. its
|
||||
// script goes with it whole, and players only run its shared and client phases
|
||||
export function client_copy(mod: Mod): Mod {
|
||||
const {
|
||||
@@ -309,6 +312,7 @@ export function client_copy(mod: Mod): Mod {
|
||||
biome_sources: _b,
|
||||
dimensions: _dim,
|
||||
features: _f,
|
||||
schematics: _sc,
|
||||
config: _c,
|
||||
...data
|
||||
} = mod.data;
|
||||
|
||||
Reference in New Issue
Block a user