Change imports
This commit is contained in:
+2
-2
@@ -238,9 +238,9 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
|
||||
scripts[side as ScriptSide] = code;
|
||||
}
|
||||
}
|
||||
// what the bworld/engine shim reads, so it's in the bundle of every script that imports it
|
||||
// what the cubi/engine shim reads, so it's in the bundle of every script that imports it
|
||||
if (!manifest.engine_access && Object.values(scripts).some((code) => code.includes(ENGINE_GLOBAL))) {
|
||||
problems.push(`a script uses bworld/engine, which needs "engine_access": true in manifest.json`);
|
||||
problems.push(`a script uses cubi/engine, which needs "engine_access": true in manifest.json`);
|
||||
}
|
||||
const credits = manifest.credits === undefined ? undefined : text(manifest.credits);
|
||||
if (manifest.credits !== undefined && credits === undefined) {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
// generating a chunk: the terrain from the generator's data (common/worldgen), then ores, then mods' features.
|
||||
// only the server generates, players get finished chunks
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
import type { FeatureChunk, Position } from "$/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "$/common/mod_data.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
|
||||
import type { FeatureChunk, Position } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import { generate_overworld } from "./worldgen/overworld.ts";
|
||||
import type { Generator } from "./worldgen/generator.ts";
|
||||
import { named_noise_2d, named_noise_3d } from "./worldgen/noise.ts";
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// engine access: hooks on the engine's own methods, like neoforge's mixins, and the global the bworld/engine shim reads.
|
||||
// engine access: hooks on the engine's own methods, like neoforge's mixins, and the global the cubi/engine shim reads.
|
||||
// see docs/modding/misc/engine.md and docs/modding_plan.md
|
||||
import { GAME_VERSION } from "./constants.ts";
|
||||
|
||||
@@ -199,7 +199,7 @@ export function clear_hooks() {
|
||||
hooked.clear();
|
||||
}
|
||||
|
||||
// runs fn as the mod: hook knows whose hooks it makes, and bworld/engine refuses mods without engine_access
|
||||
// runs fn as the mod: hook knows whose hooks it makes, and cubi/engine refuses mods without engine_access
|
||||
export async function loading_mod<T>(mod: string, engine_access: boolean, fn: () => Promise<T>): Promise<T> {
|
||||
const previous = loading;
|
||||
loading = { mod, engine_access };
|
||||
@@ -217,7 +217,7 @@ export interface EngineModules {
|
||||
client?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// what bworld/engine reads, see common/mod_api/engine.ts
|
||||
// what cubi/engine reads, see common/mod_api/engine.ts
|
||||
export interface EngineGlobal {
|
||||
version: string;
|
||||
engine: EngineModules;
|
||||
@@ -226,9 +226,9 @@ export interface EngineGlobal {
|
||||
check_access(): void;
|
||||
}
|
||||
|
||||
export const ENGINE_GLOBAL = "__bworld_engine";
|
||||
export const ENGINE_GLOBAL = "__cubi_engine";
|
||||
|
||||
// puts a side's modules where bworld/engine finds them. a realm with the server and a client in it, like tests, gets
|
||||
// puts a side's modules where cubi/engine finds them. a realm with the server and a client in it, like tests, gets
|
||||
// both
|
||||
export function expose_engine(modules: EngineModules) {
|
||||
const global = globalThis as unknown as Record<string, EngineGlobal | undefined>;
|
||||
@@ -242,9 +242,9 @@ export function expose_engine(modules: EngineModules) {
|
||||
engine: { ...modules },
|
||||
hook,
|
||||
check_access() {
|
||||
if (!loading) throw new Error("bworld/engine can only be imported by a mod's script");
|
||||
if (!loading) throw new Error("cubi/engine can only be imported by a mod's script");
|
||||
if (!loading.engine_access) {
|
||||
throw new Error(`${loading.mod} imports bworld/engine without "engine_access" in its manifest`);
|
||||
throw new Error(`${loading.mod} imports cubi/engine without "engine_access" in its manifest`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import type { FluidRules } from "./fluids.ts";
|
||||
import type { FluidVariant } from "./mod_api/shared.ts";
|
||||
import { is_object } from "./schema.ts";
|
||||
|
||||
@@ -125,7 +125,7 @@ export interface VisualBlock {
|
||||
readonly z: number;
|
||||
// they stay the same for the visual's life, it's made again when they change
|
||||
readonly states: Readonly<Record<string, number>>;
|
||||
// a field of its client data now, a copy, see BlockRef.set_client_data in bworld/server
|
||||
// a field of its client data now, a copy, see BlockRef.set_client_data in cubi/server
|
||||
get_client_data<T>(field: string): T | undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// bworld/engine: engine access, for what the game api doesn't cover yet. a mod needs "engine_access": true and a
|
||||
// cubi/engine: engine access, for what the game api doesn't cover yet. a mod needs "engine_access": true and a
|
||||
// game_version within one minor version in its manifest. see docs/modding/misc/engine.md
|
||||
//
|
||||
// this is bundled into each mod that imports it, so it only imports types: the engine and hook are the game's own,
|
||||
@@ -21,8 +21,8 @@ export interface Engine {
|
||||
client: ReturnType<typeof client_engine>;
|
||||
}
|
||||
|
||||
const api = (globalThis as unknown as Record<string, EngineGlobal | undefined>)["__bworld_engine"];
|
||||
if (!api) throw new Error("bworld/engine only works in a mod's script, loaded by the game");
|
||||
const api = (globalThis as unknown as Record<string, EngineGlobal | undefined>)["__cubi_engine"];
|
||||
if (!api) throw new Error("cubi/engine only works in a mod's script, loaded by the game");
|
||||
api.check_access();
|
||||
|
||||
export const engine = api.engine as Engine;
|
||||
|
||||
@@ -118,7 +118,7 @@ export interface BlockComponent<P = any> {
|
||||
// particular when it's undefined, like neoforge's Capabilities.FluidHandler.BLOCK. undefined when it has none
|
||||
// there. see ServerFluidApi.block_handler
|
||||
fluid_handler?(block: BlockRef, params: P, face: Face | undefined): FluidHandler | undefined;
|
||||
// placing and neighbor rules are in shared scripts, see BlockRules in bworld/shared
|
||||
// placing and neighbor rules are in shared scripts, see BlockRules in cubi/shared
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ const manifest_schema = (folder_name: string) =>
|
||||
version: z.string("must be semver, like 1.0.0").regex(/^\d+\.\d+\.\d+/),
|
||||
authors: z.array(z.string()).optional(),
|
||||
game_version: z.string().optional(),
|
||||
// imports bworld/engine to reach into the engine and hook its methods. needs game_version within one minor version
|
||||
// imports cubi/engine to reach into the engine and hook its methods. needs game_version within one minor version
|
||||
engine_access: z.boolean().optional(),
|
||||
dependencies: z.array(z.object({ id: z.string(), version: z.string() })).optional(),
|
||||
scripts: z.strictObject({
|
||||
|
||||
@@ -83,7 +83,7 @@ export interface ModListing {
|
||||
// where it's served from, relative to the server's root. named by its hash, so it never changes
|
||||
file: string;
|
||||
size: number;
|
||||
// it imports bworld/engine, see docs/modding/misc/engine.md. the confirm screen for other sites says so
|
||||
// it imports cubi/engine, see docs/modding/misc/engine.md. the confirm screen for other sites says so
|
||||
engine_access?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// noise cells), caves cut out of it, then each column's biome, its surface blocks and fluids. what all of it is comes
|
||||
// from the generator's noise settings, see OverworldTerrain and docs/modding/worldgen/terrain.md. trees and the rest
|
||||
// are features, after it
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { get_biome } from "./biomes.ts";
|
||||
import type { OverworldTerrain, TerrainColumn } from "./terrain.ts";
|
||||
import {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// imports mods' worldgen scripts and collects what they and mods' data add to generation: the generator, ores, and
|
||||
// features, code and data, in the order they run. used by the game server
|
||||
import type { FeatureBiome, FeatureChunk, FeatureStep, WorldgenContext } from "$/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "$/common/mod_data.ts";
|
||||
import type { FeatureBiome, FeatureChunk, FeatureStep, WorldgenContext } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import type { SetupFeature, WorldgenSetup } from "./generation.ts";
|
||||
import { EverythingRegistry } from "./everything_registry.ts";
|
||||
import { ModLoadError } from "./mod_loader.ts";
|
||||
|
||||
Reference in New Issue
Block a user