mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-09 22:38:04 +02:00
Respect distanceMargin when NPCs are passively moving towards entities
This commit is contained in:
parent
95993348bd
commit
c1321c2162
@ -34,7 +34,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
this.target = ((CraftEntity) target).getHandle();
|
||||
NavigationAbstract nav = NMS.getNavigation(this.handle);
|
||||
this.targetNavigator = nav != null && !params.useNewPathfinder() ? new NavigationFieldWrapper(nav)
|
||||
: new AStarTargeter();
|
||||
: new AStarTargeter();
|
||||
this.aggro = aggro;
|
||||
}
|
||||
|
||||
@ -114,7 +114,9 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
if (cancelReason != null) {
|
||||
return true;
|
||||
}
|
||||
if (target.world.getWorld().getFullTime() % 10 == 0) {
|
||||
if (!aggro && distanceSquared() < parameters.distanceMargin()) {
|
||||
stop();
|
||||
} else if (target.world.getWorld().getFullTime() % 10 == 0) {
|
||||
setPath();
|
||||
}
|
||||
NMS.look(handle, target);
|
||||
@ -159,7 +161,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
private void setStrategy() {
|
||||
Location location = target.getBukkitEntity().getLocation(TARGET_LOCATION);
|
||||
strategy = npc.isFlyable() ? new FlyingAStarNavigationStrategy(npc, location, parameters)
|
||||
: new AStarNavigationStrategy(npc, location, parameters);
|
||||
: new AStarNavigationStrategy(npc, location, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user