diff --git a/build.gradle b/build.gradle index f33da808e..f326b9a3b 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,21 @@ dependencies { // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.16.5-36.1.0' - + + + // these were added to hopefully allow for cloning + // configuredFeatures to allow for safe + // multi threaded feature generation. Sadly I couldn't find + // a way to duplicate lambda functions (which features use) + // so for now I'm not sure what to do. + //implementation 'io.github.kostaskougios:cloning:1.10.3' + // + //implementation ('com.esotericsoftware:kryo:5.1.1') { + // exclude group: "org.objenesis" + //} + //implementation 'org.objenesis:objenesis:3.2' + + // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version" 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 948b92338..17a769e4e 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java @@ -397,27 +397,15 @@ public class LodChunkGenWorker implements IWorker { for(Supplier> featureSupplier : featuresForState.get(featureStateToGenerate)) { - ConfiguredFeature configuredfeature = featureSupplier.get(); + ConfiguredFeature configuredFeature = featureSupplier.get(); - if (configuredFeaturesToAvoid.containsKey(configuredfeature.hashCode())) + if (configuredFeaturesToAvoid.containsKey(configuredFeature.hashCode())) continue; - /* - // clone any items that aren't thread safe to prevent - // them from causing issues - if(configuredfeature.config.getClass() == BlockClusterFeatureConfig.class) - { - config = cloneBlockClusterFeatureConfig((BlockClusterFeatureConfig) configuredfeature.config); - } - else if (configuredfeature.config.getClass() == DecoratedFeatureConfig.class) - { - config = cloneDecoratedFeatureConfig((DecoratedFeatureConfig) configuredfeature.config); - } - */ try { - configuredfeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition()); + configuredFeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition()); } catch(ConcurrentModificationException e) { @@ -425,13 +413,14 @@ public class LodChunkGenWorker implements IWorker // except pray that it doesn't effect the normal world generation // in any harmful way + // Issue #35 // I tried cloning the config for each feature, but that // path was blocked since I can't clone lambda methods. // I tried using a deep cloning library and discovered // the problem there. // ( https://github.com/kostaskougios/cloning ) - configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(UnsupportedOperationException e) @@ -440,7 +429,7 @@ public class LodChunkGenWorker implements IWorker // isn't able to return something that a feature // generator needs - configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(Exception e) @@ -454,7 +443,7 @@ public class LodChunkGenWorker implements IWorker //ClientProxy.LOGGER.error("error class: \"" + configuredfeature.config.getClass() + "\""); System.out.println(); - configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); + configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature); // ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 2e02bfdcc..e467abbee 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -42,6 +42,8 @@ public net.minecraft.world.gen.feature.ConfiguredFeature func_242765_a(Lnet/mine public net.minecraft.world.server.ServerChunkProvider field_217244_j # dataStorage public net.minecraft.world.lighting.WorldLightManager field_215576_a # blockEngine public net.minecraft.world.lighting.WorldLightManager field_215577_b # skyEngine +public net.minecraft.world.gen.feature.Feature field_236290_a_ # configuredCodec + #=====================#