diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java index 67ac6ab5..6502b9bd 100644 --- a/src/main/java/baritone/Settings.java +++ b/src/main/java/baritone/Settings.java @@ -343,6 +343,19 @@ public class Settings { */ public Setting axisHeight = new Setting<>(120); + /** + * When mining block of a certain type, try to mine two at once instead of one. + * If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks + * If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks + */ + public Setting forceInternalMining = new Setting<>(true); + + /** + * Modification to the previous setting, only has effect if forceInternalMining is true + * If true, only apply the previous setting if the block adjacent to the goal isn't air. + */ + public Setting internalMiningAirException = 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 3b0e4ec8..64c6c732 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -26,12 +26,14 @@ import baritone.cache.ChunkPacker; import baritone.cache.WorldProvider; import baritone.cache.WorldScanner; import baritone.pathing.goals.Goal; +import baritone.pathing.goals.GoalBlock; import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.path.IPath; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -95,7 +97,7 @@ public final class MineBehavior extends Behavior implements Helper { } if (!locationsCache.isEmpty()) { locationsCache = prune(new ArrayList<>(locationsCache), mining, 64); - PathingBehavior.INSTANCE.setGoal(new GoalComposite(locationsCache.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.setGoal(coalesce(locationsCache)); PathingBehavior.INSTANCE.path(); } List locs = scanFor(mining, 64); @@ -105,10 +107,34 @@ public final class MineBehavior extends Behavior implements Helper { return; } locationsCache = locs; - PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); + PathingBehavior.INSTANCE.setGoal(coalesce(locs)); PathingBehavior.INSTANCE.path(); } + public static GoalComposite coalesce(List locs) { + return new GoalComposite(locs.stream().map(loc -> { + if (!Baritone.settings().forceInternalMining.get()) { + return new GoalTwoBlocks(loc); + } + + boolean noUp = locs.contains(loc.up()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + boolean noDown = locs.contains(loc.down()) && !(Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + if (noUp) { + if (noDown) { + return new GoalTwoBlocks(loc); + } else { + return new GoalBlock(loc.down()); + } + } else { + if (noDown) { + return new GoalBlock(loc); + } else { + return new GoalTwoBlocks(loc); + } + } + }).toArray(Goal[]::new)); + } + public static List scanFor(List mining, int max) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>();