refactor problematic area

This commit is contained in:
Leijurv 2018-10-11 20:36:18 -07:00
parent c2adcdb051
commit 773ad89951
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 21 additions and 19 deletions

View File

@ -110,28 +110,30 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
locationsCache = locs; locationsCache = locs;
} }
public GoalComposite coalesce(List<BlockPos> locs) { public Goal coalesce(BlockPos loc, List<BlockPos> locs) {
return new GoalComposite(locs.stream().map(loc -> { if (!Baritone.settings().forceInternalMining.get()) {
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); return new GoalTwoBlocks(loc);
} }
}
}
boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); public GoalComposite coalesce(List<BlockPos> locs) {
boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR); return new GoalComposite(locs.stream().map(loc -> coalesce(loc, locs)).toArray(Goal[]::new));
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 List<BlockPos> scanFor(List<Block> mining, int max) { public List<BlockPos> scanFor(List<Block> mining, int max) {