EntityTrackerRegistry

Manages all entity trackers for a specific entity.

This registry handles the lifecycle of trackers attached to an entity, including loading, saving, spawning, and despawning. It acts as a central hub for accessing and manipulating models on an entity.

The registry registers the entity's Molang queries when it is created. All trackers in this registry use the same runtime context through keyframeContext.


var registry = EntityTrackerRegistry.registry(entity.uuid());

Since

1.15.2

Types

Link copied to clipboard
Represents a hitbox that has an entity mounted on it.

Companion functions

Link copied to clipboard
@ApiStatus.Internal
@NotNull
open fun getOrCreate(@NotNull entity: @NotNull BaseEntity): @NotNull EntityTrackerRegistry
Gets or creates a registry for a base entity.
Link copied to clipboard
@NotNull
@Unmodifiable
open fun registries(): @NotNull @Unmodifiable List<EntityTrackerRegistry>
Returns a list of all active registries.
open fun registries(@NotNull consumer: @NotNull Consumer<EntityTrackerRegistry>)
Iterates over all active registries.
Link copied to clipboard
@Nullable
open fun registry(id: Int): @Nullable EntityTrackerRegistry
Retrieves a registry by entity ID.
@Nullable
open fun registry(@NotNull uuid: @NotNull UUID): @Nullable EntityTrackerRegistry
Retrieves a registry by entity UUID.
@Nullable
open fun registry(@NotNull entity: @NotNull BaseEntity): @Nullable EntityTrackerRegistry
Retrieves a registry for a base entity.

Functions

Link copied to clipboard
open fun close(): Boolean
Closes the registry.
open fun close(@NotNull reason: @NotNull TrackerCloseReason): Boolean
Closes the registry with a specific reason.
Link copied to clipboard
@ApiStatus.Internal
@NotNull
open fun create(@NotNull key: @NotNull String, @NotNull supplier: @NotNull (EntityTrackerRegistry) -> EntityTracker): @NotNull EntityTracker
Creates a new tracker in this registry.
Link copied to clipboard
open fun despawn()
Despawns all trackers in the registry.
Link copied to clipboard
@NotNull
open fun displays(): @NotNull Stream<ModelDisplay>
Returns a stream of all displays from all trackers.
Link copied to clipboard
@NotNull
open fun entity(): @NotNull BaseEntity
Returns the source entity.
Link copied to clipboard
@Nullable
open fun first(): @Nullable EntityTracker
Returns the first tracker in the registry.
Link copied to clipboard
@ApiStatus.Internal
@NotNull
open fun getOrCreate(@NotNull key: @NotNull String, @NotNull supplier: @NotNull (EntityTrackerRegistry) -> EntityTracker): @NotNull EntityTracker
Gets or creates a tracker in this registry.
Link copied to clipboard
Checks if any hitbox has a controlling passenger.
Link copied to clipboard
open fun hasPassenger(): Boolean
Checks if any hitbox has a passenger.
Link copied to clipboard
@NotNull
open fun hideOption(@NotNull uuid: @NotNull UUID): @NotNull EntityHideOption
Returns the hide option for a specific player.
Link copied to clipboard
@NotNull
@Unmodifiable
open fun hitBoxes(): @NotNull @Unmodifiable Collection<HitBox>
Returns a collection of all active hitboxes for this registry.
Link copied to clipboard
open fun id(): Int
Returns the entity ID.
Link copied to clipboard
open fun isClosed(): Boolean
Checks if the registry is closed.
Link copied to clipboard
open fun isSpawned(@NotNull uuid: @NotNull UUID): Boolean
Checks if any tracker is spawned for a player UUID.
open fun isSpawned(@NotNull player: @NotNull PlatformPlayer): Boolean
Checks if any tracker is spawned for a player.
Link copied to clipboard
open fun load()
Loads trackers from the entity's persistent data.
open fun load(@NotNull stream: @NotNull Stream<TrackerData>)
Loads trackers from a stream of data.
Link copied to clipboard
@NotNull
@Unmodifiable
open fun mountedHitBox(): @NotNull @Unmodifiable Map<UUID, EntityTrackerRegistry.MountedHitBox>
Returns the map of currently mounted hitboxes.
Link copied to clipboard
open fun refresh()
Refreshes the registry state.
Link copied to clipboard
open fun reload()
Reloads the registry, refreshing all trackers.
Link copied to clipboard
open fun remove(@NotNull key: @NotNull String): Boolean
Removes a tracker from the registry.
open fun remove(@NotNull player: @NotNull PlatformPlayer): Boolean
Removes a player from viewing this registry.
Link copied to clipboard
open fun save()
Saves the current tracker state to the entity's persistent data.
Link copied to clipboard
@NotNull
open fun serialize(): @NotNull JsonArray
Serializes the registry state to a JSON array.
Link copied to clipboard
open fun spawn(@NotNull player: @NotNull PlatformPlayer): Boolean
Spawns trackers for a player.
Link copied to clipboard
open fun spawnIfNotSpawned(@NotNull player: @NotNull PlatformPlayer): Boolean
Spawns trackers for a player only if not already spawned.
Link copied to clipboard
@Nullable
open fun tracker(@Nullable key: @Nullable String): @Nullable EntityTracker
Retrieves a tracker by key.
Link copied to clipboard
@NotNull
@Unmodifiable
open fun trackers(): @NotNull @Unmodifiable Collection<EntityTracker>
Returns all trackers in this registry.
Link copied to clipboard
@NotNull
open fun uuid(): @NotNull UUID
Returns the entity UUID.
Link copied to clipboard
@NotNull
open fun viewedPlayer(): @NotNull Stream<PlayerChannelHandler>
Returns a stream of all players viewing this registry.