Skip to content

Commit

Permalink
Update pathfinder to use distance rather than distanceSquared
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 20, 2013
1 parent f64971b commit c3b07a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -86,7 +86,7 @@ public Vector getVector() {
}

public float heuristicDistance(Vector goal) {
return (float) (location.distanceSquared(goal) + getBlockCost()) * TIEBREAKER;
return (float) (location.distance(goal) + getBlockCost()) * TIEBREAKER;
}

private boolean isPassable(PathPoint mod) {
Expand All @@ -99,5 +99,5 @@ private boolean isPassable(PathPoint mod) {
return true;
}

private static final float TIEBREAKER = 1.00001f;
private static final float TIEBREAKER = 1.001f;
}
3 changes: 2 additions & 1 deletion src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -57,8 +57,9 @@ public void addTrait(Trait trait) {
return;
}

if (trait.getNPC() == null)
if (trait.getNPC() == null) {
trait.linkToNPC(this);
}

// if an existing trait is being replaced, we need to remove the
// currently registered runnable to avoid conflicts
Expand Down

0 comments on commit c3b07a5

Please sign in to comment.