diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java index 850891323..1a4a0a34e 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java @@ -53,7 +53,7 @@ import net.minecraftforge.common.WorldWorkerManager.IWorker; * This is used to generate a LodChunk at a given ChunkPos. * * @author James Seibel - * @version 7-4-2021 + * @version 7-5-2021 */ public class LodChunkGenWorker implements IWorker { @@ -87,9 +87,6 @@ public class LodChunkGenWorker implements IWorker { if (!threadStarted) { - // make sure we don't generate this chunk again - thread.lodDim.addLod(new LodChunk(thread.pos)); - thread.lodBufferBuilder.numberOfChunksWaitingToGenerate--; if (LodConfig.CLIENT.distanceGenerationMode.get() == DistanceGenerationMode.SERVER) @@ -332,7 +329,7 @@ public class LodChunkGenWorker implements IWorker snowFeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition(), null); - LodChunk lod = lodChunkBuilder.generateLodFromChunk(chunk, new LodBuilderConfig(false, true, true)); + LodChunk lod = lodChunkBuilder.generateLodFromChunk(chunk); lodDim.addLod(lod); } @@ -386,6 +383,7 @@ public class LodChunkGenWorker implements IWorker } } + boolean allowUnstableFeatures = LodConfig.CLIENT.allowUnstableFeatureGeneration.get(); // generate all the features related to this chunk. // this may or may not be thread safe @@ -399,7 +397,8 @@ public class LodChunkGenWorker implements IWorker { ConfiguredFeature configuredFeature = featureSupplier.get(); - if (configuredFeaturesToAvoid.containsKey(configuredFeature.hashCode())) + if (!allowUnstableFeatures && + configuredFeaturesToAvoid.containsKey(configuredFeature.hashCode())) continue; @@ -423,7 +422,8 @@ public class LodChunkGenWorker implements IWorker // and // https://github.com/EsotericSoftware/kryo ) - configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); + if (!allowUnstableFeatures) + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(UnsupportedOperationException e) @@ -432,7 +432,8 @@ public class LodChunkGenWorker implements IWorker // isn't able to return something that a feature // generator needs - configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); + if (!allowUnstableFeatures) + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(Exception e) @@ -445,7 +446,8 @@ public class LodChunkGenWorker implements IWorker System.out.println(); System.out.println(); - configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); + if (!allowUnstableFeatures) + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } } diff --git a/src/main/java/com/seibel/lod/handlers/LodConfig.java b/src/main/java/com/seibel/lod/handlers/LodConfig.java index 43fa3b067..800100bd8 100644 --- a/src/main/java/com/seibel/lod/handlers/LodConfig.java +++ b/src/main/java/com/seibel/lod/handlers/LodConfig.java @@ -23,7 +23,7 @@ import net.minecraftforge.fml.config.ModConfig; /** * * @author James Seibel - * @version 6-27-2021 + * @version 7-5-2021 */ @Mod.EventBusSubscriber public class LodConfig @@ -44,6 +44,8 @@ public class LodConfig public ForgeConfigSpec.EnumValue distanceGenerationMode; + public ForgeConfigSpec.BooleanValue allowUnstableFeatureGeneration; + /** this is multiplied by the default view distance * to determine how far out to generate/render LODs */ public ForgeConfigSpec.IntValue lodChunkRadiusMultiplier; @@ -99,7 +101,7 @@ public class LodConfig + " " + LodDetail.DOUBLE.toString() + ": render 4 LODs for each Chunk. \n" + " " + LodDetail.QUAD.toString() + ": render 16 LODs for each Chunk. \n" + " " + LodDetail.HALF.toString() + ": render 64 LODs for each Chunk. \n") - .defineEnum("lodGeometryQuality", LodDetail.QUAD); + .defineEnum("lodGeometryQuality", LodDetail.DOUBLE); lodChunkRadiusMultiplier = builder .comment("\n\n" @@ -153,7 +155,27 @@ public class LodConfig + " This will also show player made structures if you \n" + " are adding the mod to a pre-existing world. \n" + " Singlethreaded - Slow (15-50 ms, with spikes up to 200 ms) \n") - .defineEnum("distanceBiomeOnlyGeneration", DistanceGenerationMode.FEATURES); + .defineEnum("distanceBiomeOnlyGeneration", DistanceGenerationMode.SURFACE); + + allowUnstableFeatureGeneration = builder + .comment("\n\n" + + " When using the " + DistanceGenerationMode.FEATURES.toString() + "generation mode \n" + + " some features may not be thread safe, which could \n" + + " cause instability and crashes. \n" + + " By default (false) those features are skipped, \n" + + " improving stability, but decreasing how many features are \n" + + " actually generated. \n" + + " (for example: tree generation is a unstable feature," + + " so trees may not be generated.) \n" + + " By setting this to true, all features will be generated, \n" + + " but your game will be more unstable and crashes may occur. \n" + + " \n" + + " I would love to remove this option and always generate everything, \n" + + " but I'm not sure how to do that. \n" + + " If you are a Java wizard, check out the git issue here: \n" + + " https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/35 \n") + .define("allowUnstableFeatureGeneration", false); + builder.pop(); }