From 4f07d655d6b88247c811a14961b8366c63e3f704 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Sep 2018 15:08:21 -0700 Subject: [PATCH] don't scan empty --- src/main/java/baritone/behavior/impl/MineBehavior.java | 8 +++++++- src/main/java/baritone/chunk/WorldScanner.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/impl/MineBehavior.java b/src/main/java/baritone/behavior/impl/MineBehavior.java index bbd1c594..d4b09b7b 100644 --- a/src/main/java/baritone/behavior/impl/MineBehavior.java +++ b/src/main/java/baritone/behavior/impl/MineBehavior.java @@ -70,6 +70,7 @@ public class MineBehavior extends Behavior { public static List scanFor(List mining, int max) { List locs = new ArrayList<>(); List uninteresting = new ArrayList<>(); + //long b = System.currentTimeMillis(); for (String m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(ChunkPacker.stringToBlock(m))) { locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(m, 1, 1)); @@ -77,7 +78,12 @@ public class MineBehavior extends Behavior { uninteresting.add(m); } } - locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + //System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms"); + if (!uninteresting.isEmpty()) { + //long before = System.currentTimeMillis(); + locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max)); + //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); + } BlockPos playerFeet = MineBehavior.INSTANCE.playerFeet(); locs.sort(Comparator.comparingDouble(playerFeet::distanceSq)); diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java index 62e20944..fe3c0ea5 100644 --- a/src/main/java/baritone/chunk/WorldScanner.java +++ b/src/main/java/baritone/chunk/WorldScanner.java @@ -39,6 +39,9 @@ public enum WorldScanner implements Helper { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString()); } LinkedList res = new LinkedList<>(); + if (asBlocks.isEmpty()) { + return res; + } ChunkProviderClient chunkProvider = world().getChunkProvider(); int playerChunkX = playerFeet().getX() >> 4;