fix loophole with falling blocks above ore

This commit is contained in:
Leijurv 2019-04-24 22:10:41 -08:00
parent 09fbf675ec
commit bc419cfd1a
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -47,6 +47,8 @@ import net.minecraft.world.World;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
/** /**
* Mine blocks of a certain type * Mine blocks of a certain type
* *
@ -334,7 +336,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world); List<BlockPos> dropped = droppedItemsScan(mining, ctx.world);
dropped.removeIf(drop -> { dropped.removeIf(drop -> {
for (BlockPos pos : locs2) { for (BlockPos pos : locs2) {
if (pos.distanceSq(drop) <= 9 && mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) && MineProcess.plausibleToBreak(ctx.bsi, pos)) { // TODO maybe drop also has to be supported? no lava below? if (pos.distanceSq(drop) <= 9 && mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) && MineProcess.plausibleToBreak(ctx, pos)) { // TODO maybe drop also has to be supported? no lava below?
return true; return true;
} }
} }
@ -348,7 +350,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
.filter(pos -> !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos)) .filter(pos -> !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
// 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.bsi, pos)) .filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
.filter(pos -> !blacklist.contains(pos)) .filter(pos -> !blacklist.contains(pos))
@ -361,13 +363,13 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
return locs; return locs;
} }
public static boolean plausibleToBreak(BlockStateInterface bsi, BlockPos pos) { public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) {
if (MovementHelper.avoidBreaking(bsi, pos.getX(), pos.getY(), pos.getZ(), bsi.get0(pos))) { if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
return false; return false;
} }
// bedrock above and below makes it implausible, otherwise we're good // bedrock above and below makes it implausible, otherwise we're good
return !(bsi.get0(pos.up()).getBlock() == Blocks.BEDROCK && bsi.get0(pos.down()).getBlock() == Blocks.BEDROCK); return !(ctx.bsi.get0(pos.up()).getBlock() == Blocks.BEDROCK && ctx.bsi.get0(pos.down()).getBlock() == Blocks.BEDROCK);
} }
@Override @Override