MCPcopy Create free account
hub / github.com/cabaletta/baritone / prune

Method prune

src/main/java/baritone/process/MineProcess.java:429–469  ·  view source on GitHub ↗
(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped)

Source from the content-addressed store, hash-verified

427 }
428
429 private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped) {
430 dropped.removeIf(drop -> {
431 for (BlockPos pos : locs2) {
432 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?
433 return true;
434 }
435 }
436 return false;
437 });
438 List<BlockPos> locs = locs2
439 .stream()
440 .distinct()
441
442 // remove any that are within loaded chunks that aren't actually what we want
443 .filter(pos -> !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
444
445 // remove any that are implausible to mine (encased in bedrock, or touching lava)
446 .filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
447
448 .filter(pos -> {
449 if (Baritone.settings().allowOnlyExposedOres.value) {
450 return isNextToAir(ctx, pos);
451 } else {
452 return true;
453 }
454 })
455
456 .filter(pos -> pos.getY() >= Baritone.settings().minYLevelWhileMining.value + ctx.world.dimensionType().minY())
457
458 .filter(pos -> pos.getY() <= Baritone.settings().maxYLevelWhileMining.value)
459
460 .filter(pos -> !blacklist.contains(pos))
461
462 .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player().blockPosition()::distSqr))
463 .collect(Collectors.toList());
464
465 if (locs.size() > max) {
466 return locs.subList(0, max);
467 }
468 return locs;
469 }
470
471 public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) {
472 int radius = Baritone.settings().allowOnlyExposedOresDistance.value;

Callers 3

updateGoalMethod · 0.95
searchWorldMethod · 0.95
addNearbyMethod · 0.95

Calls 15

plausibleToBreakMethod · 0.95
settingsMethod · 0.95
isNextToAirMethod · 0.95
getYMethod · 0.80
collectMethod · 0.80
filterMethod · 0.80
hasMethod · 0.65
getMethod · 0.65
getXMethod · 0.65
getZMethod · 0.65
playerMethod · 0.65

Tested by

no test coverage detected