bukkit Entities Nearby Entities


Example

To retrieve a list of nearby entities of an entity, one can use

List<Entity> nearby = entity.getNearbyEntities(double x, double y, double z);

Bukkit will then calculate a bounding box centered around entity, having as parameters:

  • x: 1/2 the size of the box along x axis
  • y: 1/2 the size of the box along y axis
  • z: 1/2 the size of the box along z axis

The list may be empty, meaning that there are no nearby entities with the parameters.

This approach can be used to detect entities near custom projectiles, for example launching an Itemstack and detecting when it collides with a player