diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt index c5ed7374..7cb4e223 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/World.kt @@ -42,6 +42,7 @@ abstract class World, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk, ChunkType : Chunk { + fun collect(boundingBox: AABBi): List { val output = ArrayList() for (pos in boundingBox.chunkPositions) { val chunk = chunkMap[pos] - if (chunk != null && chunk !in output) { + if (chunk != null && (loopX || chunkMap.x.inBoundsChunk(pos.x)) && (loopY || chunkMap.y.inBoundsChunk(pos.y))) { output.add(chunk) } } @@ -418,13 +428,13 @@ abstract class World, ChunkType : Chunk> { + fun collectPositionAware(boundingBox: AABBi): List> { val output = ArrayList>() for (pos in boundingBox.chunkPositions) { val chunk = chunkMap[pos] - if (chunk != null && !output.any { it.second === chunk }) { + if (chunk != null && (loopX || chunkMap.x.inBoundsChunk(pos.x)) && (loopY || chunkMap.y.inBoundsChunk(pos.y))) { output.add(pos to chunk) } }