Fix bug with entity navigation
This commit is contained in:
parent
9d0b0aaef1
commit
7b40351c5f
|
@ -470,8 +470,9 @@ public class NMSImpl implements NMSBridge {
|
||||||
@Override
|
@Override
|
||||||
public TargetNavigator getTargetNavigator(org.bukkit.entity.Entity entity, org.bukkit.entity.Entity target,
|
public TargetNavigator getTargetNavigator(org.bukkit.entity.Entity entity, org.bukkit.entity.Entity target,
|
||||||
NavigatorParameters parameters) {
|
NavigatorParameters parameters) {
|
||||||
return getNavigation(entity) == null ? null
|
NavigationAbstract navigation = getNavigation(entity);
|
||||||
: new NavigationFieldWrapper(getNavigation(entity), entity, target, parameters);
|
return navigation == null ? null
|
||||||
|
: new NavigationFieldWrapper(navigation, target, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -918,15 +919,13 @@ public class NMSImpl implements NMSBridge {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NavigationFieldWrapper implements TargetNavigator {
|
private static class NavigationFieldWrapper implements TargetNavigator {
|
||||||
private final org.bukkit.entity.Entity handle;
|
|
||||||
private final NavigationAbstract navigation;
|
private final NavigationAbstract navigation;
|
||||||
private final NavigatorParameters parameters;
|
private final NavigatorParameters parameters;
|
||||||
private final org.bukkit.entity.Entity target;
|
private final org.bukkit.entity.Entity target;
|
||||||
|
|
||||||
private NavigationFieldWrapper(NavigationAbstract navigation, org.bukkit.entity.Entity handle,
|
private NavigationFieldWrapper(NavigationAbstract navigation, org.bukkit.entity.Entity target,
|
||||||
org.bukkit.entity.Entity target, NavigatorParameters parameters) {
|
NavigatorParameters parameters) {
|
||||||
this.navigation = navigation;
|
this.navigation = navigation;
|
||||||
this.handle = handle;
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
@ -942,10 +941,7 @@ public class NMSImpl implements NMSBridge {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
throw new IllegalStateException("mapper should not return null");
|
throw new IllegalStateException("mapper should not return null");
|
||||||
}
|
}
|
||||||
Location oldLoc = target.getLocation(HANDLE_LOCATION);
|
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed());
|
||||||
target.teleport(location);
|
|
||||||
NMS.setNavigationTarget(handle, target, parameters.speed());
|
|
||||||
target.teleport(oldLoc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -956,9 +952,7 @@ public class NMSImpl implements NMSBridge {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
updateNavigation(navigation);
|
updateNavigation(navigation);
|
||||||
}
|
};
|
||||||
|
|
||||||
private static final Location HANDLE_LOCATION = new Location(null, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NavigationIterable implements Iterable<Vector> {
|
private static class NavigationIterable implements Iterable<Vector> {
|
||||||
|
|
Loading…
Reference in New Issue