> For the complete documentation index, see [llms.txt](https://docs.nursultan.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nursultan.fun/events/event-list.md).

# Event list

Cancellable events are marked in the "Cancel" column. How to subscribe and what priority means is in Subscribing.

## Ticks

| Event                | When                                    | Cancel |
| -------------------- | --------------------------------------- | ------ |
| `ClientTickEvent`    | every client tick, even without a world |        |
| `PrePlayerTickEvent` | before the player ticks                 |        |
| `PlayerTickEvent`    | after the player ticks                  |        |

`ClientTickEvent` always fires, so it almost always needs an `if (!inGame) return@on`. `PrePlayerTickEvent` is where you get in before the player works out its movement for the tick.

## Combat

| Event                | When                                                                                    | Cancel |
| -------------------- | --------------------------------------------------------------------------------------- | ------ |
| `AttackEvent`        | you hit an entity, `target()`                                                           | yes    |
| `AttackedEvent`      | the hit went through, `target()`                                                        |        |
| `UseItemEvent`       | item use starts, `hand()`                                                               | yes    |
| `StopUsingItemEvent` | the client is about to release right click — cancel it to keep eating/drinking/charging | yes    |
| `JumpEvent`          | the player jumped                                                                       |        |
| `SlowdownEvent`      | the game slows movement down (food, shield, bow); `multiplier()` can be rewritten       |        |

## Input

| Event              | When                                                 | Cancel |
| ------------------ | ---------------------------------------------------- | ------ |
| `KeyEvent`         | a key or mouse button went down or up                | yes    |
| `CharEvent`        | a character was typed                                | yes    |
| `MouseScrollEvent` | the mouse wheel                                      | yes    |
| `MoveInputEvent`   | movement input for the tick, fields can be rewritten | yes    |
| `LookInputEvent`   | mouse movement, `deltaX`/`deltaY` can be rewritten   | yes    |

`KeyEvent` carries `key()`, `mods()`, `action()`, plus the short `pressed()`, `released()`, `mouse()` and `matches(Key.G)`.

`MoveInputEvent` is what the game is about to do: `forward()`, `backward()`, `left()`, `right()`, `jump()`, `sneak()`, `sprint()`. Every field both reads and writes:

```kotlin
on<MoveInputEvent>(priority = Priority.LAST) {
    it.sprint(true)
    it.jump(true)
}
```

## World and entities

| Event               | When                                                  | Cancel |
| ------------------- | ----------------------------------------------------- | ------ |
| `EntitySpawnEvent`  | an entity appeared, `entity()`                        |        |
| `EntityRemoveEvent` | an entity went away, `entity()`                       |        |
| `WorldLoadEvent`    | a world loaded — joining a server, changing dimension |        |
| `ScreenCloseEvent`  | a screen closed (inventory, chest, menu)              |        |

`WorldLoadEvent` is a good place to reset anything tied to one world.

## Packets

| Event                | When                                             | Cancel |
| -------------------- | ------------------------------------------------ | ------ |
| `PacketReceiveEvent` | a packet arrived from the server, `packet()`     | yes    |
| `PacketSendEvent`    | the client is about to send a packet, `packet()` | yes    |

These fire **on the network thread**. Details and the packet list are in Packets.

## Rendering

| Event           | When                      | Cancel |
| --------------- | ------------------------- | ------ |
| `Render2DEvent` | every frame, HUD layer    |        |
| `Render3DEvent` | every frame, in the world |        |

`Render2DEvent` carries `render()`, the screen size `width()` × `height()` and `tickDelta()`. `Render3DEvent` carries `render()`, `tickDelta()` and the camera position `camera()`. See 2D render and 3D render.

## Modules

| Event               | When                                     | Cancel |
| ------------------- | ---------------------------------------- | ------ |
| `ModuleToggleEvent` | a client module or a script was switched |        |

Carries `name()`, `enabled()` and `fromScript()` — the last one tells you whether it was a script or a built-in module.

## What tickDelta is

The game thinks 20 times per second but draws far more often. `tickDelta` is a fraction from 0 to 1 telling you how far the frame is past the last tick. You use it so movement on screen is smooth instead of stepping 20 times a second.
