mirror of https://github.com/cabaletta/baritone
Implement `hashCode` for goals
This commit is contained in:
parent
6c8f2698d6
commit
30278a1c52
|
@ -47,6 +47,11 @@ public class GoalAxis implements Goal {
|
|||
return o.getClass() == GoalAxis.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 201385781;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalAxis";
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -81,6 +82,11 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
|||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * 905165533;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -80,6 +80,11 @@ public class GoalComposite implements Goal {
|
|||
return Arrays.equals(goals, goal.goals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(goals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalComposite" + Arrays.toString(goals);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -75,6 +76,11 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
|||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * -49639096;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -65,6 +65,11 @@ public class GoalInverted implements Goal {
|
|||
return Objects.equals(origin, goal.origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return origin.hashCode() * 495796690;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("GoalInverted{%s}", origin.toString());
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
|
||||
|
@ -102,6 +103,11 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
|||
&& rangeSq == goal.rangeSq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) + rangeSq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -140,6 +140,14 @@ public class GoalRunAway implements Goal {
|
|||
&& Objects.equals(maintainY, goal.maintainY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = Arrays.hashCode(from);
|
||||
hash = hash * 1196803141 + distanceSq;
|
||||
hash = hash * -2053788840 + maintainY;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (maintainY != null) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -86,6 +87,14 @@ public class GoalStrictDirection implements Goal {
|
|||
&& dz == goal.dz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = (int) BetterBlockPos.longHash(x, y, z);
|
||||
hash = hash * 630627507 + dx;
|
||||
hash = hash * -283028380 + dz;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -87,6 +88,11 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
|||
&& z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) BetterBlockPos.longHash(x, y, z) * 516508351;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -77,6 +77,14 @@ public class GoalXZ implements Goal {
|
|||
return x == goal.x && z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1791873246;
|
||||
hash = hash * 222601791 + x;
|
||||
hash = hash * -1331679453 + z;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -71,6 +71,11 @@ public class GoalYLevel implements Goal, ActionCosts {
|
|||
return level == goal.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return level * 1271009915;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -775,6 +775,14 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
&& Objects.equals(fallback, goal.fallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = -1701079641;
|
||||
hash = hash * 1196141026 + primary.hashCode();
|
||||
hash = hash * -80327868 + fallback.hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JankyComposite Primary: " + primary + " Fallback: " + fallback;
|
||||
|
@ -806,6 +814,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 1636324008;
|
||||
}
|
||||
}
|
||||
|
||||
private Goal placementGoal(BlockPos pos, BuilderCalculationContext bcc) {
|
||||
|
@ -883,6 +896,14 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
&& Objects.equals(no, goal.no);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 806368046;
|
||||
hash = hash * 1730799370 + (int) BetterBlockPos.longHash(no.getX(), no.getY(), no.getZ());
|
||||
hash = hash * 260592149 + (allowSameLevel ? -1314802005 : 1565710265);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
@ -906,6 +927,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return this.y * 100 + super.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 1910811835;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
|
@ -325,6 +325,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 393857768;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
|
Loading…
Reference in New Issue