Package net.minestom.server.instance
Interface EntityTracker
public sealed interface EntityTracker
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
EntityTracker.Target<E extends Entity>
Represents the type of entity you want to retrieve.static interface
EntityTracker.Update<E extends Entity>
Callback to know the newly visible entities and those to remove. -
Method Summary
Modifier and TypeMethodDescription<T extends Entity>
@UnmodifiableView Collection<T> chunkEntities
(int chunkX, int chunkZ, @NotNull EntityTracker.Target<T> target) default <T extends Entity>
@UnmodifiableView @NotNull Collection<T> chunkEntities
(@NotNull Point point, @NotNull EntityTracker.Target<T> target) entities()
entities
(@NotNull EntityTracker.Target<T> target) Gets all the entities tracked by this class.@Nullable Entity
getEntityById
(int id) Gets an entity based on its id (fromEntity.getEntityId()
).@Nullable Entity
getEntityByUuid
(UUID uuid) Gets an entity based on its UUID (fromEntity.getUuid()
).<T extends Entity>
voidmove
(@NotNull Entity entity, @NotNull Point newPoint, @NotNull EntityTracker.Target<T> target, @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.<T extends Entity>
voidnearbyEntities
(@NotNull Point point, double range, @NotNull EntityTracker.Target<T> target, @NotNull Consumer<T> query) Gets the entities within a range.<T extends Entity>
voidnearbyEntitiesByChunkRange
(@NotNull Point point, int chunkRange, @NotNull EntityTracker.Target<T> target, @NotNull Consumer<T> query) Gets the entities within a chunk range.static @NotNull EntityTracker
<T extends Entity>
voidregister
(@NotNull Entity entity, @NotNull Point point, @NotNull EntityTracker.Target<T> target, @Nullable EntityTracker.Update<T> update) Register an entity to be tracked.<T extends Entity>
voidunregister
(@NotNull Entity entity, @NotNull EntityTracker.Target<T> target, @Nullable EntityTracker.Update<T> update) Unregister an entity tracking.default @NotNull Viewable
viewable
(int chunkX, int chunkZ) @NotNull Viewable
viewable
(@NotNull List<@NotNull SharedInstance> sharedInstances, int chunkX, int chunkZ)
-
Method Details
-
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
Gets an entity based on its id (fromEntity.getEntityId()
).- Parameters:
id
- the entity id- Returns:
- the entity having the specified id, null if not found
-
getEntityByUuid
Gets an entity based on its UUID (fromEntity.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
-
viewable
@NotNull @NotNull Viewable viewable(@NotNull @NotNull List<@NotNull SharedInstance> sharedInstances, int chunkX, int chunkZ) -
viewable
-