From e971d5d43fb14947e4872faaee52aa05ae24692a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Jan 2019 14:56:21 -0800 Subject: [PATCH] prevent favoring from affecting movement cost thresholds --- src/main/java/baritone/pathing/calc/Path.java | 4 +++- src/main/java/baritone/pathing/movement/Movement.java | 2 +- .../baritone/pathing/movement/movements/MovementAscend.java | 2 +- .../baritone/pathing/movement/movements/MovementDescend.java | 2 +- .../baritone/pathing/movement/movements/MovementDiagonal.java | 2 +- .../baritone/pathing/movement/movements/MovementDownward.java | 2 +- .../baritone/pathing/movement/movements/MovementFall.java | 2 +- .../baritone/pathing/movement/movements/MovementParkour.java | 2 +- .../baritone/pathing/movement/movements/MovementPillar.java | 2 +- .../baritone/pathing/movement/movements/MovementTraverse.java | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index 0b5b2cc7..37441743 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -132,7 +132,9 @@ class Path extends PathBase { Movement move = moves.apply0(context, src); if (move.getDest().equals(dest)) { // have to calculate the cost at calculation time so we can accurately judge whether a cost increase happened between cached calculation and real execution - move.override(cost); + // however, taking into account possible favoring that could skew the node cost, we really want the stricter limit of the two + // so we take the minimum of the path node cost difference, and the calculated cost + move.override(Math.min(move.calculateCost(context), cost)); return move; } } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index dcdcdec7..2db8bf8d 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -84,7 +84,7 @@ public abstract class Movement implements IMovement, MovementHelper { return cost; } - protected abstract double calculateCost(CalculationContext context); + public abstract double calculateCost(CalculationContext context); @Override public double recalculateCost() { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 9973e94b..2e20dd6e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -52,7 +52,7 @@ public class MovementAscend extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { return cost(context, src.x, src.y, src.z, dest.x, dest.z); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index ba915ac6..d2d2c282 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -52,7 +52,7 @@ public class MovementDescend extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { MutableMoveResult result = new MutableMoveResult(); cost(context, src.x, src.y, src.z, dest.x, dest.z, result); if (result.y != dest.y) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f2aeebbb..a47fc263 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -54,7 +54,7 @@ public class MovementDiagonal extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { MutableMoveResult result = new MutableMoveResult(); cost(context, src.x, src.y, src.z, dest.x, dest.z, result); if (result.y != dest.y) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 81b257e7..2bec8fcf 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -43,7 +43,7 @@ public class MovementDownward extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { return cost(context, src.x, src.y, src.z); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 90b44c14..6442d7d9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -54,7 +54,7 @@ public class MovementFall extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { MutableMoveResult result = new MutableMoveResult(); MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z, result); if (result.y != dest.y) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 5bc5b1db..ab98d3d0 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -166,7 +166,7 @@ public class MovementParkour extends Movement { @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { MutableMoveResult res = new MutableMoveResult(); cost(context, src.x, src.y, src.z, direction, res); if (res.x != dest.x || res.z != dest.z) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index fafba24a..b236f7e2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -42,7 +42,7 @@ public class MovementPillar extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { return cost(context, src.x, src.y, src.z); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 84e42358..0788ff8c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -60,7 +60,7 @@ public class MovementTraverse extends Movement { } @Override - protected double calculateCost(CalculationContext context) { + public double calculateCost(CalculationContext context) { return cost(context, src.x, src.y, src.z, dest.x, dest.z); }