mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 17:47:35 +01:00
Normalise distance margin calculations across implementations and loosen up the y distance restriction
This commit is contained in:
parent
d64876dd65
commit
d7e1110d46
@ -99,22 +99,22 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
destVector.setZ(vector.getZ() + targetFace.getModZ());
|
||||
}
|
||||
}*/
|
||||
if (currLoc.toVector().distanceSquared(destVector) <= params.distanceMargin()) {
|
||||
double dX = vector.getBlockX() - currLoc.getX();
|
||||
double dZ = vector.getBlockZ() - currLoc.getZ();
|
||||
double dY = vector.getY() - currLoc.getY();
|
||||
double xzDistance = dX * dX + dZ * dZ;
|
||||
if ((dY * dY) < 1 && xzDistance <= params.distanceMargin()) {
|
||||
plan.update(npc);
|
||||
if (plan.isComplete()) {
|
||||
return true;
|
||||
}
|
||||
vector = plan.getCurrentVector();
|
||||
}
|
||||
double dX = vector.getBlockX() - currLoc.getX();
|
||||
double dZ = vector.getBlockZ() - currLoc.getZ();
|
||||
double dY = vector.getY() - currLoc.getY();
|
||||
double xzDistance = dX * dX + dZ * dZ;
|
||||
double distance = xzDistance + dY * dY;
|
||||
if (params.debug()) {
|
||||
npc.getEntity().getWorld().playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL,
|
||||
0);
|
||||
}
|
||||
double distance = xzDistance + dY * dY;
|
||||
if (distance > 0 && dY > NMS.getStepHeight(npc.getEntity()) && xzDistance <= 2.75) {
|
||||
NMS.setShouldJump(npc.getEntity());
|
||||
}
|
||||
|
@ -38,10 +38,6 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
|
||||
this.navigator = NMS.getTargetNavigator(npc.getEntity(), dest, params);
|
||||
}
|
||||
|
||||
private double distanceSquared() {
|
||||
return handle.getLocation(HANDLE_LOCATION).distanceSquared(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Vector> getPath() {
|
||||
return navigator.getPath();
|
||||
@ -76,7 +72,12 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
|
||||
return true;
|
||||
boolean wasFinished = navigator.update();
|
||||
parameters.run();
|
||||
if (distanceSquared() < parameters.distanceMargin()) {
|
||||
handle.getLocation(HANDLE_LOCATION);
|
||||
double dX = target.getBlockX() + 0.5 - HANDLE_LOCATION.getX();
|
||||
double dZ = target.getBlockZ() + 0.5 - HANDLE_LOCATION.getZ();
|
||||
double dY = target.getY() - HANDLE_LOCATION.getY();
|
||||
double xzDistance = dX * dX + dZ * dZ;
|
||||
if ((dY * dY) < 1 && xzDistance <= parameters.distanceMargin()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user