Merge pull request #2107 from scorbett123/toolsSaver

add itemSaver setting.
This commit is contained in:
Leijurv 2021-02-06 13:33:01 -08:00 committed by GitHub
commit b32c9f1724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -696,6 +696,11 @@ public final class Settings {
*/
public final Setting<Boolean> censorRanCommands = new Setting<>(false);
/**
* Stop using tools just before they are going to break.
*/
public final Setting<Boolean> itemSaver = new Setting<>(false);
/**
* 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.

View File

@ -114,7 +114,7 @@ public final class InventoryBehavior extends Behavior {
}
if (cla$$.isInstance(stack.getItem())) {
double speed = ToolSet.calculateSpeedVsBlock(stack, against.getDefaultState()); // takes into account enchants
if (speed > bestSpeed) {
if (speed > bestSpeed && !(stack.getItemDamage() >= stack.getMaxDamage() && Baritone.settings().itemSaver.value && stack.getMaxDamage() > 1)) {
bestSpeed = speed;
bestInd = i;
}

View File

@ -124,6 +124,9 @@ public class ToolSet {
IBlockState blockState = b.getDefaultState();
for (int i = 0; i < 9; i++) {
ItemStack itemStack = player.inventory.getStackInSlot(i);
if (itemStack.getItemDamage() >= itemStack.getMaxDamage() && Baritone.settings().itemSaver.value && itemStack.getMaxDamage() > 1) {
continue;
}
double speed = calculateSpeedVsBlock(itemStack, blockState);
boolean silkTouch = hasSilkTouch(itemStack);
if (speed > highestSpeed) {