no need to calculate the hash on contstruction anymore
This commit is contained in:
parent
38895beb5d
commit
04d210bd8b
@ -352,7 +352,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
} else {
|
||||
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
|
||||
}
|
||||
Optional<HashSet<Long>> favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC
|
||||
Optional<HashSet<Long>> favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(BetterBlockPos::longHash)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC
|
||||
try {
|
||||
IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions);
|
||||
return pf.calculate(timeout);
|
||||
@ -367,15 +367,17 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
if (!Baritone.settings().cancelOnGoalInvalidation.get()) {
|
||||
return;
|
||||
}
|
||||
if (current == null || goal == null) {
|
||||
return;
|
||||
}
|
||||
Goal intended = current.getPath().getGoal();
|
||||
BlockPos end = current.getPath().getDest();
|
||||
if (intended.isInGoal(end) && !goal.isInGoal(end)) {
|
||||
// this path used to end in the goal
|
||||
// but the goal has changed, so there's no reason to continue...
|
||||
cancel();
|
||||
synchronized (pathPlanLock) {
|
||||
if (current == null || goal == null) {
|
||||
return;
|
||||
}
|
||||
Goal intended = current.getPath().getGoal();
|
||||
BlockPos end = current.getPath().getDest();
|
||||
if (intended.isInGoal(end) && !goal.isInGoal(end)) {
|
||||
// this path used to end in the goal
|
||||
// but the goal has changed, so there's no reason to continue...
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,14 +36,12 @@ public final class BetterBlockPos extends BlockPos {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final long hashCode;
|
||||
|
||||
public BetterBlockPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.hashCode = AbstractNodeCostSearch.posHash(x, y, z);
|
||||
}
|
||||
|
||||
public BetterBlockPos(double x, double y, double z) {
|
||||
@ -56,7 +54,11 @@ public final class BetterBlockPos extends BlockPos {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) hashCode;
|
||||
return (int) AbstractNodeCostSearch.posHash(x, y, z);
|
||||
}
|
||||
|
||||
public static long longHash(BetterBlockPos pos) {
|
||||
return AbstractNodeCostSearch.posHash(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,9 +68,6 @@ public final class BetterBlockPos extends BlockPos {
|
||||
}
|
||||
if (o instanceof BetterBlockPos) {
|
||||
BetterBlockPos oth = (BetterBlockPos) o;
|
||||
if (oth.hashCode != hashCode) {
|
||||
return false;
|
||||
}
|
||||
return oth.x == x && oth.y == y && oth.z == z;
|
||||
}
|
||||
// during path execution, like "if (whereShouldIBe.equals(whereAmI)) {"
|
||||
|
Loading…
Reference in New Issue
Block a user