From a978ddec08c36192fbccc55a81f67b87b9b9b70d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Sep 2018 10:34:02 -0700 Subject: [PATCH] mineGoalUpdateInterval and cancelOnGoalInvalidation --- src/main/java/baritone/Settings.java | 11 +++++++++++ src/main/java/baritone/behavior/MineBehavior.java | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index cb2f4632..d14d75ee 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -327,6 +327,17 @@ public class Settings { */ public Setting walkWhileBreaking = new Setting<>(true); + /** + * Rescan for the goal once every 5 ticks. + * Set to 0 to disable. + */ + public Setting mineGoalUpdateInterval = new Setting<>(5); + + /** + * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore + */ + public Setting cancelOnGoalInvalidation = new Setting<>(true); + public final Map> byLowerName; public final List> allSettings; diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 6d9564bd..9a03b156 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -17,6 +17,7 @@ package baritone.behavior; +import baritone.Baritone; import baritone.api.behavior.Behavior; import baritone.api.event.events.PathEvent; import baritone.api.event.events.TickEvent; @@ -56,8 +57,14 @@ public final class MineBehavior extends Behavior implements Helper { if (mining == null) { return; } - if (event.getCount() % 5 == 0) { - updateGoal(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + if (mineGoalUpdateInterval != 0) { + if (event.getCount() % mineGoalUpdateInterval == 0) { + updateGoal(); + } + } + if (!Baritone.settings().cancelOnGoalInvalidation.get()) { + return; } Optional path = PathingBehavior.INSTANCE.getPath(); if (!path.isPresent()) {