Use StationAPI Events to Trigger Custom Mod Behavior
Understanding the Event System
StationAPI provides a built-in event system that fires at key moments during gameplay—block placement, item use, world load, player tick, and more. This lets you hook custom logic into the game without modifying core mechanics.
Identify which event matches your desired behavior. Common events include player interaction events, block update events, and world save/load events. Each event fires at a specific point in the game loop.
Registering and Handling Events
Create an event listener class and register it with StationAPI's event bus during mod initialization. Implement the callback method for your chosen event type, then write your custom logic inside.
Your handler receives event data (like which block was placed, or which player acted). You can read this data, perform calculations, modify game state, or cancel the event if needed.
Test your event handler by triggering the condition in-game—place a block, use an item, or load a world—and verify your custom behavior executes without errors or performance issues.