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) => {
+4 -4
View File
@@ -1,7 +1,7 @@
# Players
Server scripts see players as `Player` objects: in events, in component handlers, from `ctx.players`, and as the source
of a command.
The server phase sees players as `Player` objects: in events, in component handlers, from `ctx.players`, and as the
source of a command.
## Finding Players
@@ -181,7 +181,7 @@ their eyes at 0.6, so they fit through 1-block gaps. Under a low ceiling they st
stand up.
`player.is_swimming()` says whether a player is swimming, like NeoForge's `isSwimming()`. It works on the server and in
client scripts, where `ctx.player.is_swimming()` is about the player on this client:
the client phase, where `ctx.player.is_swimming()` is about the player on this client:
```ts
if (player.is_swimming()) player.add_effect("bworld:speed", 20);
@@ -190,7 +190,7 @@ if (player.is_swimming()) player.add_effect("bworld:speed", 20);
## Sneaking
`player.is_sneaking()` says whether a player holds the sneak key, like NeoForge's `isShiftKeyDown()`. It's the key, not
the pose: a player flying down holds it too. Their client tells the server as soon as it changes. In client scripts,
the pose: a player flying down holds it too. Their client tells the server as soon as it changes. In the client phase,
`ctx.player.is_sneaking()` is about the player on this client.
Sneaking changes what right clicking a block does, like Minecraft: with an item in hand, the block isn't used at all,