WorldGen: Fix VersionConstants and more comments

More comments in WorldGenWrapper and fix version constants to always
return true in isWorldGeneratorSingleThreaded()
This commit is contained in:
tom lee
2021-12-12 23:28:18 +08:00
parent 50ae719f24
commit 66300cbe70
3 changed files with 12 additions and 32 deletions
@@ -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;
}
}*/
}
}
@@ -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<Integer, ConfiguredFeature<?, ?>> 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
* <p>
* 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.
* <p>
@@ -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)
+1 -1
Submodule core updated: 92b6a9695d...9e882951ef