From 66300cbe706287f807e7036717b03ed030bbacf6 Mon Sep 17 00:00:00 2001 From: tom lee Date: Sun, 12 Dec 2021 23:28:18 +0800 Subject: [PATCH] WorldGen: Fix VersionConstants and more comments More comments in WorldGenWrapper and fix version constants to always return true in isWorldGeneratorSingleThreaded() --- .../lod/common/wrappers/VersionConstants.java | 6 +++- .../WorldGeneratorWrapper.java | 36 ++++--------------- core | 2 +- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java index 99dbd20bb..bdaef2f0f 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java @@ -23,6 +23,10 @@ public class VersionConstants implements IVersionConstants { @Override public boolean isWorldGeneratorSingleThreaded(DistanceGenerationMode distanceGenerationMode) { + // We are always asking the server to generate the chunk, + // so no use running this stuff multithreaded. + return true; + /* switch (distanceGenerationMode) { default: case NONE: @@ -34,6 +38,6 @@ public class VersionConstants implements IVersionConstants { case FULL: return true; - } + }*/ } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java index 31accae17..a8dc4e2e7 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java @@ -26,18 +26,6 @@ import net.minecraft.world.level.chunk.*; */ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper { - //private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); - - /** - * If a configured feature fails for whatever reason, - * add it to this list. This will hopefully remove any - * features that could cause issues down the line. - */ - //private static final ConcurrentHashMap> FEATURES_TO_AVOID = new ConcurrentHashMap<>(); - - //private static ExecutorService Executor = Executors.newSingleThreadExecutor(); - - public final ServerLevel serverWorld; public final LodDimension lodDim; public final LodBuilder lodBuilder; @@ -51,7 +39,6 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper serverWorld = ((WorldWrapper) worldWrapper).getServerWorld(); } - /** takes about 2-5 ms */ @Override public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode) @@ -59,7 +46,6 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper generate(pos.getX(), pos.getZ(), generationMode); } - /** takes about 10 - 20 ms */ @Override public void generateSurface(AbstractChunkPosWrapper pos) @@ -67,12 +53,8 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper generate(pos.getX(), pos.getZ(), DistanceGenerationMode.SURFACE); } - /** * takes about 15 - 20 ms - *

- * Causes concurrentModification Exceptions, - * which could cause instability or world generation bugs */ @Override public void generateFeatures(AbstractChunkPosWrapper pos) @@ -80,7 +62,6 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FEATURES); } - /** * Generates using MC's ServerWorld. *

@@ -100,7 +81,7 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper private void generate(int chunkX, int chunkZ, DistanceGenerationMode generationMode) { - long t = System.nanoTime(); + // long t = System.nanoTime(); ChunkStatus targetStatus; switch (generationMode) { @@ -125,23 +106,19 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper return; } + // The bool=true means that we wants to generate chunk, and that the returned ChunkAccess must not be null ChunkAccess ca = serverWorld.getChunkSource().getChunk(chunkX, chunkZ, targetStatus, true); if (ca == null) throw new RuntimeException("This should NEVER be null due to bool being true"); lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(ca), new LodBuilderConfig(generationMode)); - long duration = System.nanoTime()-t; + // long duration = System.nanoTime()-t; - System.out.println("LodChunkGenFull["+chunkX+","+chunkZ+"]: "+(double)(duration)/1000.); + // Debug print the duration + // System.out.println("LodChunkGenFull["+chunkX+","+chunkZ+"]: "+(double)(duration)/1000.); } - - - - - - - /* + /* TODO: Update this chart * performance/generation tests related to * serverWorld.getChunk(x, z, ChunkStatus. *** ) @@ -161,7 +138,6 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper ChunkStatus.FULL 30 - 50 ms true ChunkStatus.SPAWN 50 - 80 ms true - At this point I would suggest using FEATURES, as it generates snow and trees (and any other object that are needed to make biomes distinct) diff --git a/core b/core index 92b6a9695..9e882951e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 92b6a9695da49287226f56b2706f88e24302f477 +Subproject commit 9e882951efccf9b2949a40badbe78d28735b2ebc