Made foundWithinY in WorldScanner an "option"

This commit is contained in:
Brady 2018-09-20 12:21:23 -05:00
parent d0fd370d53
commit 37f00f3e14
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 12 additions and 3 deletions

View File

@ -148,7 +148,7 @@ public final class MineBehavior extends Behavior implements Helper {
}
if (!uninteresting.isEmpty()) {
//long before = System.currentTimeMillis();
locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max));
locs.addAll(WorldScanner.INSTANCE.scanLoadedChunks(uninteresting, max, 10));
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
}
return prune(locs, mining, max);

View File

@ -32,7 +32,16 @@ import java.util.List;
public enum WorldScanner implements Helper {
INSTANCE;
public List<BlockPos> scanLoadedChunks(List<Block> blocks, int max) {
/**
* Scans the world, up to your render distance, for the specified blocks.
*
* @param blocks The blocks to scan for
* @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.
* @return The matching block positions
*/
public List<BlockPos> scanLoadedChunks(List<Block> blocks, int max, int yLevelThreshold) {
if (blocks.contains(null)) {
throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString());
}
@ -84,7 +93,7 @@ public enum WorldScanner implements Helper {
if (blocks.contains(state.getBlock())) {
int yy = yReal | y;
res.add(new BlockPos(chunkX | x, yy, chunkZ | z));
if (Math.abs(yy - playerY) < 10) {
if (Math.abs(yy - playerY) < yLevelThreshold) {
foundWithinY = true;
}
}