Class EntityTracker

java.lang.Object
kr.toxicity.model.api.tracker.Tracker
kr.toxicity.model.api.tracker.EntityTracker
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
PlayerTracker

public class EntityTracker extends Tracker
A tracker implementation that is attached to a living entity.

This tracker synchronizes the model's position, rotation, and animations with the target entity. It handles hitboxes, nametags, damage tinting, and mounting mechanics.

Since:
1.15.2
  • Constructor Details

    • EntityTracker

      @Internal public EntityTracker(@NotNull @NotNull EntityTrackerRegistry registry, @NotNull @NotNull RenderPipeline pipeline, @NotNull @NotNull TrackerModifier modifier, @NotNull @NotNull Consumer<EntityTracker> preUpdateConsumer)
      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
      Since:
      1.15.2
  • Method Details

    • rotation

      @NotNull public @NotNull ModelRotation rotation()
      Description copied from class: Tracker
      Returns the current rotation of the model.
      Overrides:
      rotation in class Tracker
      Returns:
      the model rotation
    • updateBaseEntity

      public void updateBaseEntity()
      Synchronizes the tracker with the base entity's data asynchronously.
      Since:
      1.15.2
    • registry

      @NotNull public @NotNull EntityTrackerRegistry registry()
      Returns the entity tracker registry associated with this tracker.
      Returns:
      the registry
      Since:
      1.15.2
    • createHitBox

      public boolean createHitBox(@Nullable @Nullable HitBoxListener listener, @NotNull @NotNull BonePredicate predicate)
      Creates hitboxes for the entity based on a predicate.
      Parameters:
      listener - the hitbox listener
      predicate - the bone predicate
      Returns:
      true if any hitboxes were created
      Since:
      1.15.2
    • hitbox

      @Nullable public @Nullable HitBox hitbox(@Nullable @Nullable HitBoxListener listener, @NotNull @NotNull Predicate<RenderedBone> predicate)
      Retrieves or creates a hitbox for the entity.
      Parameters:
      listener - the hitbox listener
      predicate - the bone predicate
      Returns:
      the hitbox, or null if not found/created
      Since:
      1.15.2
    • damageTintValue

      public int damageTintValue()
      Returns the current damage tint color value.
      Returns:
      the hex color value
      Since:
      1.15.2
    • damageTintValue

      public void damageTintValue(int tint)
      Sets the damage tint color value.
      Parameters:
      tint - the hex color value
      Since:
      1.15.2
    • damageTint

      public void damageTint()
      Triggers the damage tint effect if enabled.
      Since:
      1.15.2
    • despawn

      public void despawn()
      Description copied from class: Tracker
      Despawns the model for all players without closing the tracker completely.
      Overrides:
      despawn in class Tracker
    • location

      @NotNull public @NotNull PlatformLocation location()
      Description copied from class: Tracker
      Returns the current location of the model.
      Specified by:
      location in class Tracker
      Returns:
      the location
    • sourceEntity

      @NotNull public @NotNull BaseEntity sourceEntity()
      Returns the source entity being tracked.
      Returns:
      the source entity
      Since:
      1.15.2
    • cancelDamageTint

      public void cancelDamageTint()
      Cancels the active damage tint effect.
      Since:
      1.15.2
    • refresh

      @Internal public void refresh()
      Refreshes the tracker, updating entity data and hitboxes.
      Since:
      1.15.2
    • markPlayerForSpawn

      public boolean markPlayerForSpawn(@NotNull @NotNull PlatformPlayer player)
      Marks a player for spawning the model.
      Parameters:
      player - the player
      Returns:
      true if the player was added
      Since:
      1.15.2
    • markPlayerForSpawn

      public boolean markPlayerForSpawn(@NotNull @NotNull Set<UUID> uuids)
      Marks a set of players for spawning the model.
      Parameters:
      uuids - the set of player UUIDs
      Returns:
      true if any players were added
      Since:
      1.15.2
    • unmarkPlayerForSpawn

      public boolean unmarkPlayerForSpawn(@NotNull @NotNull PlatformPlayer player)
      Unmarks a player for spawning the model.
      Parameters:
      player - the player
      Returns:
      true if the player was removed
      Since:
      1.15.2
    • asTrackerData

      @NotNull public @NotNull TrackerData asTrackerData()
      Converts the current tracker state to a TrackerData object.
      Returns:
      the tracker data
      Since:
      1.15.2
    • bodyRotator

      @NotNull public @NotNull EntityBodyRotator bodyRotator()
      Returns the entity body rotator.
      Returns:
      the body rotator
      Since:
      1.15.2
    • canBeSpawnedAt

      public boolean canBeSpawnedAt(@NotNull @NotNull PlatformPlayer player)
      Checks if the model can be spawned for a specific player.
      Parameters:
      player - the player
      Returns:
      true if allowed
      Since:
      1.15.2
    • hideOption

      @NotNull public @NotNull EntityHideOption hideOption()
      Returns the hide option for this tracker.
      Returns:
      the hide option
      Since:
      1.15.2
    • hideOption

      public void hideOption(@NotNull @NotNull EntityHideOption hideOption)
      Sets the hide option for this tracker.
      Parameters:
      hideOption - the new hide option
      Since:
      1.15.2
    • canBeSaved

      public boolean canBeSaved()
      Checks if this tracker's data can be saved.
      Returns:
      true if saveable
      Since:
      1.15.2