Optimized GeneralMethods#getTargetedEntity (#982)

* GeneralMethods#getTargetedEntity will now only loop through entities within the specified range instead of all entities in the world
This commit is contained in:
Jay Evans 2018-10-19 17:09:55 +10:00 committed by Christopher Martin
parent d1141d5dfc
commit 7c404139d4

View file

@ -125,7 +125,6 @@ import com.projectkorra.projectkorra.util.ReflectionHandler.PackageType;
import com.projectkorra.projectkorra.util.TempArmor;
import com.projectkorra.projectkorra.util.TempArmorStand;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.TimeUtil;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
@ -1109,7 +1108,7 @@ public class GeneralMethods {
Entity target = null;
final Location origin = player.getEyeLocation();
final Vector direction = player.getEyeLocation().getDirection().normalize();
for (final Entity entity : origin.getWorld().getEntities()) {
for (final Entity entity : getEntitiesAroundPoint(origin, range)) {
if (entity instanceof Player) {
if (((Player) entity).isDead() || ((Player) entity).getGameMode().equals(GameMode.SPECTATOR)) {
continue;