Skip to main content

Overview

The Tracker class is the core controller for a specific model instance in BetterModel. It manages the lifecycle, rendering, animation, and player interaction of a model, coordinating with the RenderPipeline to update bone positions and send packets to players. Package: kr.toxicity.model.api.tracker Since: 1.15.2

Key Concepts

  • Lifecycle Management: Controls spawning, despawning, and closing of model instances
  • Animation Control: Plays, stops, and replaces animations on the model
  • Player Visibility: Manages which players can see the model
  • Scheduled Updates: Runs periodic tasks at frame-rate (25ms) or Minecraft tick intervals (50ms)
  • Bone Management: Provides access to individual bones for manipulation

Constructor

Creates a new tracker. Parameters:
  • pipeline - The render pipeline
  • modifier - The tracker modifier configuration

Core Methods

Lifecycle

location

Returns the current location of the model.

close

Closes the tracker and removes the model (calls close(CloseReason.REMOVE)).

despawn

Despawns the model for all players without closing the tracker completely.

isClosed

Checks if the tracker has been closed.

Animation

animate

Plays an animation by name or blueprint. Returns: true if the animation started

stopAnimation

Stops an animation by name, optionally on filtered bones. Returns: true if the animation was stopped

replace

Replaces a running animation with a new one. Returns: true if the replacement occurred

Rotation and Scale

rotation

Gets the current rotation or sets the rotation supplier.

rotator

Sets the model rotator strategy.

scaler

Gets or sets the model scaler.

Scheduling

task

Schedules a task to run on the next tracker tick (Minecraft tick).

frame

Registers a handler to run every frame (25ms tracker tick).

tick

Registers a handler to run every Minecraft tick (50ms) or every N ticks.

schedule

Schedules a handler to run periodically.

perPlayerTick

Registers a handler to run every tick for each visible player.

Bone Access

bone

Retrieves a bone by name or predicate. Returns: The bone, or null if not found

bones

Returns a collection of all bones in the model.

displays

Returns a stream of all model displays.

Update Actions

update

Forces an update action on all or filtered bones.

tryUpdate

Tries to apply an update action to bones matching a predicate. Returns: true if any bones were updated

HitBox and Nametag

createHitBox

Creates a hitbox for bones matching a predicate. Returns: true if any hitboxes were created

hitbox

Retrieves or creates a hitbox for a specific bone. Returns: The hitbox, or null if not found/created

createNametag

Creates a nametag for bones matching a predicate. Returns: true if any nametags were created

listenHitBox

Registers hitbox event listeners for newly created hitboxes.

Player Visibility

hide

Hides the tracker from a specific player. Returns: true if hidden successfully

show

Shows the tracker to a specific player. Returns: true if shown successfully

isHide

Checks if the tracker is hidden from a specific player.

isSpawned

Checks if the model is spawned for a player.

Other Methods

pause

Pauses or resumes the tracker’s ticking. Returns: true if the state changed

forceUpdate

Flags the tracker for a forced update on the next tick. Returns: true if the state changed

height

Calculates the height of the model based on its head bone position.

name

Returns the name of the model being tracked.

playerCount

Returns the number of players currently viewing the model.

renderer

Returns the renderer associated with this tracker.

modifier

Returns the tracker modifier.

handleCloseEvent

Registers a handler for the tracker close event.

Constants

TRACKER_TICK_INTERVAL

The interval in milliseconds between tracker ticks.

MINECRAFT_TICK_MULTIPLIER

The multiplier to convert tracker ticks to Minecraft ticks (50ms).

Inner Classes

ScheduledPacketHandler

Functional interface for handling scheduled packets.

BundlerSet

Holds different types of packet bundlers for a tracker tick.

CloseReason

Enum representing reasons for closing a tracker.

Usage Examples

Basic Animation Control

Scheduling Tasks

Bone Manipulation

HitBox Management

Player Visibility

See Also