Single module modding

This commit is contained in:
2026-11-14 12:18:41 -03:00
parent 605008f584
commit 313098892e
134 changed files with 919 additions and 924 deletions
+1 -7
View File
@@ -9,11 +9,5 @@
],
"game_version": ">=0.1.0",
"credits": "CREDITS.md",
"scripts": {
"server": "scripts/server.ts",
"client": "scripts/client.ts",
"shared": "scripts/shared.ts",
"worldgen": "scripts/worldgen.ts",
"content": "scripts/content.ts"
}
"main": "scripts/main.ts"
}
+1 -1
View File
@@ -29,7 +29,7 @@ const HEIGHT = 166;
// what an item sells for, after its food line in its tooltip
const VALUE_COLOR: Color = [0.95, 0.8, 0.3, 1];
export function setup(ctx: ClientContext) {
export function client(ctx: ClientContext) {
ctx.ui.register_menu_screen("bworld:storage", chest_screen);
ctx.ui.register_menu_screen("bworld:furnace", furnace_screen);
ctx.ui.register_menu_screen("bworld:crabpot", (menu) => container_screen(menu, HEIGHT));
+1 -1
View File
@@ -41,7 +41,7 @@ const FORMS: { form: string; id: (rock: string) => string }[] = [
const STONE_MINING = { toughness: 3, tool: "pickaxe", requires_tool: true } as const;
export function setup(ctx: ContentContext) {
export function content(ctx: ContentContext) {
const texture = (form: string, rock: string) => `bworld:rock_${form}_${rock}`;
for (const rock of ROCKS) {
for (const { form, id } of FORMS) {
+1 -1
View File
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// the kitchen's recipe types, registered by the shared script: what the cooking pot cooks, found by the items in its
// the kitchen's recipe types, registered by the shared phase: what the cooking pot cooks, found by the items in its
// ingredient slots, and what the cutting board cuts, found by the item on it. see cooking.ts
import type { SharedContext } from "cubi/shared";
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// fermentable recipes: a fluid that ferments into another over a number of ticks, like juice into wine in the keg. the
// shared script registers one for every juice, and mods can add more like any recipe, as files or from their shared
// shared phase registers one for every juice, and mods can add more like any recipe, as files or from their shared
// scripts. they're found by the fluid that ferments
import type { FluidStack, FluidVariant, SharedContext } from "cubi/shared";
import type { JuiceableParams } from "./shared.ts";
+3 -3
View File
@@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// juicing recipes: what the juicer presses an item into. the shared script registers one for every item with
// bworld:juiceable, its own juice, and mods can add more like any recipe, as files or from their shared scripts.
// juicing recipes: what the juicer presses an item into. the shared phase registers one for every item with
// bworld:juiceable, its own juice, and mods can add more like any recipe, as files or from their shared phases.
// whatever makes juice finds them by the item, like the juicer. with create installed, each is also a create:compacting
// recipe, so its press can make juice in a basin
import type { FluidStack, SharedContext } from "cubi/shared";
@@ -44,7 +44,7 @@ export function register_juicing(ctx: SharedContext) {
// a create:compacting recipe for every juicing recipe there is so far, so create's press squashes the item into its
// juice in a basin under it. create's recipes take a list of item choices and give a list of results, a fluid's as
// { fluid, amount }. juicing recipes other mods' shared scripts register later aren't seen here
// { fluid, amount }. juicing recipes other mods' shared phases register later aren't seen here
function register_compacting(ctx: SharedContext) {
for (const juicing of ctx.recipes.list(JUICING)) {
ctx.recipes.register("create:compacting", {
+9
View File
@@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// the base game's script. each phase is in its own file, see docs/modding/concepts/sides.md
export { content } from "./content.ts";
export { shared } from "./shared.ts";
export { server } from "./server.ts";
export { client } from "./client.ts";
export { worldgen } from "./worldgen.ts";
+1 -1
View File
@@ -15,7 +15,7 @@ import { JUICING, type JuicingRecipe } from "./juicing.ts";
import { FERMENTABLE, type FermentableRecipe } from "./fermenting.ts";
import { register_cooking_pot, register_cutting_board, register_stove } from "./cooking.ts";
export function setup(ctx: ServerContext) {
export function server(ctx: ServerContext) {
register_hoeable(ctx);
register_strippable(ctx);
const storage_menu = register_storage(ctx);
+1 -1
View File
@@ -14,7 +14,7 @@ import { register_smithing } from "./smithing.ts";
import { register_stonecutting } from "./stonecutting.ts";
import { register_verdigris_rules } from "./verdigris/shared.ts";
export function setup(ctx: SharedContext) {
export function shared(ctx: SharedContext) {
register_fence(ctx);
register_trapdoor(ctx);
register_door(ctx);
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// smelting and fuel recipes: the furnace cooks one item into another, burning fuel to do it. both are found by an item
// id, and registered by the shared script like smithing.ts
// id, and registered by the shared phase like smithing.ts
import type { SharedContext } from "cubi/shared";
export const SMELTING = "bworld:smelting";
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// smithing recipes: the smithing table upgrades a tool with some of a material and maybe some of one more item. the
// type is registered by the shared script, so the server's menu and anything on a client find them the same way
// type is registered by the shared phase, so the server's menu and anything on a client find them the same way
import type { ItemStack, RecipeReader, SharedContext } from "cubi/shared";
export const SMITHING = "bworld:smithing";
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// stonecutting recipes: the stonecutter cuts one item into another, picked from every recipe that takes it. the type is
// registered by the shared script, so the server's menu and the client's screen both list them from ctx.recipes.all, in
// registered by the shared phase, so the server's menu and the client's screen both list them from ctx.recipes.all, in
// the same order, so a button's number means the same recipe to both
import type { SharedContext } from "cubi/shared";
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// the power blocks give each other, see docs/modding/blocks/verdigris.md. every signal is a block state, so this only
// reads states, through a small world instead of ctx so it runs the same in shared scripts, server scripts and tests
// reads states, through a small world instead of ctx so it runs the same in shared phases, server phases and tests
import type { Face, Id } from "cubi/shared";
import { FACES, type FacingParam, front_of, named_sides, OPPOSITE, type SideName, step } from "./sides.ts";
+1 -1
View File
@@ -6,7 +6,7 @@
import type { FeatureChunk, WorldgenContext } from "cubi/worldgen";
import { register_trees } from "./trees.ts";
export function setup(gen: WorldgenContext) {
export function worldgen(gen: WorldgenContext) {
// trees grow in vegetal_decoration, before the cactus looks for air in the last step
register_trees(gen);
gen.register_feature("bworld:cactus", cactus);
+1 -5
View File
@@ -16,9 +16,5 @@
}
],
"credits": "CREDITS.md",
"scripts": {
"server": "scripts/server.ts",
"client": "scripts/client.ts",
"shared": "scripts/shared.ts"
}
"main": "scripts/main.ts"
}
+1 -1
View File
@@ -49,7 +49,7 @@ const half_shaft = (facing: Face) => HALF_SHAFT_TURNS[OPPOSITE[facing]];
// how a model made along y is turned to an axis, the way the kinetic blocks' variants turn theirs
const AXIS_TURNS: Record<Axis, { x?: number; y?: number }> = { x: { x: 90, y: 90 }, y: {}, z: { x: 90, y: 180 } };
export function setup(ctx: ClientContext) {
export function client(ctx: ClientContext) {
const shape_of = (block: VisualBlock): KineticShape => {
const params = ctx.blocks.components(block.id)["create:kinetic"] as KineticParams;
return kinetic_shape(params, (name) => block.states[name]);
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// create's script. each phase is in its own file, see docs/modding/concepts/sides.md
export { shared } from "./shared.ts";
export { server } from "./server.ts";
export { client } from "./client.ts";
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// create's processing recipes, the shape its machines' recipe types share, like ProcessingRecipe: item choices in, and
// stacks out, each with a chance, and for the types that can, fluids out as { fluid, amount }. the shared script
// stacks out, each with a chance, and for the types that can, fluids out as { fluid, amount }. the shared phase
// registers each type, so a broken recipe stops the mod loading instead of a machine later. no ctx, tests give what it
// needs
import type { FluidStack, Id, RecipeType } from "cubi/shared";
+1 -1
View File
@@ -79,7 +79,7 @@ interface PressData extends KineticData {
scan?: number;
}
export function setup(ctx: ServerContext) {
export function server(ctx: ServerContext) {
const config: Config = ctx.config;
const world = kinetic_world(ctx, config);
+1 -1
View File
@@ -20,7 +20,7 @@ import {
OPPOSITE,
} from "./kinetics/connections.ts";
export function setup(ctx: SharedContext) {
export function shared(ctx: SharedContext) {
const lookup = { expand: ctx.tags.expand, item_exists: ctx.items.exists, fluid_exists: ctx.fluids.exists };
ctx.recipes.register_type(PRESSING.id, processing_type(PRESSING, lookup));
ctx.recipes.register_type(COMPACTING.id, processing_type(COMPACTING, lookup));
+1 -3
View File
@@ -8,7 +8,5 @@
"paula"
],
"game_version": ">=0.1.0",
"scripts": {
"client": "scripts/client.ts"
}
"main": "scripts/client.ts"
}
+1 -1
View File
@@ -8,7 +8,7 @@ import type { ClientContext } from "cubi/client";
import { type Entry, ItemList, type Mode } from "./item_list.ts";
import { RecipeIndex, RecipesScreen } from "./recipes_screen.ts";
export function setup(ctx: ClientContext) {
export function client(ctx: ClientContext) {
const index = new RecipeIndex(ctx);
const list = new ItemList(ctx);
// like jei's IRecipesGui.show, only when there's something to show