add mineOnlyExposedOres setting

Signed-off-by: scorbett123 <sam@corbettchocolates.com>
This commit is contained in:
scorbett123 2020-09-04 10:43:05 +01:00 committed by Sam Corbett
parent 7992b63aae
commit bcbfca100f
2 changed files with 21 additions and 0 deletions

View File

@ -726,6 +726,11 @@ public final class Settings {
*/ */
public final Setting<Integer> maxCachedWorldScanCount = new Setting<>(10); 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 GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
*/ */

View File

@ -40,6 +40,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -409,6 +410,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
// remove any that are implausible to mine (encased in bedrock, or touching lava) // remove any that are implausible to mine (encased in bedrock, or touching lava)
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos)) .filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
.filter(pos -> isNextToAir(ctx, pos))
.filter(pos -> !blacklist.contains(pos)) .filter(pos -> !blacklist.contains(pos))
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)) .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq))
@ -420,6 +423,19 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
return locs; return locs;
} }
public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) {
if (!Baritone.settings().allowOnlyExposedOres.value) {
return true;
}
return (ctx.bsi.get0(pos.down()).getBlock() == Blocks.AIR ||
ctx.bsi.get0(pos.up()).getBlock() == Blocks.AIR
|| ctx.bsi.get0(pos.north()).getBlock() == Blocks.AIR ||
ctx.bsi.get0(pos.south()).getBlock() == Blocks.AIR ||
ctx.bsi.get0(pos.east()).getBlock() == Blocks.AIR
|| ctx.bsi.get0(pos.west()).getBlock() == Blocks.AIR);
}
public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) { 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) { if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
return false; return false;