Skip to main content

Overview

Events are the primary way to react to game actions and client state changes in LiquidBounce. Scripts can listen to events to implement custom behavior.

Event Handlers

Register event handlers using module.on() within a module:
script.registerModule({
    name: "EventExample",
    category: "Misc"
}, function(module) {
    
    module.on("playerTick", function(event) {
        // Called every player tick
    });
    
});

Cancellable Events

Some events can be cancelled to prevent default behavior:
module.on("packet", function(event) {
    // Cancel a specific packet
    if (event.packet instanceof SomePacketClass) {
        event.cancelEvent();
    }
});
Cancelling critical events may cause game instability. Only cancel events when you understand the consequences.

Available Events

Here’s a comprehensive list of events you can listen to:

Player Events

Called every tick for the local player. Cancellable.
module.on("playerTick", function(event) {
    var player = mc.player;
    // Custom player logic
});
Source: PlayerTickEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:43)
Called after player tick processing.
module.on("playerPostTick", function(event) {
    // Post-tick logic
});
Source: PlayerPostTickEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:46)
Called when the player moves.
module.on("playerMove", function(event) {
    var movement = event.movement;
    // Access: movement.x, movement.y, movement.z
    // Modify movement vector
    event.movement = new Vec3d(newX, newY, newZ);
});
Source: PlayerMoveEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:64)
Called when the player jumps. Cancellable.
module.on("playerJump", function(event) {
    // Modify jump motion
    event.motion *= 1.5; // Higher jump
    
    // Or cancel the jump
    event.cancelEvent();
});
Source: PlayerJumpEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:67)
Called immediately after a jump is executed.
module.on("playerAfterJump", function(event) {
    Client.displayChatMessage("Jumped!");
});
Source: PlayerAfterJumpEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:70)
Control whether the player should avoid falling off edges.
module.on("playerSafeWalk", function(event) {
    event.isSafeWalk = true; // Enable safewalk
});
Source: PlayerSafeWalkEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:98)
Modify step height for climbing blocks.
module.on("playerStep", function(event) {
    event.height = 1.0; // Allow stepping up full blocks
});
Source: PlayerStepEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:101)
Called when player health, food, or saturation changes.
module.on("healthUpdate", function(event) {
    var health = event.health;
    var previousHealth = event.previousHealth;
    var food = event.food;
    var saturation = event.saturation;
    
    if (health < previousHealth) {
        Client.displayChatMessage("§cTook damage!");
    }
});
Source: HealthUpdateEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:37)
Called when the player dies.
module.on("death", function(event) {
    Client.displayChatMessage("§cYou died!");
});
Source: DeathEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt:40)

Game Events

Called every game tick (20 times per second).
module.on("gameTick", function(event) {
    // Game tick logic
});
Source: GameTickEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:41)
Called when a key is pressed.
module.on("key", function(event) {
    var key = event.key;
    var action = event.action; // 0 = release, 1 = press, 2 = repeat
    
    Client.displayChatMessage("Key pressed: " + key.getName());
});
Source: KeyEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:55)
Modify player movement input.
module.on("movementInput", function(event) {
    var input = event.directionalInput;
    event.jump = true; // Force jump
    event.sneak = false; // Disable sneak
});
Source: MovementInputEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:65)
Control sprint state.
module.on("sprint", function(event) {
    event.sprint = true; // Force sprinting
});
Source: SprintEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:72)
Modify mouse rotation. Cancellable.
module.on("mouseRotation", function(event) {
    event.cursorDeltaX *= 0.5; // Reduce sensitivity
    event.cursorDeltaY *= 0.5;
});
Source: MouseRotationEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:85)

Network Events

Called for incoming and outgoing packets. Cancellable.
module.on("packet", function(event) {
    var packet = event.packet;
    var origin = event.origin; // "INCOMING" or "OUTGOING"
    
    // Check packet type
    if (packet.getClass().getSimpleName() === "ServerboundChatPacket") {
        Client.displayChatMessage("Sending chat packet");
    }
    
    // Cancel packet
    // event.cancelEvent();
});
Source: PacketEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/NetworkEvents.kt:34)

Chat Events

Called when receiving a chat message. Cancellable.
module.on("chatReceive", function(event) {
    var message = event.message;
    var textData = event.textData;
    var type = event.type; // CHAT_MESSAGE, GAME_MESSAGE, etc.
    
    if (message.contains("secret")) {
        event.cancelEvent(); // Hide message
    }
});
Source: ChatReceiveEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:132)
Called when sending a chat message. Cancellable.
module.on("chatSend", function(event) {
    var message = event.message;
    
    // Prevent sending certain messages
    if (message.startsWith("!")) {
        event.cancelEvent();
        Client.displayChatMessage("§cCommand blocked!");
    }
});
Source: ChatSendEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:127)

Connection Events

Called when connecting to a server. Cancellable.
module.on("serverConnect", function(event) {
    var address = event.address.getHost();
    Client.displayChatMessage("§aConnecting to: " + address);
});
Source: ServerConnectEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:146)
Called when disconnecting from a server.
module.on("disconnect", function(event) {
    Client.displayChatMessage("§cDisconnected from server");
});
Source: DisconnectEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:154)
Called when session changes (login).
module.on("session", function(event) {
    var session = event.session;
    var username = session.getName();
    Client.displayChatMessage("§aLogged in as: " + username);
});
Source: SessionEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:117)

Screen Events

Called when screen/GUI changes. Cancellable.
module.on("screen", function(event) {
    var screen = event.screen;
    
    if (screen !== null) {
        var screenName = screen.getClass().getSimpleName();
        Client.displayChatMessage("§7Opened: " + screenName);
    }
});
Source: ScreenEvent (~/workspace/source/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt:122)

Event Properties

Each event object contains specific properties. Access them via the event parameter:
module.on("playerMove", function(event) {
    // Access event properties
    var type = event.type;
    var movement = event.movement;
    
    // Modify mutable properties
    event.movement = newMovement;
});

Cancelling Events

For cancellable events, use event.cancelEvent():
module.on("playerJump", function(event) {
    if (shouldPreventJump) {
        event.cancelEvent();
    }
});
Check if an event is cancelled:
if (event.isCancelled) {
    // Event was cancelled
}

Best Practices

Always verify that game objects exist:
module.on("playerTick", function(event) {
    var player = mc.player;
    if (!player) return;
    
    var world = mc.level;
    if (!world) return;
    
    // Safe to use player and world
});
Choose the most specific event for your needs:
  • Use playerTick for frequent player updates
  • Use gameTick for less frequent game logic
  • Use specific events like playerJump instead of checking in playerTick
Avoid heavy operations in frequently-called events:
var tickCount = 0;
module.on("playerTick", function() {
    tickCount++;
    
    // Only run every 20 ticks (1 second)
    if (tickCount % 20 === 0) {
        // Heavy operation here
    }
});
Wrap potentially failing code in try-catch:
module.on("packet", function(event) {
    try {
        // Risky packet handling
    } catch (e) {
        Client.displayChatMessage("§cError: " + e.message);
    }
});

Event Categories Summary

Player Events

  • playerTick, playerPostTick
  • playerMove, playerJump
  • playerSafeWalk, playerStep
  • healthUpdate, death

Game Events

  • gameTick, key
  • movementInput, sprint
  • mouseRotation

Network Events

  • packet
  • serverConnect, disconnect
  • session

Chat & UI Events

  • chatReceive, chatSend
  • screen

Next Steps

API Reference

Explore available utilities and functions

Creating Modules

Build modules that use events

Build docs developers (and LLMs) love