From 773ad89951e5d68cacc86bb9216f7150d11ce119 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Oct 2018 20:36:18 -0700 Subject: [PATCH] refactor problematic area --- .../java/baritone/behavior/MineBehavior.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index ffa3298d7..c67e9ae62 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -110,28 +110,30 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe locationsCache = locs; } - public GoalComposite coalesce(List locs) { - return new GoalComposite(locs.stream().map(loc -> { - if (!Baritone.settings().forceInternalMining.get()) { + public Goal coalesce(BlockPos loc, List locs) { + if (!Baritone.settings().forceInternalMining.get()) { + return new GoalTwoBlocks(loc); + } + + boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); + if (upwardGoal) { + if (downwardGoal) { + return new GoalTwoBlocks(loc); + } else { + return new GoalBlock(loc); + } + } else { + if (downwardGoal) { + return new GoalBlock(loc.down()); + } else { return new GoalTwoBlocks(loc); } + } + } - boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); - boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); - if (upwardGoal) { - if (downwardGoal) { - return new GoalTwoBlocks(loc); - } else { - return new GoalBlock(loc); - } - } else { - if (downwardGoal) { - return new GoalBlock(loc.down()); - } else { - return new GoalTwoBlocks(loc); - } - } - }).toArray(Goal[]::new)); + public GoalComposite coalesce(List locs) { + return new GoalComposite(locs.stream().map(loc -> coalesce(loc, locs)).toArray(Goal[]::new)); } public List scanFor(List mining, int max) {