Upload files to "/"
This commit is contained in:
35
PathNode.java
Normal file
35
PathNode.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package xyz.nodrop.farmingtools.client.pathfinding;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Single node in the A* search graph.
|
||||
* Comparable by f = g + h so it can be used directly in a PriorityQueue.
|
||||
*/
|
||||
public class PathNode implements Comparable<PathNode> {
|
||||
|
||||
public final BlockPos pos;
|
||||
public final PathNode parent;
|
||||
|
||||
/** Cost from start to this node. */
|
||||
public final double g;
|
||||
|
||||
/** Heuristic cost estimate from this node to goal. */
|
||||
public final double h;
|
||||
|
||||
public PathNode(BlockPos pos, PathNode parent, double g, double h) {
|
||||
this.pos = pos;
|
||||
this.parent = parent;
|
||||
this.g = g;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public double f() {
|
||||
return g + h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PathNode other) {
|
||||
return Double.compare(this.f(), other.f());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user