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 {
|
} else {
|
||||||
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
|
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 {
|
try {
|
||||||
IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions);
|
IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions);
|
||||||
return pf.calculate(timeout);
|
return pf.calculate(timeout);
|
||||||
@ -367,6 +367,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
if (!Baritone.settings().cancelOnGoalInvalidation.get()) {
|
if (!Baritone.settings().cancelOnGoalInvalidation.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
synchronized (pathPlanLock) {
|
||||||
if (current == null || goal == null) {
|
if (current == null || goal == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -378,6 +379,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderPass(RenderEvent event) {
|
public void onRenderPass(RenderEvent event) {
|
||||||
|
@ -36,14 +36,12 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
public final int x;
|
public final int x;
|
||||||
public final int y;
|
public final int y;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final long hashCode;
|
|
||||||
|
|
||||||
public BetterBlockPos(int x, int y, int z) {
|
public BetterBlockPos(int x, int y, int z) {
|
||||||
super(x, y, z);
|
super(x, y, z);
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.hashCode = AbstractNodeCostSearch.posHash(x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BetterBlockPos(double x, double y, double z) {
|
public BetterBlockPos(double x, double y, double z) {
|
||||||
@ -56,7 +54,11 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
@ -66,9 +68,6 @@ public final class BetterBlockPos extends BlockPos {
|
|||||||
}
|
}
|
||||||
if (o instanceof BetterBlockPos) {
|
if (o instanceof BetterBlockPos) {
|
||||||
BetterBlockPos oth = (BetterBlockPos) o;
|
BetterBlockPos oth = (BetterBlockPos) o;
|
||||||
if (oth.hashCode != hashCode) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return oth.x == x && oth.y == y && oth.z == z;
|
return oth.x == x && oth.y == y && oth.z == z;
|
||||||
}
|
}
|
||||||
// during path execution, like "if (whereShouldIBe.equals(whereAmI)) {"
|
// during path execution, like "if (whereShouldIBe.equals(whereAmI)) {"
|
||||||
|
Loading…
Reference in New Issue
Block a user