⌘K

Events

Updated 30 Mar 2026

Subscribing to events

Use an on <EventName>: block at the top level of a script file. The event name is case- and separator-insensitive.

on PlayerJoin:
    send "&aWelcome!" to player

on BlockBreak:
    if $block_type == "diamond_ore":
        give_xp 50

Entity type filters

Append [EntityType] to any entity event to restrict the block to a specific entity.

on EntityDeath[Zombie]:
    broadcast "&aA zombie was slain!"

on EntitySpawn[Creeper]:
    cancel_event

Event variable reference

Kode injects local variables into the context for each event that carries extra data.

EventVariables injected
PlayerChat$message
PlayerInteract$action, $block_type
PlayerDropItem$item
PlayerGameModeChange$gamemode, $old_gamemode
PlayerFish$state
PlayerConsume$item
PlayerLevelChange$old_level, $new_level
PlayerSneak$sneaking (true when crouching)
PlayerSprint$sprinting (true when starting to sprint)
PlayerToggleFlight$flying (true when enabling flight)
PlayerRespawn$is_bed_spawn
PlayerMove$to_x, $to_y, $to_z
BlockBreak$block_type
BlockPlace$block_type
EntityDamage$damage, $cause
EntityDamageByEntity$damage, $cause, $attacker_type, $attacker_name, $attacker_is_player
FurnaceSmelt$input, $result
CraftItem$item
ItemPickup$item
ProjectileHit$projectile_type, $shooter, $shooter_is_player

Full event list

Player (17): PlayerJoin, PlayerQuit, PlayerDeath, PlayerRespawn, PlayerMove, PlayerChat, PlayerCommand, PlayerLevelChange, PlayerSneak, PlayerSprint, PlayerToggleFlight, PlayerInteract, PlayerDropItem, PlayerGameModeChange, PlayerBedEnter, PlayerFish, PlayerConsume

Block (2): BlockBreak, BlockPlace

Entity (5): EntityDamage, EntityDamageByEntity, EntityDeath, EntitySpawn, ProjectileHit

World (2): WeatherChange, Explode

Inventory (4): InventoryClick, ItemPickup, FurnaceSmelt, CraftItem

PlayerKick

Fired when a player is kicked from the server. Variables: $reason.

on PlayerKick:
    broadcast "$player was kicked: $reason"

PlayerTeleport

Fired when a player is teleported. Variables: $from_x, $from_y, $from_z, $to_x, $to_y, $to_z, $cause.

on PlayerTeleport:
    send "Teleported from $from_x,$from_y,$from_z to $to_x,$to_y,$to_z" to player

PlayerPortal

Fired when a player enters a portal. Variables: $portal_type.

on PlayerPortal:
    if $portal_type == "nether":
        send "&6Entering the Nether!" to player

PlayerSwapHands

Fired when a player swaps main/off-hand. Variables: $main_hand_item, $off_hand_item.

on PlayerSwapHands:
    send "Main: $main_hand_item, Off: $off_hand_item" to player

PlayerHeldItemChange

Fired when a player switches hotbar slot. Variables: $slot, $previous_slot.

on PlayerHeldItemChange:
    send "Switched to slot $slot" to player

SignChange

Fired when a player edits a sign. Variables: $line1$line4.

on SignChange:
    if $line1 == "[Shop]":
        send "&aShop sign created!" to player

PlayerAdvancement

Fired when a player earns an advancement. Variables: $advancement.

on PlayerAdvancement:
    send "&6Achievement unlocked: &e$advancement" to player

PlayerShootBow

Fired when a bow is released. Variables: $force (0.0–1.0), $is_critical.

on PlayerShootBow:
    if $is_critical == true:
        send "&cPerfect shot! Force: $force" to player

BlockBurn

Fired when a block burns. Variables: $block_type, $x, $y, $z.

on BlockBurn:
    log warn "Block $block_type burned at $x $y $z"

PlayerOpenInventory

Fired when a player opens an inventory. Variables: $inventory_type.

on PlayerOpenInventory:
    if $inventory_type == "chest":
        send "&7[You opened a chest]" to player

PlayerToggleGlide

Fired when a player starts or stops gliding with an elytra. Variable: $gliding (true = started, false = stopped).

on PlayerToggleGlide:
    if $gliding == true:
        send "&bGliding activated!" to player

EntityTame

Fired when a player tames an entity. Variable: $entity_type.

on EntityTame:
    send "&aYou tamed a $entity_type!" to player
    sound ENTITY_PLAYER_LEVELUP