migrate to mojmap

This commit is contained in:
wagyourtail
2021-06-23 11:24:32 -06:00
parent f0130c7199
commit e6d8b268c7
159 changed files with 1453 additions and 1447 deletions

View File

@@ -32,17 +32,25 @@ import baritone.utils.BaritoneProcessHelper;
import baritone.utils.BlockStateInterface;
import baritone.utils.NotificationHelper;
import net.minecraft.block.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.state.BlockState;
import java.util.*;
import java.util.stream.Collectors;
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
import BlockOptionalMetaLookup;
import Goal;
import GoalRunAway;
/**
* Mine blocks of a certain type
*
@@ -248,7 +256,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
}
private Goal coalesce(BlockPos loc, List<BlockPos> locs, CalculationContext context) {
boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof FallingBlock);
boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.above()).getBlock() instanceof FallingBlock);
if (!Baritone.settings().forceInternalMining.value) {
if (assumeVerticalShaftMine) {
// we can get directly below the block
@@ -258,9 +266,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
return new GoalTwoBlocks(loc);
}
}
boolean upwardGoal = internalMiningGoal(loc.up(), context, locs);
boolean downwardGoal = internalMiningGoal(loc.down(), context, locs);
boolean doubleDownwardGoal = internalMiningGoal(loc.down(2), context, locs);
boolean upwardGoal = internalMiningGoal(loc.above(), context, locs);
boolean downwardGoal = internalMiningGoal(loc.below(), context, locs);
boolean doubleDownwardGoal = internalMiningGoal(loc.below(2), context, locs);
if (upwardGoal == downwardGoal) { // symmetric
if (doubleDownwardGoal && assumeVerticalShaftMine) {
// we have a checkerboard like pattern
@@ -282,11 +290,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
if (doubleDownwardGoal && assumeVerticalShaftMine) {
// this block and two below it are goals
// path into the center of the one below, because that includes directly below this one
return new GoalTwoBlocks(loc.down());
return new GoalTwoBlocks(loc.below());
}
// upwardGoal false, downwardGoal true, doubleDownwardGoal false
// just this block and the one immediately below, no others
return new GoalBlock(loc.down());
return new GoalBlock(loc.below());
}
private static class GoalThreeBlocks extends GoalTwoBlocks {
@@ -314,11 +322,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
return Collections.emptyList();
}
List<BlockPos> ret = new ArrayList<>();
for (Entity entity : ((ClientWorld) ctx.world()).getAllEntities()) {
for (Entity entity : ((ClientLevel) ctx.world()).entitiesForRendering()) {
if (entity instanceof ItemEntity) {
ItemEntity ei = (ItemEntity) entity;
if (filter.has(ei.getItem())) {
ret.add(entity.getPosition());
ret.add(entity.blockPosition());
}
}
}
@@ -378,7 +386,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
// is an x-ray and it'll get caught
if (filter.has(bsi.get0(x, y, z))) {
BlockPos pos = new BlockPos(x, y, z);
if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) {
if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distSqr(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) {
knownOreLocations.add(pos);
}
}
@@ -391,7 +399,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
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?
if (pos.distSqr(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;
}
}
@@ -450,7 +458,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
}
// bedrock above and below makes it implausible, otherwise we're good
return !(ctx.bsi.get0(pos.up()).getBlock() == Blocks.BEDROCK && ctx.bsi.get0(pos.down()).getBlock() == Blocks.BEDROCK);
return !(ctx.bsi.get0(pos.above()).getBlock() == Blocks.BEDROCK && ctx.bsi.get0(pos.below()).getBlock() == Blocks.BEDROCK);
}
@Override