Single module modding
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user