Interface EntityTracker


public sealed interface EntityTracker
Defines how entities are tracked within an instance.

Implementations are expected to be thread-safe.

  • Method Details

    • newTracker

      @NotNull static @NotNull EntityTracker newTracker()
    • register

      <T extends Entity> void register(@NotNull @NotNull Entity entity, @NotNull @NotNull Point point, @NotNull @NotNull EntityTracker.Target<T> target, @Nullable @Nullable EntityTracker.Update<T> update)
      Register an entity to be tracked.
    • unregister

      <T extends Entity> void unregister(@NotNull @NotNull Entity entity, @NotNull @NotNull EntityTracker.Target<T> target, @Nullable @Nullable EntityTracker.Update<T> update)
      Unregister an entity tracking.
    • getEntityById

      @Nullable @Nullable Entity getEntityById(int id)
      Gets an entity based on its id (from Entity.getEntityId()).
      Parameters:
      id - the entity id
      Returns:
      the entity having the specified id, null if not found
    • getEntityByUuid

      @Nullable @Nullable Entity getEntityByUuid(UUID uuid)
      Gets an entity based on its UUID (from Entity.getUuid()).
      Parameters:
      uuid - the entity UUID
      Returns:
      the entity having the specified uuid, null if not found
    • move

      <T extends Entity> void move(@NotNull @NotNull Entity entity, @NotNull @NotNull Point newPoint, @NotNull @NotNull EntityTracker.Target<T> target, @Nullable @Nullable EntityTracker.Update<T> update)
      Called every time an entity move, you may want to verify if the new position is in a different chunk.
    • chunkEntities

      <T extends Entity> @UnmodifiableView Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull @NotNull EntityTracker.Target<T> target)
    • chunkEntities

      @NotNull default <T extends Entity> @UnmodifiableView @NotNull Collection<T> chunkEntities(@NotNull @NotNull Point point, @NotNull @NotNull EntityTracker.Target<T> target)
    • nearbyEntitiesByChunkRange

      <T extends Entity> void nearbyEntitiesByChunkRange(@NotNull @NotNull Point point, int chunkRange, @NotNull @NotNull EntityTracker.Target<T> target, @NotNull @NotNull Consumer<T> query)
      Gets the entities within a chunk range.
    • nearbyEntities

      <T extends Entity> void nearbyEntities(@NotNull @NotNull Point point, double range, @NotNull @NotNull EntityTracker.Target<T> target, @NotNull @NotNull Consumer<T> query)
      Gets the entities within a range.
    • entities

      @NotNull <T extends Entity> @UnmodifiableView @NotNull Set<@NotNull T> entities(@NotNull @NotNull EntityTracker.Target<T> target)
      Gets all the entities tracked by this class.
    • entities

      @NotNull default @UnmodifiableView @NotNull Set<@NotNull Entity> entities()
    • viewable

      @NotNull @NotNull Viewable viewable(@NotNull @NotNull List<@NotNull SharedInstance> sharedInstances, int chunkX, int chunkZ)
    • viewable

      @NotNull default @NotNull Viewable viewable(int chunkX, int chunkZ)