Check destination world matches NPC world in guided AI goal
This commit is contained in:
parent
4705cff283
commit
33955027ff
|
@ -364,6 +364,11 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.target = destinations.get(Util.getFastRandom().nextInt(destinations.size()));
|
this.target = destinations.get(Util.getFastRandom().nextInt(destinations.size()));
|
||||||
|
if (target.getLocation().getWorld().equals(npc.getEntity().getWorld())) {
|
||||||
|
target = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
|
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
|
||||||
return plan != null;
|
return plan != null;
|
||||||
}
|
}
|
||||||
|
@ -436,12 +441,12 @@ public class GuidedWaypointProvider implements EnumerableWaypointProvider {
|
||||||
@Override
|
@Override
|
||||||
public Iterable<AStarNode> getNeighbours() {
|
public Iterable<AStarNode> getNeighbours() {
|
||||||
PhTree<Waypoint> source = getParent() == null ? tree : treePlusDestinations;
|
PhTree<Waypoint> source = getParent() == null ? tree : treePlusDestinations;
|
||||||
PhRangeQuery<Waypoint> rq = source.rangeQuery(
|
PhRangeQuery<Waypoint> query = source.rangeQuery(
|
||||||
distance == -1 ? npc.getNavigator().getDefaultParameters().range() : distance,
|
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();
|
||||||
rq.forEachRemaining(n -> neighbours.add(new GuidedNode(this, n)));
|
query.forEachRemaining(wp -> neighbours.add(new GuidedNode(this, wp)));
|
||||||
|
|
||||||
return neighbours;
|
return neighbours;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue