Add IWorldGenerationWrapper and change SERVER generation to FULL

This commit is contained in:
James Seibel
2021-11-20 11:28:11 -06:00
parent b87f3e0c42
commit 5a170874d3
10 changed files with 56 additions and 27 deletions
@@ -92,7 +92,7 @@ public class EventApi
public void chunkLoadEvent(IChunkWrapper chunk, IDimensionTypeWrapper dimType)
{
ApiShared.lodBuilder.generateLodNodeAsync(chunk, ApiShared.lodWorld, dimType, DistanceGenerationMode.SERVER);
ApiShared.lodBuilder.generateLodNodeAsync(chunk, ApiShared.lodWorld, dimType, DistanceGenerationMode.FULL);
}
public void worldSaveEvent()
@@ -93,7 +93,7 @@ public class LodBuilder
public void generateLodNodeAsync(IChunkWrapper chunk, LodWorld lodWorld, IDimensionTypeWrapper dim)
{
generateLodNodeAsync(chunk, lodWorld, dim, DistanceGenerationMode.SERVER);
generateLodNodeAsync(chunk, lodWorld, dim, DistanceGenerationMode.FULL);
}
public void generateLodNodeAsync(IChunkWrapper chunk, LodWorld lodWorld, IDimensionTypeWrapper dim, DistanceGenerationMode generationMode)
@@ -52,7 +52,7 @@ public class LodBuilderConfig
useHeightmap = false;
useBiomeColors = false;
useSolidBlocksInColorGen = true;
distanceGenerationMode = DistanceGenerationMode.SERVER;
distanceGenerationMode = DistanceGenerationMode.FULL;
}
/**
@@ -82,7 +82,7 @@ public class LodGenWorker implements IWorker // TODO is there a way to have this
{
if (!threadStarted)
{
if (CONFIG.client().worldGenerator().getDistanceGenerationMode() == DistanceGenerationMode.SERVER)
if (CONFIG.client().worldGenerator().getDistanceGenerationMode() == DistanceGenerationMode.FULL)
{
// if we are using SERVER generation that has to be done
// synchronously to prevent crashing and harmful
@@ -155,19 +155,19 @@ public class LodGenWorker implements IWorker // TODO is there a way to have this
case BIOME_ONLY:
case BIOME_ONLY_SIMULATE_HEIGHT:
// fastest
worldGenWrapper.generateUsingBiomesOnly(pos, generationMode);
worldGenWrapper.generateBiomesOnly(pos, generationMode);
break;
case SURFACE:
// faster
worldGenWrapper.generateUsingSurface(pos);
worldGenWrapper.generateSurface(pos);
break;
case FEATURES:
// fast
worldGenWrapper.generateUsingFeatures(pos);
worldGenWrapper.generateFeatures(pos);
break;
case SERVER:
case FULL:
// very slow
worldGenWrapper.generateWithServer(pos);
worldGenWrapper.generateFull(pos);
break;
}
@@ -77,10 +77,10 @@ public enum DistanceGenerationMode
* Ask the server to generate/load each chunk.
* This is the most compatible, but causes server/simulation lag.
* This will also show player made structures if you
* are adding the mod to a pre-existing world.
* are adding the mod on a pre-existing world.
* Singlethreaded - Slow (15-50 ms, with spikes up to 200 ms)
*/
SERVER((byte) 5);
FULL((byte) 5);
/**
@@ -129,7 +129,7 @@ public class LodDimensionFileHandler
{
//there is no file for current gen mode
//search others above current from the most to the least detailed
DistanceGenerationMode tempGenMode = DistanceGenerationMode.SERVER;
DistanceGenerationMode tempGenMode = DistanceGenerationMode.FULL;
while (tempGenMode != generationMode)
{
fileName = getFileNameAndPathForRegion(regionX, regionZ, tempGenMode, tempDetailLevel, verticalQuality);
@@ -140,7 +140,7 @@ public class LodDimensionFileHandler
break;
}
//decrease gen mode
if (tempGenMode == DistanceGenerationMode.SERVER)
if (tempGenMode == DistanceGenerationMode.FULL)
tempGenMode = DistanceGenerationMode.FEATURES;
else if (tempGenMode == DistanceGenerationMode.FEATURES)
tempGenMode = DistanceGenerationMode.SURFACE;
@@ -271,7 +271,7 @@ public class DataPointUtil
long[] dataPoint = ThreadMapUtil.getVerticalDataArray(DetailDistanceUtil.getMaxVerticalData(0));
int genMode = DistanceGenerationMode.SERVER.complexity;
int genMode = DistanceGenerationMode.FULL.complexity;
boolean allEmpty = true;
boolean allVoid = true;
boolean allDefault;
@@ -446,7 +446,7 @@ public class DataPointUtil
int tempBlue = 0;
int tempLightBlock = 0;
int tempLightSky = 0;
byte tempGenMode = DistanceGenerationMode.SERVER.complexity;
byte tempGenMode = DistanceGenerationMode.FULL.complexity;
allEmpty = true;
allVoid = true;
allDefault = true;
@@ -266,8 +266,8 @@ public interface ILodConfigWrapperSingleton
+ " WARNING: This may cause world generation bugs or instability! \n"
+ " Multithreaded - Fast (15-20 ms) \n\n"
+ ""
+ " " + DistanceGenerationMode.SERVER + " \n"
+ " Ask the server to generate/load each chunk. \n"
+ " " + DistanceGenerationMode.FULL + " \n"
+ " Ask the local server to generate/load each chunk. \n"
+ " This will show player made structures, which can \n"
+ " be useful if you are adding the mod to a pre-existing world. \n"
+ " This is the most compatible, but causes server/simulation lag. \n"
@@ -0,0 +1,22 @@
package com.seibel.lod.core.wrapperAdapters.worldGeneration;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.wrapperAdapters.chunk.AbstractChunkPosWrapper;
/**
* This class contains all the information to generate
* chunks.
*
* @author James Seibel
* @version 11-20-2021
*/
public interface IWorldGeneratorWrapper
{
public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode);
public void generateSurface(AbstractChunkPosWrapper pos);
public void generateFeatures(AbstractChunkPosWrapper pos);
public void generateFull(AbstractChunkPosWrapper pos);
}
@@ -16,6 +16,7 @@ import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.chunk.AbstractChunkPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.core.wrapperAdapters.worldGeneration.IWorldGeneratorWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkWrapper;
import com.seibel.lod.wrappers.world.WorldWrapper;
@@ -43,7 +44,7 @@ import net.minecraft.world.server.ServerWorldLightManager;
* @author James Seibel
* @version 11-13-2021
*/
public class WorldGeneratorWrapper
public class WorldGeneratorWrapper implements IWorldGeneratorWrapper
{
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
@@ -73,7 +74,8 @@ public class WorldGeneratorWrapper
/** takes about 2-5 ms */
public void generateUsingBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode)
@Override
public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode)
{
List<IChunk> chunkList = new LinkedList<>();
ChunkPrimer chunk = new ChunkPrimer(((ChunkPosWrapper) pos).getChunkPos(), UpgradeData.EMPTY);
@@ -183,7 +185,8 @@ public class WorldGeneratorWrapper
/** takes about 10 - 20 ms */
public void generateUsingSurface(AbstractChunkPosWrapper pos)
@Override
public void generateSurface(AbstractChunkPosWrapper pos)
{
List<IChunk> chunkList = new LinkedList<>();
ChunkPrimer chunk = new ChunkPrimer(((ChunkPosWrapper) pos).getChunkPos(), UpgradeData.EMPTY);
@@ -223,7 +226,8 @@ public class WorldGeneratorWrapper
* Causes concurrentModification Exceptions,
* which could cause instability or world generation bugs
*/
public void generateUsingFeatures(AbstractChunkPosWrapper pos)
@Override
public void generateFeatures(AbstractChunkPosWrapper pos)
{
List<IChunk> chunkList = new LinkedList<>();
ChunkPrimer chunk = new ChunkPrimer(((ChunkPosWrapper) pos).getChunkPos(), UpgradeData.EMPTY);
@@ -334,17 +338,20 @@ public class WorldGeneratorWrapper
/**
* on pre generated chunks 0 - 1 ms
* on un generated chunks 0 - 50 ms
* with the median seeming to hover around 15 - 30 ms
* and outliers in the 100 - 200 ms range
* Generates using MC's ServerWorld.
* <p>
* on pre generated chunks 0 - 1 ms <br>
* on un generated chunks 0 - 50 ms <br>
* with the median seeming to hover around 15 - 30 ms <br>
* and outliers in the 100 - 200 ms range <br>
* <p>
* Note this should not be multithreaded and does cause server/simulation lag
* (Higher lag for generating than loading)
*/
public void generateWithServer(AbstractChunkPosWrapper pos)
@Override
public void generateFull(AbstractChunkPosWrapper pos)
{
lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(serverWorld.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FEATURES)), new LodBuilderConfig(DistanceGenerationMode.SERVER));
lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(serverWorld.getChunk(pos.getX(), pos.getZ(), ChunkStatus.FEATURES)), new LodBuilderConfig(DistanceGenerationMode.FULL));
}