From 147a07f413eecf801a48c665f7bdb6975ca54743 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 6 May 2023 23:10:29 +0800 Subject: [PATCH] Simplify wander --- .../trait/waypoint/WanderWaypointProvider.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/WanderWaypointProvider.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/WanderWaypointProvider.java index 5cbddb688..d91eb7506 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/WanderWaypointProvider.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/WanderWaypointProvider.java @@ -72,20 +72,8 @@ public class WanderWaypointProvider @Override public Location apply(NPC npc) { - Location npcLoc = npc.getStoredLocation(); - Location closestCentre = regionCentres.stream() - .min((a, b) -> Double.compare(a.distanceSquared(npcLoc), b.distanceSquared(npcLoc))).orElse(null); - if (closestCentre != null) { - Location random = MinecraftBlockExaminer.findRandomValidLocation(closestCentre, xrange, yrange, - currentGoal.blockFilter(), Util.getFastRandom()); - if (random != null) - return random; - - // TODO: should find closest edge block that is valid - return MinecraftBlockExaminer.findValidLocation(npc.getStoredLocation(), xrange, yrange, - currentGoal.blockFilter()); - } - return null; + return MinecraftBlockExaminer.findValidLocation(npc.getStoredLocation(), xrange, yrange, + currentGoal.blockFilter()); } @Override