Search in sources :

Example 21 with CalculationContext

use of baritone.pathing.movement.CalculationContext in project baritone by cabaletta.

the class MineProcess method prune.

private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped) {
    dropped.removeIf(drop -> {
        for (BlockPos pos : locs2) {
            if (pos.distanceSq(drop) <= 9 && filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) && MineProcess.plausibleToBreak(ctx, pos)) {
                // TODO maybe drop also has to be supported? no lava below?
                return true;
            }
        }
        return false;
    });
    List<BlockPos> locs = locs2.stream().distinct().filter(pos -> !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos)).filter(pos -> MineProcess.plausibleToBreak(ctx, pos)).filter(pos -> {
        if (Baritone.settings().allowOnlyExposedOres.value) {
            return isNextToAir(ctx, pos);
        } else {
            return true;
        }
    }).filter(pos -> pos.getY() >= Baritone.settings().minYLevelWhileMining.value).filter(pos -> !blacklist.contains(pos)).sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)).collect(Collectors.toList());
    if (locs.size() > max) {
        return locs.subList(0, max);
    }
    return locs;
}
Also used : IMineProcess(baritone.api.process.IMineProcess) java.util(java.util) Blocks(net.minecraft.init.Blocks) COST_INF(baritone.api.pathing.movement.ActionCosts.COST_INF) BaritoneProcessHelper(baritone.utils.BaritoneProcessHelper) MovementHelper(baritone.pathing.movement.MovementHelper) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) baritone.api.utils(baritone.api.utils) EntityItem(net.minecraft.entity.item.EntityItem) Entity(net.minecraft.entity.Entity) WorldScanner(baritone.cache.WorldScanner) BlockFalling(net.minecraft.block.BlockFalling) BlockAir(net.minecraft.block.BlockAir) PathingCommandType(baritone.api.process.PathingCommandType) BlockPos(net.minecraft.util.math.BlockPos) CalculationContext(baritone.pathing.movement.CalculationContext) Collectors(java.util.stream.Collectors) PathingCommand(baritone.api.process.PathingCommand) IBlockState(net.minecraft.block.state.IBlockState) baritone.api.pathing.goals(baritone.api.pathing.goals) Baritone(baritone.Baritone) CachedChunk(baritone.cache.CachedChunk) BlockStateInterface(baritone.utils.BlockStateInterface) Input(baritone.api.utils.input.Input) BlockPos(net.minecraft.util.math.BlockPos)

Example 22 with CalculationContext

use of baritone.pathing.movement.CalculationContext in project baritone by cabaletta.

the class MineProcess method mine.

@Override
public void mine(int quantity, BlockOptionalMetaLookup filter) {
    this.filter = filter;
    if (filter != null && !Baritone.settings().allowBreak.value) {
        logDirect("Unable to mine when allowBreak is false!");
        this.mine(quantity, (BlockOptionalMetaLookup) null);
        return;
    }
    this.desiredQuantity = quantity;
    this.knownOreLocations = new ArrayList<>();
    this.blacklist = new ArrayList<>();
    this.branchPoint = null;
    this.branchPointRunaway = null;
    this.anticipatedDrops = new HashMap<>();
    if (filter != null) {
        rescan(new ArrayList<>(), new CalculationContext(baritone));
    }
}
Also used : CalculationContext(baritone.pathing.movement.CalculationContext)

Aggregations

CalculationContext (baritone.pathing.movement.CalculationContext)22 BlockPos (net.minecraft.util.math.BlockPos)16 PathingCommand (baritone.api.process.PathingCommand)10 IBlockState (net.minecraft.block.state.IBlockState)10 Baritone (baritone.Baritone)8 Input (baritone.api.utils.input.Input)8 MovementHelper (baritone.pathing.movement.MovementHelper)8 BlockStateInterface (baritone.utils.BlockStateInterface)8 Blocks (net.minecraft.init.Blocks)8 baritone.api.pathing.goals (baritone.api.pathing.goals)6 COST_INF (baritone.api.pathing.movement.ActionCosts.COST_INF)6 IMineProcess (baritone.api.process.IMineProcess)6 PathingCommandType (baritone.api.process.PathingCommandType)6 baritone.api.utils (baritone.api.utils)6 CachedChunk (baritone.cache.CachedChunk)6 WorldScanner (baritone.cache.WorldScanner)6 BaritoneProcessHelper (baritone.utils.BaritoneProcessHelper)6 java.util (java.util)6 Collectors (java.util.stream.Collectors)6 Block (net.minecraft.block.Block)6