mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-14 06:36:36 +01:00
Fix random infinite loop and wrong axis usage in coordinate check
This commit is contained in:
parent
58c1a98005
commit
24e92041c1
@ -280,17 +280,15 @@ public class RandomSearcher {
|
|||||||
} while (!inRange(randomLoc.getBlockX(), center.getBlockX()));
|
} while (!inRange(randomLoc.getBlockX(), center.getBlockX()));
|
||||||
do {
|
do {
|
||||||
randomLoc.setZ(center.getBlockZ() + (random.nextBoolean() ? 1 : -1) * random.nextInt(maxRadius));
|
randomLoc.setZ(center.getBlockZ() + (random.nextBoolean() ? 1 : -1) * random.nextInt(maxRadius));
|
||||||
} while (!inRange(randomLoc.getBlockZ(), center.getBlockX()));
|
} while (!inRange(randomLoc.getBlockZ(), center.getBlockZ()));
|
||||||
randomLoc.setX((randomLoc.getBlockX() >> 4) * 16);
|
randomLoc.setX((randomLoc.getBlockX() >> 4) * 16);
|
||||||
randomLoc.setZ((randomLoc.getBlockZ() >> 4) * 16);
|
randomLoc.setZ((randomLoc.getBlockZ() >> 4) * 16);
|
||||||
PaperLib.getChunkAtAsync(randomLoc, generatedOnly).thenApply(c -> {
|
PaperLib.getChunkAtAsync(randomLoc, generatedOnly).thenApply(c -> {
|
||||||
checks++;
|
checks++;
|
||||||
int startIndex = random.nextInt(RANDOM_LIST.size());
|
int indexOffset = random.nextInt(RANDOM_LIST.size());
|
||||||
Location foundLoc = null;
|
Location foundLoc = null;
|
||||||
for (int index = startIndex; index != startIndex - 1; index++) {
|
for (int i = 0; i < RANDOM_LIST.size(); i++) {
|
||||||
if (index >= RANDOM_LIST.size()) {
|
int index = (i + indexOffset) % RANDOM_LIST.size();
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
boolean validated = true;
|
boolean validated = true;
|
||||||
Location loc = randomLoc.clone().add(RANDOM_LIST.get(index)[0], 0, RANDOM_LIST.get(index)[1]);
|
Location loc = randomLoc.clone().add(RANDOM_LIST.get(index)[0], 0, RANDOM_LIST.get(index)[1]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user