Single module modding
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// what client scripts get, see docs/modding/gui/index.md
|
||||
// what client phases get, see docs/modding/gui/index.md
|
||||
import type {
|
||||
FluidApi,
|
||||
FluidVariant,
|
||||
@@ -66,7 +66,7 @@ export interface ClientContext {
|
||||
// read only, what this client sees
|
||||
world: {
|
||||
get_block(x: number, y: number, z: number): Id | undefined;
|
||||
// a field of the block's client data, what server scripts set with BlockRef.set_client_data, a copy.
|
||||
// a field of the block's client data, what server phases set with BlockRef.set_client_data, a copy.
|
||||
// undefined when it isn't set or the chunk isn't loaded
|
||||
get_client_data<T>(x: number, y: number, z: number, field: string): T | undefined;
|
||||
// the biome at a block and its season, like the server's. undefined when the chunk isn't loaded
|
||||
@@ -115,7 +115,7 @@ export interface ClientContext {
|
||||
table(id: Id): LootTableJson | undefined;
|
||||
};
|
||||
// every recipe as its json (see docs/modding/resources/recipes.md), including mods' own types, in load order. copies.
|
||||
// find and all read the recipes of types shared scripts registered
|
||||
// find and all read the recipes of types shared phases registered
|
||||
recipes: {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
list(type?: Id): any[];
|
||||
@@ -376,7 +376,7 @@ export interface HudRegistry {
|
||||
// a layer, drawn every frame in the order they're registered, mods in load order, like RegisterGuiLayersEvent's
|
||||
// registerAboveAll. only during setup. one that throws is removed, with the error in the console
|
||||
register(id: Id, layer: HudLayer): void;
|
||||
// a server script sent an overlay message (MessageOptions.overlay), for a layer to show
|
||||
// a mod's server phase sent an overlay message (MessageOptions.overlay), for a layer to show
|
||||
on_overlay_message(fn: (text: string) => void): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// content scripts: blocks made in code, for content that's easier to generate than to write out file by file, like
|
||||
// content phases: blocks made in code, for content that's easier to generate than to write out file by file, like
|
||||
// every block of every kind of rock. the server runs them while it loads mods, before anything else reads their data,
|
||||
// and what they register becomes part of the mod's data just like its files: checked the same way, sent to players
|
||||
// with the rest, and generated by worldgen workers. see docs/modding/gettingstarted/modfiles.md
|
||||
|
||||
@@ -13,8 +13,8 @@ import type { client_engine } from "../../client/engine_modules.ts";
|
||||
|
||||
export type { HookHandlers } from "../hooks.ts";
|
||||
|
||||
// the engine's live classes and objects. common is on every side, server only in server scripts, client only in
|
||||
// client scripts
|
||||
// the engine's live classes and objects. common is on every side, server only in server phases, client only in
|
||||
// client phases
|
||||
export interface Engine {
|
||||
common: ReturnType<typeof common_engine>;
|
||||
server: ReturnType<typeof server_engine>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// what server scripts get, see docs/modding/
|
||||
// what server phases get, see docs/modding/
|
||||
import type {
|
||||
EventSignal,
|
||||
Face,
|
||||
@@ -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 cubi/shared
|
||||
// placing and neighbor rules are in shared phases, see BlockRules in cubi/shared
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
@@ -638,7 +638,7 @@ export interface TankHandlerOptions {
|
||||
set(tanks: FluidStack[]): void;
|
||||
}
|
||||
|
||||
// ctx.fluids in server scripts: FluidApi, and fluid handlers
|
||||
// ctx.fluids in server phases: FluidApi, and fluid handlers
|
||||
export interface ServerFluidApi extends FluidApi {
|
||||
// the handler of the block at x y z reached from face, from the first of its components with one, like
|
||||
// level.getCapability(Capabilities.FluidHandler.BLOCK, pos, side). undefined for a block without one there
|
||||
@@ -660,7 +660,7 @@ export interface ServerFluidApi extends FluidApi {
|
||||
interact(player: Player, handler: FluidHandler): boolean;
|
||||
}
|
||||
|
||||
// find and all read the recipes of types shared scripts registered
|
||||
// find and all read the recipes of types shared phases registered
|
||||
export interface RecipeApi extends RecipeLookup {
|
||||
// every recipe of a mod's own type, like "bworld:cooking", as its json. copies, in load order
|
||||
// deno-lint-ignore no-explicit-any
|
||||
@@ -817,7 +817,7 @@ export interface MenuRegistry {
|
||||
// adds slots to every player's own inventory menu, always there while they play, like the curios slots next to the
|
||||
// inventory. build runs when each player joins. only during setup
|
||||
extend_player_menu(build: (menu: PlayerMenuBuilder, player: Player) => void): void;
|
||||
// like registering a MenuType. the client script gives it a screen with ctx.ui.register_menu_screen
|
||||
// like registering a MenuType. the client phase gives it a screen with ctx.ui.register_menu_screen
|
||||
register<Args = undefined>(
|
||||
id: Id,
|
||||
build: (menu: MenuBuilder, args: Args, player: Player) => void,
|
||||
|
||||
+10
-10
@@ -12,7 +12,7 @@ export type Season = "spring" | "summer" | "autumn" | "winter";
|
||||
export interface ItemStack {
|
||||
readonly id: Id;
|
||||
count: number;
|
||||
// any json value, set by server scripts
|
||||
// any json value, set by server phases
|
||||
data?: unknown;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface FluidStack {
|
||||
amount: number;
|
||||
}
|
||||
|
||||
// ctx.fluids in server and client scripts: every fluid any mod defines, the same on the server and every client
|
||||
// ctx.fluids in server and client phases: every fluid any mod defines, the same on the server and every client
|
||||
export interface FluidApi {
|
||||
// every fluid's id, in load order, like ctx.items.ids. each without data, which a fluid like juice has many of
|
||||
ids(): Id[];
|
||||
@@ -44,7 +44,7 @@ export interface FluidApi {
|
||||
same(a: FluidVariant, b: FluidVariant): boolean;
|
||||
}
|
||||
|
||||
// what a fluid's data makes it, registered by a shared script, like neoforge's FluidType.getDescription and
|
||||
// what a fluid's data makes it, registered by a mod's shared phase, like neoforge's FluidType.getDescription and
|
||||
// FluidTintSource.colorAsStack without the amount. data is the variant's, undefined for none, and isn't to be changed.
|
||||
// returning undefined keeps what the fluid's json says
|
||||
export interface FluidRules {
|
||||
@@ -127,7 +127,7 @@ export interface EventSignal<T> {
|
||||
subscribe(handler: (event: T) => void): Unsubscribe;
|
||||
}
|
||||
|
||||
// shared scripts: block rules that run on the server and on every client, so a client places blocks the way the
|
||||
// shared phases: block rules that run on the server and on every client, so a client places blocks the way the
|
||||
// server will, like minecraft's Block code that both sides run. see docs/modding/gettingstarted/modfiles.md
|
||||
|
||||
export interface SharedContext {
|
||||
@@ -169,21 +169,21 @@ export interface SharedContext {
|
||||
readonly recipes: {
|
||||
// adds a recipe of type, like "shaped" or "bworld:cooking", as a file in the mod's recipes/ with that
|
||||
// json would, only during setup. for recipes made from other data, like one for every item with a component.
|
||||
// shared scripts run on the server and every client alike, so they all have it without it being sent. it's
|
||||
// there for server and client scripts, which set up after, and it throws when it's broken like a file would
|
||||
// shared phases run on the server and every client alike, so they all have it without it being sent. it's
|
||||
// there for server and client phases, which set up after, and it throws when it's broken like a file would
|
||||
// stop the mod loading
|
||||
register(type: string, json: Record<string, unknown>): void;
|
||||
// every recipe, or every one of type, as its json, copies, in load order: the mods' recipes/ files, and what the
|
||||
// shared scripts that set up before this one registered, which are the dependencies'. like the client's
|
||||
// shared phases that set up before this one registered, which are the dependencies'. like the client's
|
||||
// deno-lint-ignore no-explicit-any
|
||||
list(type?: string): any[];
|
||||
// a recipe type of the mod's own, in its namespace, only during setup: its recipes, from files and register,
|
||||
// are parsed by it then, and find and all read them from there on every side. a recipe of a type no mod
|
||||
// registers stops its mod loading once every shared script has set up. see RecipeType
|
||||
// registers stops its mod loading once every shared phase has set up. see RecipeType
|
||||
register_type<R, I>(type: Id, rules: RecipeType<R, I>): void;
|
||||
} & RecipeLookup;
|
||||
readonly components: {
|
||||
// the rules of a block component, the same id the server script registers the rest of it under
|
||||
// the rules of a block component, the same id the server phase registers the rest of it under
|
||||
// deno-lint-ignore no-explicit-any
|
||||
register_block<P = any>(id: Id, rules: BlockRules<P>): void;
|
||||
};
|
||||
@@ -246,6 +246,6 @@ export interface BlockRules<P = any> {
|
||||
on_neighbor_change?(block: SharedBlock, params: P, neighbor: SharedBlock): void;
|
||||
// a player right clicks it, like minecraft's useWithoutItem: changes only its states and its neighbors', which
|
||||
// the clicking client shows right away instead of waiting for the server. return true if it did something, then
|
||||
// nothing is placed. the server runs the server script's on_interact too
|
||||
// nothing is placed. the server runs the server phase's on_interact too
|
||||
on_interact?(block: SharedBlock, params: P, interaction: BlockInteraction): boolean | void;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// what worldgen scripts get, see docs/modding/worldgen/index.md. runs on the server and must be deterministic
|
||||
// what worldgen phases get, see docs/modding/worldgen/index.md. runs on the server and must be deterministic
|
||||
import type { Id, Position } from "./shared.ts";
|
||||
|
||||
export type { Id, Position } from "./shared.ts";
|
||||
|
||||
Reference in New Issue
Block a user