Skip to main content
Learn how to use BetterModel’s event system for hitbox interactions, custom triggers, and reactive model behavior.

Overview

BetterModel provides powerful event systems for:
  • Hitbox interactions (click, attack, damage)
  • Model lifecycle events (spawn, despawn, close)
  • Animation events
  • Per-player events

Hitbox Events

Basic Hitbox Interaction

Mount and Dismount Events

Handling Entity Mounting

Tracker Lifecycle Events

Model Creation and Destruction

Player Visibility Events

Per-Player Animation Events

Custom Event System

Creating Custom Model Events

Hitbox Builder Pattern

Advanced Hitbox Configuration

Best Practices

  • Use HitBoxListener.builder() for complex hitbox configurations
  • Register event listeners in your plugin’s onEnable()
  • Handle null checks for player() calls in events
  • Use event cancellation to prevent default behavior
  • Store event data for analytics and debugging
  • Avoid heavy computations in event handlers
  • Don’t create infinite event loops
  • Always unregister listeners when cleaning up
  • Test event handlers with multiple concurrent players

Next Steps

Animated NPC

Use events for NPC interactions

Dynamic Boss

Implement boss mechanics with events

Multi-part Entities

Handle per-part events

HitBox API

Complete hitbox API documentation