From 8bfe32eeefa7af4a630d6e2823f0899bd1e5c359 Mon Sep 17 00:00:00 2001 From: mankool <8884398+mankool0@users.noreply.github.com> Date: Wed, 9 Jun 2021 10:34:45 -0700 Subject: [PATCH] Added itemSaverThreshold --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ba4b4c52..2e131588 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -733,6 +733,11 @@ public final class Settings { */ public final Setting itemSaver = new Setting<>(false); + /** + * Durability to leave on the tool when using itemSaver + */ + public final Setting itemSaverThreshold = new Setting<>(10); + /** * Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk * touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand. diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 22ef3a64..c9e18eb7 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -112,7 +112,7 @@ public final class InventoryBehavior extends Behavior { if (stack.isEmpty()) { continue; } - if (Baritone.settings().itemSaver.value && stack.getItemDamage() >= stack.getMaxDamage() && stack.getMaxDamage() > 1) { + if (Baritone.settings().itemSaver.value && (stack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= stack.getMaxDamage() && stack.getMaxDamage() > 1) { continue; } if (cla$$.isInstance(stack.getItem())) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 0e153e77..e5e96e34 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -129,7 +129,7 @@ public class ToolSet { continue; } - if (Baritone.settings().itemSaver.value && itemStack.getItemDamage() >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { + if (Baritone.settings().itemSaver.value && (itemStack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { continue; } double speed = calculateSpeedVsBlock(itemStack, blockState);