From a713a9de8c4f4a887f1d8aa5f7ead1e9e98b69f6 Mon Sep 17 00:00:00 2001 From: Zax71 Date: Sun, 21 Apr 2024 14:04:22 +0100 Subject: [PATCH] Separate out ALL case --- .../utils/PortalDetector.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java b/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java index 43bcd54..478a8d6 100644 --- a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java +++ b/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; import java.util.regex.Pattern; public class PortalDetector { @@ -257,17 +256,19 @@ public Entity[] getRedstoneTeleportEntities(Sign sign) { List entitiesInRange = new ArrayList(worldEntities.size()); for (LivingEntity entity : worldEntities) { - if ((type == RedstoneTeleportType.ALL || type == RedstoneTeleportType.ANIMALS) && (entity instanceof Animals || entity instanceof Squid || entity instanceof Villager)) { - if (entity.getLocation().toVector().isInAABB(min, max)) { - Logging.finest("Found " + entity + " within range!"); - entitiesInRange.add(entity); - } - } else if ((type == RedstoneTeleportType.ALL || type == RedstoneTeleportType.MONSTERS) && (entity instanceof Monster)) { - if (entity.getLocation().toVector().isInAABB(min, max)) { - Logging.finest("Found " + entity + " within range!"); - entitiesInRange.add(entity); - } - } else if ((type == RedstoneTeleportType.ALL || type == RedstoneTeleportType.PLAYERS) && (entity instanceof HumanEntity)) { + boolean tryToAddEntity = false; + + if (type == RedstoneTeleportType.ALL) { + tryToAddEntity = true; + } else if (type == RedstoneTeleportType.ANIMALS && (entity instanceof Animals || entity instanceof Squid || entity instanceof Villager)) { + tryToAddEntity = true; + } else if (type == RedstoneTeleportType.MONSTERS && (entity instanceof Monster)) { + tryToAddEntity = true; + } else if (type == RedstoneTeleportType.PLAYERS && (entity instanceof HumanEntity)) { + tryToAddEntity = true; + } + + if (tryToAddEntity && entity.getLocation().toVector().isInAABB(min, max)) { if (entity.getLocation().toVector().isInAABB(min, max)) { Logging.finest("Found " + entity + " within range!"); entitiesInRange.add(entity);