Single module modding
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Events
|
||||
|
||||
Events let a server script react to what happens in the game, and stop some of it from happening. They're the
|
||||
Events let the server phase react to what happens in the game, and stop some of it from happening. They're the
|
||||
alternative to [components](../blocks/components.md) when the behavior isn't tied to one block or item: logging chat,
|
||||
protecting spawn, or reacting to every block broken anywhere.
|
||||
|
||||
@@ -15,7 +15,7 @@ Every event is a signal you subscribe to. Events come in two kinds:
|
||||
```ts
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
export function server(ctx: ServerContext) {
|
||||
// nobody breaks blocks within 16 blocks of the world's center
|
||||
ctx.events.before.block_break.subscribe((event) => {
|
||||
const { x, z } = event.block;
|
||||
@@ -52,7 +52,7 @@ showed. These events fire for **every** player's actions, since they all go thro
|
||||
| `player_death` | | ✓ | `player`, `cause`. They've dropped what they carried and respawn right after |
|
||||
| `player_join` | | ✓ | `player` |
|
||||
| `player_leave` | | ✓ | `player` |
|
||||
| `server_start` | | ✓ | none. Every mod's `setup` has run |
|
||||
| `server_start` | | ✓ | none. Every mod's server phase has run |
|
||||
| `tick` | | ✓ | `dt`, in seconds. 20 times a second |
|
||||
| `new_day` | | ✓ | `day`. At 06:00, after every block's `on_new_day` |
|
||||
|
||||
@@ -66,7 +66,7 @@ only when the entity was hurt, with the amount the before handlers left.
|
||||
|
||||
### Order
|
||||
|
||||
Handlers run in the order they subscribed, and mods' `setup` functions run in [load order](registries.md#loading). For
|
||||
Handlers run in the order they subscribed, and mods' server phases run in [load order](registries.md#loading). For
|
||||
`block_interact`, the before event runs first, then the block's own components' `on_interact`, rules before handlers,
|
||||
unless the player is [sneaking](../entities/players.md#sneaking) with an item in hand. If no component handled the click
|
||||
and the held item has no `on_use`, the held block is placed, which fires `block_place`. Cancelling it undoes what the
|
||||
|
||||
Reference in New Issue
Block a user