From af875aaca09df0fa8a70dab0f4a714540764c1a6 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Sun, 26 Jul 2020 17:29:59 +0200 Subject: [PATCH] Fix shape beign stuck (#83) --- .../chunkmaster/lib/generation/DefaultGenerationTask.kt | 3 ++- src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt | 2 +- src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/DefaultGenerationTask.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/DefaultGenerationTask.kt index 2c96430..4880f7a 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/DefaultGenerationTask.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/DefaultGenerationTask.kt @@ -85,7 +85,8 @@ class DefaultGenerationTask( do { lastChunkCoords = nextChunkCoordinates count = shape.count - } while (PaperLib.isChunkGenerated(world, lastChunkCoords.x, lastChunkCoords.z)) + println(count) + } while (PaperLib.isChunkGenerated(world, lastChunkCoords.x, lastChunkCoords.z) && !borderReached()) } /** diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt index a410228..2546b04 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt @@ -52,7 +52,7 @@ class Circle(center: Pair, start: Pair, radius: Int) : Shape } if (count == 0 && currentPos != center) { val tmpCircle = Circle(center, center, radius) - while (tmpCircle.next() != currentPos); + while (tmpCircle.next() != currentPos && !tmpCircle.endReached()); this.count = tmpCircle.count this.r = tmpCircle.r } diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt index 7f4e345..9564ca6 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt @@ -39,7 +39,7 @@ class Spiral(center: Pair, start: Pair, radius: Int): Shape( if (count == 0 && currentPos != center) { // simulate the spiral to get the correct direction and count val simSpiral = Spiral(center, center, radius) - while (simSpiral.next() != currentPos); + while (simSpiral.next() != currentPos && !simSpiral.endReached()); direction = simSpiral.direction count = simSpiral.count }