force internal mining

This commit is contained in:
Leijurv 2018-09-16 13:00:44 -07:00
parent eca41a046a
commit 9937739518
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 41 additions and 2 deletions

View File

@ -343,6 +343,19 @@ public class Settings {
*/ */
public Setting<Integer> axisHeight = new Setting<>(120); public Setting<Integer> 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<Boolean> 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<Boolean> internalMiningAirException = new Setting<>(true);
public final Map<String, Setting<?>> byLowerName; public final Map<String, Setting<?>> byLowerName;
public final List<Setting<?>> allSettings; public final List<Setting<?>> allSettings;

View File

@ -26,12 +26,14 @@ import baritone.cache.ChunkPacker;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
import baritone.cache.WorldScanner; import baritone.cache.WorldScanner;
import baritone.pathing.goals.Goal; import baritone.pathing.goals.Goal;
import baritone.pathing.goals.GoalBlock;
import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalComposite;
import baritone.pathing.goals.GoalTwoBlocks; import baritone.pathing.goals.GoalTwoBlocks;
import baritone.pathing.path.IPath; import baritone.pathing.path.IPath;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.utils.Helper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.EmptyChunk;
@ -95,7 +97,7 @@ public final class MineBehavior extends Behavior implements Helper {
} }
if (!locationsCache.isEmpty()) { if (!locationsCache.isEmpty()) {
locationsCache = prune(new ArrayList<>(locationsCache), mining, 64); 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(); PathingBehavior.INSTANCE.path();
} }
List<BlockPos> locs = scanFor(mining, 64); List<BlockPos> locs = scanFor(mining, 64);
@ -105,10 +107,34 @@ public final class MineBehavior extends Behavior implements Helper {
return; return;
} }
locationsCache = locs; locationsCache = locs;
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new))); PathingBehavior.INSTANCE.setGoal(coalesce(locs));
PathingBehavior.INSTANCE.path(); PathingBehavior.INSTANCE.path();
} }
public static GoalComposite coalesce(List<BlockPos> 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<BlockPos> scanFor(List<Block> mining, int max) { public static List<BlockPos> scanFor(List<Block> mining, int max) {
List<BlockPos> locs = new ArrayList<>(); List<BlockPos> locs = new ArrayList<>();
List<Block> uninteresting = new ArrayList<>(); List<Block> uninteresting = new ArrayList<>();