Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[B+C] Add Location.getNearbyEntities. Adds BUKKIT-3868 #1068

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/org/bukkit/Location.java
@@ -1,6 +1,9 @@
package org.bukkit;

import java.util.Collection;

import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector;

Expand Down Expand Up @@ -82,6 +85,19 @@ public Block getBlock() {
return world.getBlockAt(this);
}

/**
* Returns a collection of entities within a bounding box centered
* around this location
*
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @return List<Entity> List of entities nearby
*/
public Collection<Entity> getNearbyEntities(double x, double y, double z) {
return world.getEntities(this, x, y, z);
}

/**
* Sets the x-coordinate of this location
*
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/bukkit/World.java
Expand Up @@ -429,6 +429,46 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public Collection<Entity> getEntitiesByClasses(Class<?>... classes);

/**
* Returns a collection of entities within a bounding box centered around the
* specified location
*
* @param center the center of the bounding box
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @return A Collection of entities nearby
*/
public Collection<Entity> getEntities(Location center, double x, double y, double z);

/**
* Get a collection of all entities in this World matching the given
* class/interface within a specific area
*
* @param center the center of the bounding box
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @param clazz The class representing the type of entity to match
* @return A Collection of all Entities currently residing in this world that
* match the given class/interface within the given area
*/
public <T extends Entity> Collection<T> getEntitiesByClass(Location center, double x, double y, double z, Class<T> clazz);

/**
* Get a collection of all entities in this World matching any of the
* given classes/interfaces within a specific area
*
* @param center the center of the bounding box
* @param x 1/2 the size of the box along x axis
* @param y 1/2 the size of the box along y axis
* @param z 1/2 the size of the box along z axis
* @param classes The classes representing the types of entity to match
* @return A Collection of all Entities currently residing in this world that
* match one or more of the given classes/interfaces in the area
*/
public Collection<Entity> getEntitiesByClasses(Location center, double x, double y, double z, Class<?>... classes);

/**
* Get a list of all players in this World
*
Expand Down