Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/com/zenith/command/impl/PathfinderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,13 @@ public LiteralArgumentBuilder<CommandContext> register() {
.addField("Failed Path Search Cooldown", CONFIG.client.extra.pathfinder.failedPathSearchCooldownMs)
.primaryColor();
})))
.then(literal("minDistPath").then(argument("blocks", doubleArg(0.0, 1000.0)).executes(c -> {
CONFIG.client.extra.pathfinder.minDistPath = getDouble(c, "blocks");
c.getSource().getEmbed()
.title("Pathfinder")
.addField("Min Dist Path", CONFIG.client.extra.pathfinder.minDistPath)
.primaryColor();
})))
.then(literal("renderPath").then(argument("toggle", toggle()).executes(c -> {
CONFIG.client.extra.pathfinder.renderPath = getToggle(c, "toggle");
c.getSource().getEmbed()
Expand Down Expand Up @@ -842,6 +849,7 @@ private Map<String, String> getSettingsMap() {
settingsMap.put("planAheadPrimaryTimeoutMs", String.valueOf(CONFIG.client.extra.pathfinder.planAheadPrimaryTimeoutMs));
settingsMap.put("planAheadFailureTimeoutMs", String.valueOf(CONFIG.client.extra.pathfinder.planAheadFailureTimeoutMs));
settingsMap.put("failedPathSearchCooldownMs", String.valueOf(CONFIG.client.extra.pathfinder.failedPathSearchCooldownMs));
settingsMap.put("minDistPath", String.valueOf(CONFIG.client.extra.pathfinder.minDistPath));
settingsMap.put("renderPath", toggleStr(CONFIG.client.extra.pathfinder.renderPath));
settingsMap.put("renderPathIntervalTicks", String.valueOf(CONFIG.client.extra.pathfinder.pathRenderIntervalTicks));
settingsMap.put("renderPathDetailed", toggleStr(CONFIG.client.extra.pathfinder.renderPathDetailed));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) {
bestHeuristicSoFar[i] = heuristic;
bestSoFar[i] = neighbor;
if (failing && getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) {
if (failing && getDistFromStartSq(neighbor) > minDistPathSq) {
failing = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public abstract class AbstractNodeCostSearch {
*/
protected static final double[] COEFFICIENTS = {1.5, 2, 2.5, 3, 4, 5, 10};

/**
* If a path goes less than 5 blocks and doesn't make it to its goal, it's not worth considering.
*/
protected static final double MIN_DIST_PATH = 5;

/**
* there are floating point errors caused by random combinations of traverse and diagonal over a flat area
Expand Down Expand Up @@ -170,7 +166,7 @@ protected Optional<IPath> bestSoFar(boolean logInfo, int numNodes) {
if (dist > bestDist) {
bestDist = dist;
}
if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared
if (dist > context.minDistPath * context.minDistPath) { // square the comparison since distFromStartSq is squared
return Optional.of(new Path(realStart, startNode, bestSoFar[i], numNodes, goal, context));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class CalculationContext {
public final boolean allowLongFall = CONFIG.client.extra.pathfinder.allowLongFall;
public final double longFallCostLogMultiplier = CONFIG.client.extra.pathfinder.longFallCostLogMultiplier;
public final double longFallCostAddCost = CONFIG.client.extra.pathfinder.longFallCostAddCost;
public final double minDistPath = CONFIG.client.extra.pathfinder.minDistPath;
// public final int maxFallHeightBucket;
public final double waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST + ActionCosts.WALK_ONE_BLOCK_COST;
public final double breakBlockAdditionalCost = CONFIG.client.extra.pathfinder.blockBreakAdditionalCost;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/zenith/util/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public static final class Pathfinder {
public double longFallCostLogMultiplier = 50;
public double longFallCostAddCost = 100;
public int followRadius = 2;
public double minDistPath = 5;
public int teleportDelayMs = 500;
public boolean renderPath = true;
public int pathRenderIntervalTicks = 10;
Expand Down