diff --git a/src/api/java/baritone/api/behavior/IPathingBehavior.java b/src/api/java/baritone/api/behavior/IPathingBehavior.java
index f92a00ca..cfc93d2d 100644
--- a/src/api/java/baritone/api/behavior/IPathingBehavior.java
+++ b/src/api/java/baritone/api/behavior/IPathingBehavior.java
@@ -19,7 +19,7 @@ package baritone.api.behavior;
import baritone.api.pathing.calc.IPathFinder;
import baritone.api.pathing.goals.Goal;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.path.IPathExecutor;
import java.util.Optional;
diff --git a/src/api/java/baritone/api/pathing/path/IPath.java b/src/api/java/baritone/api/pathing/calc/IPath.java
similarity index 77%
rename from src/api/java/baritone/api/pathing/path/IPath.java
rename to src/api/java/baritone/api/pathing/calc/IPath.java
index 275f0f97..c9d58818 100644
--- a/src/api/java/baritone/api/pathing/path/IPath.java
+++ b/src/api/java/baritone/api/pathing/calc/IPath.java
@@ -15,16 +15,12 @@
* along with Baritone. If not, see .
*/
-package baritone.api.pathing.path;
+package baritone.api.pathing.calc;
-import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.movement.IMovement;
import baritone.api.utils.BetterBlockPos;
-import net.minecraft.client.Minecraft;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.chunk.EmptyChunk;
import java.util.List;
@@ -116,37 +112,25 @@ public interface IPath {
}
/**
- * Cuts off this path at the loaded chunk border, and returns the {@link CutoffResult}.
+ * Cuts off this path at the loaded chunk border, and returns the resulting path. Default
+ * implementation just returns this path, without the intended functionality.
*
* @return The result of this cut-off operation
*/
- default CutoffResult cutoffAtLoadedChunks() {
- for (int i = 0; i < positions().size(); i++) {
- BlockPos pos = positions().get(i);
- if (Minecraft.getMinecraft().world.getChunk(pos) instanceof EmptyChunk) {
- return CutoffResult.cutoffPath(this, i);
- }
- }
- return CutoffResult.preservePath(this);
+ default IPath cutoffAtLoadedChunks() {
+ return this;
}
/**
- * Cuts off this path using the min length and cutoff factor settings, and returns the {@link CutoffResult}.
+ * Cuts off this path using the min length and cutoff factor settings, and returns the resulting path.
+ * Default implementation just returns this path, without the intended functionality.
*
* @see Settings#pathCutoffMinimumLength
* @see Settings#pathCutoffFactor
*
* @return The result of this cut-off operation
*/
- default CutoffResult staticCutoff(Goal destination) {
- if (length() < BaritoneAPI.getSettings().pathCutoffMinimumLength.get()) {
- return CutoffResult.preservePath(this);
- }
- if (destination == null || destination.isInGoal(getDest())) {
- return CutoffResult.preservePath(this);
- }
- double factor = BaritoneAPI.getSettings().pathCutoffFactor.get();
- int newLength = (int) (length() * factor);
- return CutoffResult.cutoffPath(this, newLength);
+ default IPath staticCutoff(Goal destination) {
+ return this;
}
}
diff --git a/src/api/java/baritone/api/pathing/calc/IPathFinder.java b/src/api/java/baritone/api/pathing/calc/IPathFinder.java
index 31fed89d..446f7e05 100644
--- a/src/api/java/baritone/api/pathing/calc/IPathFinder.java
+++ b/src/api/java/baritone/api/pathing/calc/IPathFinder.java
@@ -18,7 +18,6 @@
package baritone.api.pathing.calc;
import baritone.api.pathing.goals.Goal;
-import baritone.api.pathing.path.IPath;
import java.util.Optional;
diff --git a/src/api/java/baritone/api/pathing/path/CutoffResult.java b/src/api/java/baritone/api/pathing/path/CutoffResult.java
deleted file mode 100644
index d4175e85..00000000
--- a/src/api/java/baritone/api/pathing/path/CutoffResult.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Baritone is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.api.pathing.path;
-
-/**
- * The result of a path cut-off operation.
- *
- * @author Brady
- * @since 10/8/2018
- */
-public final class CutoffResult {
-
- /**
- * The resulting path
- */
- private final IPath path;
-
- /**
- * The amount of movements that were removed
- */
- private final int removed;
-
- private CutoffResult(IPath path, int removed) {
- this.path = path;
- this.removed = removed;
- }
-
- /**
- * @return Whether or not the path was cut
- */
- public final boolean wasCut() {
- return this.removed > 0;
- }
-
- /**
- * @return The amount of movements that were removed
- */
- public final int getRemoved() {
- return this.removed;
- }
-
- /**
- * @return The resulting path
- */
- public final IPath getPath() {
- return this.path;
- }
-
- /**
- * Creates a new result from a successful cut-off operation.
- *
- * @param path The input path
- * @param index The index to cut the path at
- * @return The result of the operation
- */
- public static CutoffResult cutoffPath(IPath path, int index) {
- return new CutoffResult(new CutoffPath(path, index), path.positions().size() - index - 1);
- }
-
- /**
- * Creates a new result in which no cut-off occurred.
- *
- * @param path The input path
- * @return The result of the operation
- */
- public static CutoffResult preservePath(IPath path) {
- return new CutoffResult(path, 0);
- }
-}
diff --git a/src/api/java/baritone/api/pathing/path/IPathExecutor.java b/src/api/java/baritone/api/pathing/path/IPathExecutor.java
index bf701224..f72060dc 100644
--- a/src/api/java/baritone/api/pathing/path/IPathExecutor.java
+++ b/src/api/java/baritone/api/pathing/path/IPathExecutor.java
@@ -17,6 +17,8 @@
package baritone.api.pathing.path;
+import baritone.api.pathing.calc.IPath;
+
/**
* @author Brady
* @since 10/8/2018
diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java
index c701e7a5..e91769b8 100644
--- a/src/main/java/baritone/behavior/PathingBehavior.java
+++ b/src/main/java/baritone/behavior/PathingBehavior.java
@@ -25,8 +25,8 @@ import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalXZ;
-import baritone.api.pathing.path.CutoffResult;
-import baritone.api.pathing.path.IPath;
+import baritone.pathing.calc.CutoffPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.pathing.calc.AStarPathFinder;
@@ -285,27 +285,27 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
Optional path = findPath(start, previous);
if (Baritone.settings().cutoffAtLoadBoundary.get()) {
path = path.map(p -> {
- CutoffResult result = p.cutoffAtLoadedChunks();
+ IPath result = p.cutoffAtLoadedChunks();
- if (result.wasCut()) {
+ if (result instanceof CutoffPath) {
logDebug("Cutting off path at edge of loaded chunks");
- logDebug("Length decreased by " + result.getRemoved());
+ logDebug("Length decreased by " + (p.length() - result.length()));
} else {
logDebug("Path ends within loaded chunks");
}
- return result.getPath();
+ return result;
});
}
Optional executor = path.map(p -> {
- CutoffResult result = p.staticCutoff(goal);
+ IPath result = p.staticCutoff(goal);
- if (result.wasCut()) {
- logDebug("Static cutoff " + p.length() + " to " + result.getPath().length());
+ if (result instanceof CutoffPath) {
+ logDebug("Static cutoff " + p.length() + " to " + result.length());
}
- return result.getPath();
+ return result;
}).map(PathExecutor::new);
synchronized (pathPlanLock) {
diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java
index 3afafda9..f4adc7e2 100644
--- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java
+++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java
@@ -20,7 +20,7 @@ package baritone.pathing.calc;
import baritone.Baritone;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.movement.ActionCosts;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import baritone.pathing.calc.openset.BinaryHeapOpenSet;
import baritone.pathing.movement.CalculationContext;
diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java
index 3c033a93..424c512e 100644
--- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java
+++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java
@@ -20,7 +20,7 @@ package baritone.pathing.calc;
import baritone.Baritone;
import baritone.api.pathing.calc.IPathFinder;
import baritone.api.pathing.goals.Goal;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.Optional;
diff --git a/src/api/java/baritone/api/pathing/path/CutoffPath.java b/src/main/java/baritone/pathing/calc/CutoffPath.java
similarity index 96%
rename from src/api/java/baritone/api/pathing/path/CutoffPath.java
rename to src/main/java/baritone/pathing/calc/CutoffPath.java
index 1fcbdadc..bcf66b79 100644
--- a/src/api/java/baritone/api/pathing/path/CutoffPath.java
+++ b/src/main/java/baritone/pathing/calc/CutoffPath.java
@@ -15,10 +15,11 @@
* along with Baritone. If not, see .
*/
-package baritone.api.pathing.path;
+package baritone.pathing.calc;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.movement.IMovement;
+import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import java.util.Collections;
diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java
index 4983de54..f7bf9638 100644
--- a/src/main/java/baritone/pathing/calc/Path.java
+++ b/src/main/java/baritone/pathing/calc/Path.java
@@ -17,13 +17,16 @@
package baritone.pathing.calc;
+import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.movement.IMovement;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.Moves;
+import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.chunk.EmptyChunk;
import java.util.ArrayList;
import java.util.Collections;
@@ -188,4 +191,28 @@ class Path implements IPath {
public BetterBlockPos getDest() {
return end;
}
+
+ @Override
+ public IPath cutoffAtLoadedChunks() {
+ for (int i = 0; i < positions().size(); i++) {
+ BlockPos pos = positions().get(i);
+ if (Minecraft.getMinecraft().world.getChunk(pos) instanceof EmptyChunk) {
+ return new CutoffPath(this, i);
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public IPath staticCutoff(Goal destination) {
+ if (length() < BaritoneAPI.getSettings().pathCutoffMinimumLength.get()) {
+ return this;
+ }
+ if (destination == null || destination.isInGoal(getDest())) {
+ return this;
+ }
+ double factor = BaritoneAPI.getSettings().pathCutoffFactor.get();
+ int newLength = (int) (length() * factor);
+ return new CutoffPath(this, newLength);
+ }
}
diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java
index cbf078fd..6fba09a3 100644
--- a/src/main/java/baritone/pathing/path/PathExecutor.java
+++ b/src/main/java/baritone/pathing/path/PathExecutor.java
@@ -22,7 +22,7 @@ import baritone.api.event.events.TickEvent;
import baritone.api.pathing.movement.ActionCosts;
import baritone.api.pathing.movement.IMovement;
import baritone.api.pathing.movement.MovementStatus;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.path.IPathExecutor;
import baritone.api.utils.BetterBlockPos;
import baritone.pathing.calc.AbstractNodeCostSearch;
diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java
index de2630c9..841876d8 100644
--- a/src/main/java/baritone/utils/PathRenderer.java
+++ b/src/main/java/baritone/utils/PathRenderer.java
@@ -23,7 +23,7 @@ import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalComposite;
import baritone.api.pathing.goals.GoalTwoBlocks;
import baritone.api.pathing.goals.GoalXZ;
-import baritone.api.pathing.path.IPath;
+import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.behavior.PathingBehavior;