mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-22 10:36:00 +01:00
Return earlier if check count exceeds max tries
This commit is contained in:
parent
aa9d995e4d
commit
988f2ee736
@ -314,6 +314,11 @@ public class RandomSearcher {
|
||||
}
|
||||
|
||||
do {
|
||||
checks++;
|
||||
if (checks >= maxTries) {
|
||||
future.completeExceptionally(new NotFoundException("location"));
|
||||
return;
|
||||
}
|
||||
if (loadedOnly) {
|
||||
Chunk chunk = loadedChunks[random.nextInt(loadedChunks.length)];
|
||||
randChunkX = chunk.getX();
|
||||
@ -322,11 +327,6 @@ public class RandomSearcher {
|
||||
randChunkX = (random.nextBoolean() ? 1 : -1) * random.nextInt(maxChunk + 1);
|
||||
randChunkZ = (random.nextBoolean() ? 1 : -1) * random.nextInt(maxChunk + 1);
|
||||
}
|
||||
checks++;
|
||||
if (checks >= maxTries) {
|
||||
future.completeExceptionally(new NotFoundException("location"));
|
||||
return;
|
||||
}
|
||||
} while (!checked.put(randChunkX, randChunkZ) || !inRadius(randChunkX, randChunkZ, minChunk, maxChunk));
|
||||
|
||||
randomLoc.setX(((center.getBlockX() >> 4) + randChunkX) * 16);
|
||||
|
Loading…
Reference in New Issue
Block a user