diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldRemoteGenerationQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldRemoteGenerationQueue.java index 235c65a9d..e06204bfc 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldRemoteGenerationQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldRemoteGenerationQueue.java @@ -51,6 +51,8 @@ public class WorldRemoteGenerationQueue implements IWorldGenerationQueue, IDebug private final AtomicInteger finishedRequests = new AtomicInteger(); private final AtomicInteger failedRequests = new AtomicInteger(); + private final Set alreadyGeneratedPosHashSet = ConcurrentHashMap.newKeySet(); + public WorldRemoteGenerationQueue(ClientNetworkState networkState, IDhClientLevel level) { this.networkState = networkState; @@ -75,6 +77,15 @@ public class WorldRemoteGenerationQueue implements IWorldGenerationQueue, IDebug { LodUtil.assertTrue(sectionPos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL, "Only highest-detail sections are allowed."); + // check if this is a duplicate generation task + if (this.alreadyGeneratedPosHashSet.contains(sectionPos)) + { + // temporary solution to prevent generating the same section multiple times + LOGGER.trace("Duplicate generation section " + sectionPos + ". Skipping..."); + return CompletableFuture.completedFuture(WorldGenResult.CreateFail()); + } + this.alreadyGeneratedPosHashSet.add(sectionPos); + WorldGenQueueEntry entry = new WorldGenQueueEntry(new CompletableFuture<>(), tracker); waitingTasks.put(sectionPos, entry); return entry.future; @@ -149,6 +160,7 @@ public class WorldRemoteGenerationQueue implements IWorldGenerationQueue, IDebug entry.future.cancel(false); if (entry.request != null) entry.request.cancel(false); + alreadyGeneratedPosHashSet.remove(pos); } } }