From 1c2e47c39af8d6085bbbd3e936cddec3924b1161 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 20 Sep 2018 14:14:59 -0500 Subject: [PATCH] Add maxSearchRadius parameter to WorldScanner --- src/main/java/baritone/cache/WorldScanner.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 106161f8..48cb59ba 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -39,9 +39,10 @@ public enum WorldScanner implements Helper { * @param max The maximum number of blocks to scan before cutoff * @param yLevelThreshold If a block is found within this Y level, the current result will be * returned, if the value is negative, then this condition doesn't apply. + * @param maxSearchRadius The maximum chunk search radius * @return The matching block positions */ - public List scanLoadedChunks(List blocks, int max, int yLevelThreshold) { + public List scanLoadedChunks(List blocks, int max, int yLevelThreshold, int maxSearchRadius) { if (blocks.contains(null)) { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString()); } @@ -51,6 +52,7 @@ public enum WorldScanner implements Helper { } ChunkProviderClient chunkProvider = world().getChunkProvider(); + int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius; int playerChunkX = playerFeet().getX() >> 4; int playerChunkZ = playerFeet().getZ() >> 4; int playerY = playerFeet().getY(); @@ -105,7 +107,7 @@ public enum WorldScanner implements Helper { } if ((allUnloaded && foundChunks) || res.size() >= max - || (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY)) + || (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY)) ) { return res; }