baritone/src/main/resources/baritone/pathfinding/Node.java

54 lines
1.5 KiB
Java
Raw Normal View History

2018-08-01 15:34:35 +00:00
package baritone.pathfinding;
import baritone.pathfinding.goals.Goal;
import baritone.pathfinding.actions.Action;
import java.util.Objects;
import net.minecraft.util.math.BlockPos;
/**
*
* @author leijurv
*/
public class Node {
final BlockPos pos;
double cost;
Node previous;
final Goal goal;
final double estimatedCostToGoal;
Action previousAction;
boolean isOpen;
Node nextOpen;
public Node(BlockPos pos, Goal goal) {
this.pos = pos;
this.previous = null;
this.cost = Short.MAX_VALUE;
this.goal = goal;
this.estimatedCostToGoal = goal.heuristic(pos);
this.previousAction = null;
this.isOpen = false;
}
@Override
public int hashCode() {//this is some OG code right here
int hash = 3241;
hash = 3457689 * hash + this.pos.getX();
hash = 8734625 * hash + this.pos.getY();
hash = 2873465 * hash + this.pos.getZ();
hash = 3241543 * hash + Objects.hashCode(this.goal);
return hash;
}
@Override
public boolean equals(Object obj) {//autogenerated by netbeans. that's why it looks disgusting.
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Node other = (Node) obj;
if (!Objects.equals(this.pos, other.pos)) {
return false;
}
return Objects.equals(this.goal, other.goal);
}
}