mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
StraightLineTargetingStrategy should update target
This commit is contained in:
parent
6ff59a1fe0
commit
47d9330a56
@ -220,17 +220,12 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getCurrentDestination() {
|
public Location getCurrentDestination() {
|
||||||
if (active == null)
|
return active == null ? null : active.getCurrentDestination();
|
||||||
return null;
|
|
||||||
return active.getCurrentDestination();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Vector> getPath() {
|
public Iterable<Vector> getPath() {
|
||||||
if (active != null) {
|
return active != null ? active.getPath() : fallback.getPath();
|
||||||
return active.getPath();
|
|
||||||
}
|
|
||||||
return fallback.getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -239,15 +234,11 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
|||||||
if (location == null)
|
if (location == null)
|
||||||
throw new IllegalStateException("mapper should not return null");
|
throw new IllegalStateException("mapper should not return null");
|
||||||
|
|
||||||
if (parameters.straightLineTargetingDistance() > 0) {
|
if (parameters.straightLineTargetingDistance() > 0
|
||||||
double distance = npc.getStoredLocation().distance(location);
|
&& npc.getStoredLocation().distance(location) <= parameters.straightLineTargetingDistance()) {
|
||||||
if (distance < parameters.straightLineTargetingDistance()) {
|
|
||||||
if (active == null) {
|
|
||||||
active = new StraightLineNavigationStrategy(npc, target, parameters);
|
active = new StraightLineNavigationStrategy(npc, target, parameters);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
active = null;
|
active = null;
|
||||||
fallback.setPath();
|
fallback.setPath();
|
||||||
|
Loading…
Reference in New Issue
Block a user