Merge pull request #1995 from scorbett123/exposedOres
add mineOnlyExposedOres setting
This commit is contained in:
commit
5a5d11922f
@ -738,6 +738,18 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10);
|
||||
|
||||
/**
|
||||
* This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them.
|
||||
*/
|
||||
public final Setting<Boolean> allowOnlyExposedOres = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* When allowOnlyExposedOres is enabled this is the distance around to search.
|
||||
* <p>
|
||||
* It is recommended to keep this value low, as it dramatically increases calculation times.
|
||||
*/
|
||||
public final Setting<Integer> allowOnlyExposedOresDistance = new Setting<>(1);
|
||||
|
||||
/**
|
||||
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
|
||||
*/
|
||||
|
@ -562,4 +562,11 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
enum PlaceResult {
|
||||
READY_TO_PLACE, ATTEMPTING, NO_OPTION;
|
||||
}
|
||||
static boolean isTransparent(Block b) {
|
||||
|
||||
return b == Blocks.AIR ||
|
||||
b == Blocks.FLOWING_LAVA ||
|
||||
b == Blocks.FLOWING_WATER ||
|
||||
b == Blocks.WATER;
|
||||
}
|
||||
}
|
||||
|
@ -409,6 +409,14 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
|
||||
|
||||
.filter(pos -> {
|
||||
if (Baritone.settings().allowOnlyExposedOres.value) {
|
||||
return isNextToAir(ctx, pos);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
|
||||
.filter(pos -> !blacklist.contains(pos))
|
||||
|
||||
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq))
|
||||
@ -420,6 +428,22 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return locs;
|
||||
}
|
||||
|
||||
public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) {
|
||||
int radius = Baritone.settings().allowOnlyExposedOresDistance.value;
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dy = -radius; dy <= radius; dy++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
if (Math.abs(dx) + Math.abs(dy) + Math.abs(dz) <= radius
|
||||
&& MovementHelper.isTransparent(ctx.getBlock(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) {
|
||||
if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user