Skip to main content

Overview

The EntityTracker class is a Tracker implementation that is attached to a living entity. It synchronizes the model’s position, rotation, and animations with the target entity, and handles hitboxes, nametags, damage tinting, and mounting mechanics. Package: kr.toxicity.model.api.tracker Extends: Tracker Since: 1.15.2

Key Features

  • Entity Synchronization: Automatically follows the target entity’s position and rotation
  • Damage Effects: Supports damage tinting and animations
  • Shadow Rendering: Automatically manages entity shadows
  • Head Rotation: Synchronizes head bone rotation with entity look direction
  • Mounting: Supports mounting entities on model bones
  • Nametag Management: Automatically displays entity custom names
  • Persistence: Can save and restore tracker state

Constructor

Creates a new entity tracker. Parameters:
  • registry - The entity tracker registry
  • pipeline - The render pipeline
  • modifier - The tracker modifier
  • preUpdateConsumer - A consumer to run before the first update
This constructor is marked @ApiStatus.Internal and should not be called directly. Use BetterModelAPI.createEntityTracker() or similar factory methods instead.

Methods

Entity Information

sourceEntity

Returns the source entity being tracked. Returns: The source entity

registry

Returns the entity tracker registry associated with this tracker. Returns: The registry

location

Returns the current location of the model (synchronized with the entity). Returns: The location

Damage Effects

damageTint

Triggers the damage tint effect if enabled in the tracker modifier. The model will be tinted with the damage tint color for a short duration.

damageTintValue

Gets or sets the damage tint color value (RGB hex). Default: 0xFF8080 (light red)

cancelDamageTint

Cancels the active damage tint effect immediately.

Entity Synchronization

updateBaseEntity

Synchronizes the tracker with the base entity’s data asynchronously. This updates potion effects, position, and other entity properties on all bones.

refresh

Refreshes the tracker, updating entity data and hitboxes.
This method is marked @ApiStatus.Internal and is typically called automatically.

HitBox Management

createHitBox

Creates hitboxes for the entity based on a predicate. Parameters:
  • listener - Optional hitbox listener for interaction events
  • predicate - Bone predicate to filter which bones get hitboxes
Returns: true if any hitboxes were created

hitbox

Retrieves or creates a hitbox for the entity. Parameters:
  • listener - Optional hitbox listener
  • predicate - Bone predicate
Returns: The hitbox, or null if not found/created

Rotation Control

bodyRotator

Returns the entity body rotator that controls body and head rotation. Returns: The body rotator

rotation

Returns the current rotation of the model. If the entity is dead, returns the pipeline’s frozen rotation. Otherwise, returns the calculated rotation from the body rotator. Returns: The model rotation

Player Spawning Control

markPlayerForSpawn

Marks player(s) for spawning the model. When marked, the model will only spawn for these specific players. Returns: true if any players were added

unmarkPlayerForSpawn

Unmarks a player for spawning the model. Returns: true if the player was removed

canBeSpawnedAt

Checks if the model can be spawned for a specific player. Returns: true if allowed

Visibility Options

hideOption

Gets or sets the hide option for this tracker. Parameters:
  • hideOption - The new hide option controlling when the entity is hidden

Persistence

asTrackerData

Converts the current tracker state to a TrackerData object for persistence. Returns: The tracker data

canBeSaved

Checks if this tracker’s data can be saved. Returns: true if saveable

Lifecycle

despawn

Despawns the model for all players. If the source entity is dead, this closes the tracker with CloseReason.DESPAWN. Otherwise, it calls the parent despawn() method.

Usage Examples

Creating an Entity Tracker

Damage Effects

Entity Synchronization

HitBox and Mounting

Body and Head Rotation

Player-Specific Spawning

Hide Options

Persistence

Events

The following events are fired for entity trackers:
  • CreateEntityTrackerEvent - When the tracker is created
  • MountModelEvent - When an entity mounts a bone
  • DismountModelEvent - When an entity dismounts a bone
  • All standard Tracker events (spawn, despawn, close, etc.)

See Also