From 7c404139d4199ea3a6b16e544d1f3be686765362 Mon Sep 17 00:00:00 2001 From: Jay Evans <16403908+jayoevans@users.noreply.github.com> Date: Fri, 19 Oct 2018 17:09:55 +1000 Subject: [PATCH] Optimized GeneralMethods#getTargetedEntity (#982) * GeneralMethods#getTargetedEntity will now only loop through entities within the specified range instead of all entities in the world --- src/com/projectkorra/projectkorra/GeneralMethods.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index f096efe3..9d6f837a 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -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;