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
+4 -4
View File
@@ -4,7 +4,7 @@ Status effects change a player or a mob for a while, like speed or poison. They
effect is defined once, and adding it to someone gives them an instance of it with a duration and a level.
Like blocks and items, an effect is data with components. Its JSON in the mod's `effects/` folder says what it is and
which attributes it changes. Components, registered by the server script, say what it does over time. An effect can also
which attributes it changes. Components, registered by the server phase, say what it does over time. An effect can also
change things where they happen, through an [event](../concepts/events.md). Even the base game's effects are defined
this way, in `mods/bworld/effects`.
@@ -46,12 +46,12 @@ An effect that does something each tick lists components, with their parameters:
}
```
The server script registers them during `setup`, in the mod's own namespace:
The server phase registers them while it runs, in the mod's own namespace:
```ts
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
export function server(ctx: ServerContext) {
ctx.components.register_effect<{ every: number }>("copper_tools:rusting", {
should_tick: (ticks, amplifier, params) => ticks % params.every === 0,
on_tick(entity, amplifier) {
@@ -102,7 +102,7 @@ Like block components, an effect that lists a component nobody registered stops
Some effects change something as it happens, like damage coming in, rather than over time. Those need no component: a
handler checks whether the entity has the effect. `bworld:resistance` is one, subscribing to `entity_damage` in its
server script:
server phase:
```ts
ctx.events.before.entity_damage.subscribe((event) => {