diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java index 1b59fe4e..b75a1cab 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java @@ -103,7 +103,13 @@ private void onEntityTargetAcquire(EntityTargetEvent event) { return; } - double targetDistanceSquared = event.getEntity().getLocation().distanceSquared(targetEntity.getLocation()); + double targetDistanceSquared; + try { + targetDistanceSquared = event.getEntity().getLocation().distanceSquared(targetEntity.getLocation()); + } catch (IllegalArgumentException e) { + if (logIsEnabled) error("Unable to measure distance between entity and target.", e); + return; + } if (globalDistanceEnabled) { if (targetDistanceSquared > globalMaxDistanceSquared) { diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java index afa5cfd6..475a03c9 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java @@ -102,7 +102,13 @@ private void onEntityPathfind(EntityPathfindEvent event) { return; } - double targetDistanceSquared = event.getEntity().getLocation().distanceSquared(event.getLoc()); + double targetDistanceSquared; + try { + targetDistanceSquared = event.getEntity().getLocation().distanceSquared(event.getLoc()); + } catch (IllegalArgumentException e) { + if (logIsEnabled) error("Unable to measure distance between entity and target.", e); + return; + } if (globalDistanceEnabled) { if (targetDistanceSquared > globalMaxDistanceSquared) { diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java index 0c2b5de8..44137e8c 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/EntityTargeting.java @@ -103,7 +103,13 @@ private void onEntityTargetAcquire(EntityTargetEvent event) { return; } - double targetDistanceSquared = event.getEntity().getLocation().distanceSquared(targetEntity.getLocation()); + double targetDistanceSquared; + try { + targetDistanceSquared = event.getEntity().getLocation().distanceSquared(targetEntity.getLocation()); + } catch (IllegalArgumentException e) { + if (logIsEnabled) error("Unable to measure distance between entity and target.", e); + return; + } if (globalDistanceEnabled) { if (targetDistanceSquared > globalMaxDistanceSquared) { diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java index afa5cfd6..0b7d022d 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/lagpreventions/physics/Pathfinding.java @@ -32,21 +32,21 @@ public Pathfinding() { 14.0, 120.0 ); - this.config.addComment(configPath+".enable", """ - Limits entities deciding to pathfind to a specific location\s - within a configurable radius and timeframe to help reduce lag\s - by cancelling burst activity hotspots."""); - this.limit = config.getInt(configPath + ".entity-pathfind-event-limit", 512, """ - Maximum number of times an entity can decide to start moving\s - towards a location within the configured timeframe before the\s - area will be put on cooldown."""); + this.config.addComment(configPath+".enable", + "Limits entities deciding to pathfind to a specific location\n" + + "within a configurable radius and timeframe to help reduce lag\n" + + "by cancelling burst activity hotspots."); + this.limit = config.getInt(configPath + ".entity-pathfind-event-limit", 512, + "Maximum number of times an entity can decide to start moving\n" + + "towards a location within the configured timeframe before the\n" + + "area will be put on cooldown."); this.globalDistanceEnabled = config.getBoolean(configPath + ".distance-limit.global-limit.enable", false); this.globalMaxDistanceSquared = NumberConversions.square( - config.getDouble(configPath + ".distance-limit.global-limit.max-target-distance", 20.0, """ - The max distance no mob pathfinding should exceed.\s - You always want this to be higher than your highest max distance\s - for a specific mob.""")); + config.getDouble(configPath + ".distance-limit.global-limit.max-target-distance", 20.0, + "The max distance no mob pathfinding should exceed.\n" + + "You always want this to be higher than your highest max distance\n" + + "for a specific mob.")); this.perTypeDistanceEnabled = config.getBoolean(configPath + ".distance-limit.custom-limits.enable", true); Map defaults = new EnumMap<>(XEntityType.class); @@ -102,7 +102,13 @@ private void onEntityPathfind(EntityPathfindEvent event) { return; } - double targetDistanceSquared = event.getEntity().getLocation().distanceSquared(event.getLoc()); + double targetDistanceSquared; + try { + targetDistanceSquared = event.getEntity().getLocation().distanceSquared(event.getLoc()); + } catch (IllegalArgumentException e) { + if (logIsEnabled) error("Unable to measure distance between entity and target.", e); + return; + } if (globalDistanceEnabled) { if (targetDistanceSquared > globalMaxDistanceSquared) {