mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-19 22:03:12 +01:00
Fix guided waypoint provider neighbour generation
This commit is contained in:
parent
2931f95939
commit
3e7b465a04
@ -18,10 +18,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import ch.ethz.globis.phtree.PhDistanceL;
|
import ch.ethz.globis.phtree.PhRangeQuery;
|
||||||
import ch.ethz.globis.phtree.PhFilterDistance;
|
|
||||||
import ch.ethz.globis.phtree.PhTree;
|
import ch.ethz.globis.phtree.PhTree;
|
||||||
import ch.ethz.globis.phtree.PhTree.PhKnnQuery;
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.ai.Goal;
|
import net.citizensnpcs.api.ai.Goal;
|
||||||
import net.citizensnpcs.api.ai.GoalSelector;
|
import net.citizensnpcs.api.ai.GoalSelector;
|
||||||
@ -338,10 +336,12 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(GoalSelector selector) {
|
public void run(GoalSelector selector) {
|
||||||
if (plan == null || plan.isComplete()) {
|
if (plan != null && plan.isComplete()) {
|
||||||
if (plan.isComplete()) {
|
target.onReach(npc);
|
||||||
target.onReach(npc);
|
plan = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plan == null) {
|
||||||
selector.finish();
|
selector.finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -435,17 +435,14 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<AStarNode> getNeighbours() {
|
public Iterable<AStarNode> getNeighbours() {
|
||||||
PhFilterDistance filter = new PhFilterDistance();
|
|
||||||
filter.set(
|
|
||||||
new long[] { waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(),
|
|
||||||
waypoint.getLocation().getBlockZ() },
|
|
||||||
PhDistanceL.THIS, distance == -1 ? npc.getNavigator().getDefaultParameters().range() : distance);
|
|
||||||
PhTree<Waypoint> source = getParent() == null ? tree : treePlusDestinations;
|
PhTree<Waypoint> source = getParent() == null ? tree : treePlusDestinations;
|
||||||
PhKnnQuery<Waypoint> res = source.nearestNeighbour(100, PhDistanceL.THIS, filter,
|
PhRangeQuery<Waypoint> rq = source.rangeQuery(
|
||||||
|
distance == -1 ? npc.getNavigator().getDefaultParameters().range() : distance,
|
||||||
waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(),
|
waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(),
|
||||||
waypoint.getLocation().getBlockZ());
|
waypoint.getLocation().getBlockZ());
|
||||||
List<AStarNode> neighbours = Lists.newArrayList();
|
List<AStarNode> neighbours = Lists.newArrayList();
|
||||||
res.forEachRemaining(n -> neighbours.add(new GuidedNode(this, n)));
|
rq.forEachRemaining(n -> neighbours.add(new GuidedNode(this, n)));
|
||||||
|
|
||||||
return neighbours;
|
return neighbours;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +450,11 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 31 + ((waypoint == null) ? 0 : waypoint.hashCode());
|
return 31 + ((waypoint == null) ? 0 : waypoint.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GuidedNode [" + waypoint + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class GuidedPlan implements Plan {
|
private static class GuidedPlan implements Plan {
|
||||||
|
Loading…
Reference in New Issue
Block a user