mirror of https://github.com/cabaletta/baritone
Merge branch 'master' into 1.13.2
This commit is contained in:
commit
4e96c5e5ee
|
@ -37,6 +37,7 @@ import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -238,7 +239,9 @@ public class SettingsUtil {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object parse(ParserContext context, String raw) {
|
public Object parse(ParserContext context, String raw) {
|
||||||
return this.parser.apply(raw);
|
Object parsed = this.parser.apply(raw);
|
||||||
|
Objects.requireNonNull(parsed);
|
||||||
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,7 @@ import baritone.utils.schematic.AirSchematic;
|
||||||
import baritone.utils.schematic.Schematic;
|
import baritone.utils.schematic.Schematic;
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
|
import net.minecraft.block.BlockFlowingFluid;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
@ -54,7 +55,6 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||||
|
|
||||||
|
@ -517,17 +517,45 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
||||||
}
|
}
|
||||||
|
|
||||||
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlacable) {
|
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlacable) {
|
||||||
List<BetterBlockPos> placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() instanceof BlockAir && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList());
|
List<BetterBlockPos> placable = new ArrayList<>();
|
||||||
Goal[] toBreak = incorrectPositions.stream().filter(pos -> !(bcc.bsi.get0(pos).getBlock() instanceof BlockAir)).map(pos -> breakGoal(pos, bcc)).toArray(Goal[]::new);
|
List<BetterBlockPos> breakable = new ArrayList<>();
|
||||||
Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementGoal(pos, bcc)).toArray(Goal[]::new);
|
List<BetterBlockPos> sourceLiquids = new ArrayList<>();
|
||||||
|
incorrectPositions.forEach(pos -> {
|
||||||
|
IBlockState state = bcc.bsi.get0(pos);
|
||||||
|
if (state.getBlock() instanceof BlockAir) {
|
||||||
|
if (approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))) {
|
||||||
|
placable.add(pos);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state.getBlock() instanceof BlockFlowingFluid) {
|
||||||
|
// if the block itself is JUST a liquid (i.e. not just a waterlogged block), we CANNOT break it
|
||||||
|
// TODO for 1.13 make sure that this only matches pure water, not waterlogged blocks
|
||||||
|
if (!MovementHelper.possiblyFlowing(state)) {
|
||||||
|
// if it's a source block then we want to replace it with a throwaway
|
||||||
|
sourceLiquids.add(pos);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
breakable.add(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
List<Goal> toBreak = new ArrayList<>();
|
||||||
|
breakable.forEach(pos -> toBreak.add(breakGoal(pos, bcc)));
|
||||||
|
List<Goal> toPlace = new ArrayList<>();
|
||||||
|
placable.forEach(pos -> {
|
||||||
|
if (!placable.contains(pos.down()) && !placable.contains(pos.down(2))) {
|
||||||
|
toPlace.add(placementGoal(pos, bcc));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sourceLiquids.forEach(pos -> toPlace.add(new GoalBlock(pos.up())));
|
||||||
|
|
||||||
if (toPlace.length != 0) {
|
if (!toPlace.isEmpty()) {
|
||||||
return new JankyGoalComposite(new GoalComposite(toPlace), new GoalComposite(toBreak));
|
return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0])));
|
||||||
}
|
}
|
||||||
if (toBreak.length == 0) {
|
if (toBreak.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new GoalComposite(toBreak);
|
return new GoalComposite(toBreak.toArray(new Goal[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JankyGoalComposite implements Goal {
|
public static class JankyGoalComposite implements Goal {
|
||||||
|
|
|
@ -206,9 +206,16 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||||
knownOreLocations = locs;
|
knownOreLocations = locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List<BlockPos> locs) {
|
private boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List<BlockPos> locs) {
|
||||||
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
||||||
return locs.contains(pos) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, pos) instanceof BlockAir);
|
if (locs.contains(pos)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Block block = BlockStateInterface.getBlock(ctx, pos);
|
||||||
|
if (Baritone.settings().internalMiningAirException.value && block instanceof BlockAir) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return mining.contains(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Goal coalesce(BlockPos loc, List<BlockPos> locs) {
|
private Goal coalesce(BlockPos loc, List<BlockPos> locs) {
|
||||||
|
@ -363,7 +370,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||||
|
|
||||||
.filter(pos -> !blacklist.contains(pos))
|
.filter(pos -> !blacklist.contains(pos))
|
||||||
|
|
||||||
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq))
|
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (locs.size() > max) {
|
if (locs.size() > max) {
|
||||||
|
|
Loading…
Reference in New Issue