From ae9ab03e512649f93c55c0ecce934a2b36239ddd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Dec 2018 22:01:47 -0800 Subject: [PATCH] walk on water hunger penalty --- src/api/java/baritone/api/Settings.java | 5 +++++ .../java/baritone/pathing/movement/CalculationContext.java | 6 ++++++ .../pathing/movement/movements/MovementDiagonal.java | 2 ++ .../pathing/movement/movements/MovementTraverse.java | 2 ++ 4 files changed, 15 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 8528c921..59d6c217 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -73,6 +73,11 @@ public class Settings { */ public Setting jumpPenalty = new Setting<>(2D); + /** + * Walking on water uses up hunger really quick, so penalize it + */ + public Setting walkOnWaterOnePenalty = new Setting<>(5D); + /** * Allow Baritone to fall arbitrary distances and place a water bucket beneath it. * Reliability: questionable. diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index e81ed6c8..5d6fe81b 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -62,6 +62,7 @@ public class CalculationContext { private final double waterWalkSpeed; private final double breakBlockAdditionalCost; private final double jumpPenalty; + private final double walkOnWaterOnePenalty; private final BetterWorldBorder worldBorder; public CalculationContext(IBaritone baritone) { @@ -95,6 +96,7 @@ public class CalculationContext { this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); this.jumpPenalty = Baritone.settings().jumpPenalty.get(); + this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.get(); // why cache these things here, why not let the movements just get directly from settings? // because if some movements are calculated one way and others are calculated another way, // then you get a wildly inconsistent path that isn't optimal for either scenario. @@ -218,4 +220,8 @@ public class CalculationContext { public double jumpPenalty() { return jumpPenalty; } + + public double walkOnWaterOnePenalty() { + return walkOnWaterOnePenalty; + } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f53c5832..2b1e77af 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -80,6 +80,8 @@ public class MovementDiagonal extends Movement { // For either possible soul sand, that affects half of our walking if (destWalkOn.getBlock() == Blocks.SOUL_SAND) { multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; + } else if (destWalkOn.getBlock() == Blocks.WATER) { + multiplier += context.walkOnWaterOnePenalty() * SQRT_2; } Block fromDown = context.get(x, y - 1, z).getBlock(); if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 59720b91..2edfe78d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -75,6 +75,8 @@ public class MovementTraverse extends Movement { } else { if (destOn.getBlock() == Blocks.SOUL_SAND) { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; + } else if (destOn.getBlock() == Blocks.WATER) { + WC += context.walkOnWaterOnePenalty(); } if (srcDown == Blocks.SOUL_SAND) { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;