From c0909770212011f1b5957d5cb9cd18b47d3043c4 Mon Sep 17 00:00:00 2001 From: trivernis Date: Thu, 16 Apr 2020 20:56:53 +0200 Subject: [PATCH] Revert optimizations on spigot Revert the optimizations which check if the chunk is already generated because the function doesn't report the right value. https://hub.spigotmc.org/jira/browse/SPIGOT-5541?attachmentOrder=desc --- .../lib/generation/GenerationTaskPaper.kt | 2 +- .../lib/generation/GenerationTaskSpigot.kt | 23 ++++++------------- .../chunkmaster/lib/shapes/Circle.kt | 3 +++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt index a349c07..5e8d92f 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt @@ -59,7 +59,7 @@ class GenerationTaskPaper( } } lastChunkCoords = chunk - count = shape.count // set the count to the more accurate spiral count + count = shape.count } } checkChunksLoaded() diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskSpigot.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskSpigot.kt index 8e3b64a..5dfbd10 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskSpigot.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskSpigot.kt @@ -34,26 +34,17 @@ class GenerationTaskSpigot( if (borderReachedCheck()) return var chunk = nextChunkCoordinates - for (i in 0 until chunkSkips) { - if (world.isChunkGenerated(chunk.x, chunk.z)) { - chunk = nextChunkCoordinates - } else { - break - } - } - - if (!world.isChunkGenerated(chunk.x, chunk.z)) { - for (i in 0 until chunksPerStep) { - if (borderReached()) break - val chunkInstance = world.getChunkAt(chunk.x, chunk.z) - chunkInstance.load(true) - loadedChunks.add(chunkInstance) - chunk = nextChunkCoordinates - } + for (i in 0 until chunksPerStep) { + if (borderReached()) break val chunkInstance = world.getChunkAt(chunk.x, chunk.z) chunkInstance.load(true) loadedChunks.add(chunkInstance) + chunk = nextChunkCoordinates } + val chunkInstance = world.getChunkAt(chunk.x, chunk.z) + chunkInstance.load(true) + loadedChunks.add(chunkInstance) + lastChunkCoords = chunk count = shape.count } 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 90bc9de..19aa335 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt @@ -35,6 +35,9 @@ class Circle(center: Pair, start: Pair, radius: Int): Shape( } override fun next(): Pair { + if (endReached()) { + return currentPos + } if (count == 0 && currentPos != center) { val tmpCircle = Circle(center, center, radius) while (tmpCircle.next() != currentPos);