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

Method addNearby

src/main/java/baritone/process/MineProcess.java:397–427  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

395 }
396
397 private boolean addNearby() {
398 List<BlockPos> dropped = droppedItemsScan();
399 knownOreLocations.addAll(dropped);
400 BlockPos playerFeet = ctx.playerFeet();
401 BlockStateInterface bsi = new BlockStateInterface(ctx);
402
403
404 BlockOptionalMetaLookup filter = filterFilter();
405 if (filter == null) {
406 return false;
407 }
408
409 int searchDist = 10;
410 double fakedBlockReachDistance = 20; // at least 10 * sqrt(3) with some extra space to account for positioning within the block
411 for (int x = playerFeet.getX() - searchDist; x <= playerFeet.getX() + searchDist; x++) {
412 for (int y = playerFeet.getY() - searchDist; y <= playerFeet.getY() + searchDist; y++) {
413 for (int z = playerFeet.getZ() - searchDist; z <= playerFeet.getZ() + searchDist; z++) {
414 // crucial to only add blocks we can see because otherwise this
415 // is an x-ray and it'll get caught
416 if (filter.has(bsi.get0(x, y, z))) {
417 BlockPos pos = new BlockPos(x, y, z);
418 if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distSqr(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx, pos, fakedBlockReachDistance).isPresent()) {
419 knownOreLocations.add(pos);
420 }
421 }
422 }
423 }
424 }
425 knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, Baritone.settings().mineMaxOreLocationsCount.value, blacklist, dropped);
426 return true;
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 -> {

Callers 1

onTickMethod · 0.95

Calls 13

droppedItemsScanMethod · 0.95
filterFilterMethod · 0.95
hasMethod · 0.95
get0Method · 0.95
settingsMethod · 0.95
reachableMethod · 0.95
pruneMethod · 0.95
playerFeetMethod · 0.80
getYMethod · 0.80
addMethod · 0.80
getXMethod · 0.65
getZMethod · 0.65

Tested by

no test coverage detected