# event

the `event` parameter passed into any `@Katton.listen(...)` handler. its exact set of available properties depends on which event fired, see [event list & properties](../events/event-list.md) for the full breakdown

### properties (availability varies by event)

```csharp
event.player // a `player` value, where applicable
event.item // a `item` value, where applicable
event.block // the block's material name as a string, where applicable
event.entity // the entity's type name as a string, where applicable
event.projectile // the projectile's name as a string, where applicable

event.forward // when using player_input event
event.backward // when using player_input event
event.left // when using player_input event
event.right // when using player_input event
event.jump // when using player_input event
event.sneak // when using player_input event
event.sprint // when using player_input event
```

### methods

```csharp
event.cancel()
```

cancels the actual action (if the event supports cancellation). returns `true` if it actually cancelled something, `false` if the event isn't cancellable (safe to call either way). more details on [cancelling events](../events/cancelling-events.md)

```csharp
event.clearDrops()
```

this clears the drops from when a player/entity dies

### `event.item` is a full item, not just a name

unlike `event.block`/`event.entity`/`event.projectile` (which are just strings), `event.item` gives you a real [item](item.md) value with all its methods available:

```csharp
@Katton.listen("player_rightclick")
function onRightClick(event) {
    val item = event.item
    if (item == null) {
        return // player right clicked with an empty hand
    }

    val ability = item.getTag("ability")
    if (ability == "leap_wand") {
        event.player.launchForward(horizontal = 1.8, vertical = 0.65)
    } else if (ability == "heal_wand") {
        event.player.setHealth(20)
    }
}
```

### always check for `null` on optional properties

```csharp
@Katton.listen("player_interact")
function onInteract(event) {
    // event.item can be null (empty hand), event.block can be null (clicking air)
    if (event.item != null) {
        Katton.log.info("Holding: " + event.item.getTag("ability"))
    }
}
```
