mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 22:23:59 +01:00
Simplify wander
This commit is contained in:
parent
35af40a9c5
commit
147a07f413
@ -72,21 +72,9 @@ public class WanderWaypointProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location apply(NPC npc) {
|
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,
|
return MinecraftBlockExaminer.findValidLocation(npc.getStoredLocation(), xrange, yrange,
|
||||||
currentGoal.blockFilter());
|
currentGoal.blockFilter());
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WaypointEditor createEditor(final CommandSender sender, CommandContext args) {
|
public WaypointEditor createEditor(final CommandSender sender, CommandContext args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user