Fix censorCoordinates recalc bug
Adds `equals` and `toString` implementations where needed Replaces `toString` equality check with actual `equals` check in `forceRevalidate`
This commit is contained in:
@@ -42,6 +42,11 @@ public class GoalAxis implements Goal {
|
||||
return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o.getClass() == GoalAxis.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalAxis";
|
||||
|
||||
@@ -66,6 +66,17 @@ public class GoalBlock implements Goal, IGoalRenderPos {
|
||||
return calculate(xDiff, yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalBlock goal = (GoalBlock) o;
|
||||
if (x != goal.x) return false;
|
||||
if (y != goal.y) return false;
|
||||
return z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -67,6 +67,15 @@ public class GoalComposite implements Goal {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalComposite goal = (GoalComposite) o;
|
||||
return Arrays.equals(goals, goal.goals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoalComposite" + Arrays.toString(goals);
|
||||
|
||||
@@ -60,6 +60,17 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
|
||||
return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalGetToBlock goal = (GoalGetToBlock) o;
|
||||
if (x != goal.x) return false;
|
||||
if (y != goal.y) return false;
|
||||
return z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package baritone.api.pathing.goals;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Invert any goal.
|
||||
* <p>
|
||||
@@ -50,6 +52,15 @@ public class GoalInverted implements Goal {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalInverted goal = (GoalInverted) o;
|
||||
return Objects.equals(origin, goal.origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("GoalInverted{%s}", origin.toString());
|
||||
|
||||
@@ -86,6 +86,18 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalNear goal = (GoalNear) o;
|
||||
if (x != goal.x) return false;
|
||||
if (y != goal.y) return false;
|
||||
if (z != goal.z) return false;
|
||||
return rangeSq == goal.rangeSq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -23,6 +23,7 @@ import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Useful for automated combat (retreating specifically)
|
||||
@@ -124,6 +125,17 @@ public class GoalRunAway implements Goal {
|
||||
return maxInside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalRunAway goal = (GoalRunAway) o;
|
||||
if (distanceSq != goal.distanceSq) return false;
|
||||
if (!Arrays.equals(from, goal.from)) return false;
|
||||
return Objects.equals(maintainY, goal.maintainY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (maintainY != null) {
|
||||
|
||||
@@ -69,6 +69,19 @@ public class GoalStrictDirection implements Goal {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalStrictDirection goal = (GoalStrictDirection) o;
|
||||
if (x != goal.x) return false;
|
||||
if (y != goal.y) return false;
|
||||
if (z != goal.z) return false;
|
||||
if (dx != goal.dx) return false;
|
||||
return dz == goal.dz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -72,6 +72,17 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalTwoBlocks goal = (GoalTwoBlocks) o;
|
||||
if (x != goal.x) return false;
|
||||
if (y != goal.y) return false;
|
||||
return z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -64,6 +64,16 @@ public class GoalXZ implements Goal {
|
||||
return calculate(xDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalXZ goal = (GoalXZ) o;
|
||||
if (x != goal.x) return false;
|
||||
return z == goal.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -58,6 +58,15 @@ public class GoalYLevel implements Goal, ActionCosts {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
GoalYLevel goal = (GoalYLevel) o;
|
||||
return level == goal.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
@@ -30,10 +30,7 @@ import baritone.api.schematic.ISchematic;
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.RayTraceUtils;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.RotationUtils;
|
||||
import baritone.api.utils.*;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.Movement;
|
||||
@@ -764,6 +761,16 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return primary.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
JankyGoalComposite goal = (JankyGoalComposite) o;
|
||||
if (!Objects.equals(primary, goal.primary)) return false;
|
||||
return Objects.equals(fallback, goal.fallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JankyComposite Primary: " + primary + " Fallback: " + fallback;
|
||||
@@ -785,6 +792,16 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
// but any other adjacent works for breaking, including inside or below
|
||||
return super.isInGoal(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"GoalBreak{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private Goal placementGoal(BlockPos pos, BuilderCalculationContext bcc) {
|
||||
@@ -828,6 +845,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
this.allowSameLevel = allowSameLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(int x, int y, int z) {
|
||||
if (x == this.x && y == this.y && z == this.z) {
|
||||
return false;
|
||||
@@ -844,10 +862,30 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
return super.isInGoal(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {
|
||||
// prioritize lower y coordinates
|
||||
return this.y * 100 + super.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
GoalAdjacent goal = (GoalAdjacent) o;
|
||||
if (allowSameLevel != goal.allowSameLevel) return false;
|
||||
return Objects.equals(no, goal.no);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"GoalAdjacent{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GoalPlace extends GoalBlock {
|
||||
@@ -856,10 +894,21 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
super(placeAt.up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double heuristic(int x, int y, int z) {
|
||||
// prioritize lower y coordinates
|
||||
return this.y * 100 + super.heuristic(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"GoalPlace{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -319,6 +319,21 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
int zDiff = z - this.z;
|
||||
return GoalBlock.calculate(xDiff, yDiff < -1 ? yDiff + 2 : yDiff == -1 ? 0 : yDiff, zDiff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"GoalThreeBlocks{x=%s,y=%s,z=%s}",
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlockPos> droppedItemsScan() {
|
||||
|
||||
@@ -160,7 +160,7 @@ public class PathingControlManager implements IPathingControlManager {
|
||||
if (newGoal.isInGoal(current.getPath().getDest())) {
|
||||
return false;
|
||||
}
|
||||
return !newGoal.toString().equals(current.getPath().getGoal().toString());
|
||||
return !newGoal.equals(current.getPath().getGoal());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user