don't scan empty

This commit is contained in:
Leijurv 2018-09-04 15:08:21 -07:00
parent 7cc23bc89b
commit 4f07d655d6
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 10 additions and 1 deletions

View File

@ -70,6 +70,7 @@ public class MineBehavior extends Behavior {
public static List<BlockPos> scanFor(List<String> mining, int max) {
List<BlockPos> locs = new ArrayList<>();
List<String> 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);
}
}
//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));

View File

@ -39,6 +39,9 @@ public enum WorldScanner implements Helper {
throw new IllegalStateException("Invalid block name should have been caught earlier: " + blockTypes.toString());
}
LinkedList<BlockPos> res = new LinkedList<>();
if (asBlocks.isEmpty()) {
return res;
}
ChunkProviderClient chunkProvider = world().getChunkProvider();
int playerChunkX = playerFeet().getX() >> 4;