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 5f356504d..89bd4bba3 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java @@ -4,13 +4,14 @@ import java.util.ConcurrentModificationException; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.Supplier; import com.seibel.lod.builders.LodBufferBuilder; -import com.seibel.lod.builders.LodChunkBuilder; import com.seibel.lod.builders.LodBuilderConfig; +import com.seibel.lod.builders.LodChunkBuilder; import com.seibel.lod.enums.DistanceGenerationMode; import com.seibel.lod.handlers.LodConfig; import com.seibel.lod.objects.LodChunk; @@ -52,7 +53,7 @@ import net.minecraftforge.common.WorldWorkerManager.IWorker; * This is used to generate a LodChunk at a given ChunkPos. * * @author James Seibel - * @version 6-27-2021 + * @version 7-4-2021 */ public class LodChunkGenWorker implements IWorker { @@ -61,6 +62,12 @@ public class LodChunkGenWorker implements IWorker private boolean threadStarted = false; private LodChunkGenThread thread; + /** If a configured feature fails for whatever reason, + * add it to this list, this is to hopefully remove any + * features that could cause issues down the line. */ + private static ConcurrentHashMap> configuredFeaturesToAvoid = new ConcurrentHashMap<>(); + + public LodChunkGenWorker(ChunkPos newPos, LodRenderer newLodRenderer, LodChunkBuilder newLodBuilder, LodBufferBuilder newLodBufferBuilder, @@ -305,7 +312,7 @@ public class LodChunkGenWorker implements IWorker List chunkList = new LinkedList<>(); ChunkPrimer chunk = new ChunkPrimer(pos, UpgradeData.EMPTY); chunkList.add(chunk); - LodServerWorld lodServerWorld = new LodServerWorld(chunk); + LodServerWorld lodServerWorld = new LodServerWorld(serverWorld, chunk); ServerChunkProvider chunkSource = serverWorld.getChunkSource(); ChunkGenerator chunkGen = chunkSource.generator; @@ -341,7 +348,7 @@ public class LodChunkGenWorker implements IWorker List chunkList = new LinkedList<>(); ChunkPrimer chunk = new ChunkPrimer(pos, UpgradeData.EMPTY); chunkList.add(chunk); - LodServerWorld lodServerWorld = new LodServerWorld(chunk); + LodServerWorld lodServerWorld = new LodServerWorld(serverWorld, chunk); ServerChunkProvider chunkSource = serverWorld.getChunkSource(); ChunkGenerator chunkGen = chunkSource.generator; @@ -381,6 +388,9 @@ public class LodChunkGenWorker implements IWorker { ConfiguredFeature configuredfeature = featureSupplier.get(); + if (configuredFeaturesToAvoid.containsKey(configuredfeature.hashCode())) + continue; + /* // clone any items that aren't thread safe to prevent // them from causing issues @@ -409,12 +419,18 @@ public class LodChunkGenWorker implements IWorker // I tried using a deep cloning library and discovered // the problem there. // ( https://github.com/kostaskougios/cloning ) + + configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); +// ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(UnsupportedOperationException e) { // This will happen when the LodServerWorld // isn't able to return something that a feature // generator needs + + configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); +// ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } catch(Exception e) { @@ -426,6 +442,9 @@ public class LodChunkGenWorker implements IWorker System.out.println(); //ClientProxy.LOGGER.error("error class: \"" + configuredfeature.config.getClass() + "\""); System.out.println(); + + configuredFeaturesToAvoid.put(configuredfeature.hashCode(), configuredfeature); +// ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount()); } } } diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java index 3d7d664b3..23ab158ab 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java @@ -50,7 +50,7 @@ import net.minecraft.world.storage.IWorldInfo; * to multithread generation. * * @author James Seibel - * @version 6-27-2021 + * @version 7-4-2021 */ public class LodServerWorld implements ISeedReader { @@ -58,9 +58,12 @@ public class LodServerWorld implements ISeedReader { public IChunk chunk; - public LodServerWorld(IChunk newChunk) + public ServerWorld serverWorld; + + public LodServerWorld(ServerWorld newServerWorld, IChunk newChunk) { chunk = newChunk; + serverWorld = newServerWorld; } @@ -102,12 +105,7 @@ public class LodServerWorld implements ISeedReader { return chunk.getFluidState(pos); } -// @Override -// public int getLightFor(LightType type, BlockPos pos) -// { -// // this needs to be low for snow generation to work -// return 0; -// } + @Override public boolean isStateAtPosition(BlockPos pos, Predicate state) @@ -122,10 +120,30 @@ public class LodServerWorld implements ISeedReader { } @Override - public IChunk getChunk(int x, int z, ChunkStatus requiredStatus, boolean nonnull) { + public IChunk getChunk(int x, int z, ChunkStatus requiredStatus, boolean nonnull) + { return chunk; } + @Override + public Stream> startsForFeature(SectionPos p_241827_1_, Structure p_241827_2_) + { + return serverWorld.startsForFeature(p_241827_1_, p_241827_2_); + } + + @Override + public ITickList getLiquidTicks() + { + return EmptyTickList.empty(); + } + + @Override + public WorldLightManager getLightEngine() + { + return new WorldLightManager(null, false, false); + } + + @@ -191,14 +209,8 @@ public class LodServerWorld implements ISeedReader { public long getSeed() { throw new UnsupportedOperationException("Not Implemented"); } + - @Override - public Stream> startsForFeature(SectionPos p_241827_1_, Structure p_241827_2_) { - throw new UnsupportedOperationException("Not Implemented"); - } - - - @Override public ServerWorld getLevel() { throw new UnsupportedOperationException("Not Implemented"); @@ -226,15 +238,7 @@ public class LodServerWorld implements ISeedReader { throw new UnsupportedOperationException("Not Implemented"); } - - - @Override - public ITickList getLiquidTicks() { - throw new UnsupportedOperationException("Not Implemented"); - } - - - + @Override public void levelEvent(PlayerEntity arg0, int arg1, BlockPos arg2, int arg3) { throw new UnsupportedOperationException("Not Implemented"); @@ -290,16 +294,8 @@ public class LodServerWorld implements ISeedReader { public DimensionType dimensionType() { throw new UnsupportedOperationException("Not Implemented"); } - - - - @Override - public WorldLightManager getLightEngine() { - throw new UnsupportedOperationException("Not Implemented"); - } - - - + + @Override public TileEntity getBlockEntity(BlockPos p_175625_1_) { throw new UnsupportedOperationException("Not Implemented"); diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index 11e855a11..040dd3849 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -48,7 +48,7 @@ import net.minecraft.util.math.vector.Vector3f; * This is where LODs are draw to the world. * * @author James Seibel - * @version 06-19-2021 + * @version 07-4-2021 */ public class LodRenderer { diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 6340723c7..2e02bfdcc 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -40,7 +40,8 @@ public net.minecraft.world.gen.feature.FeatureSpread field_242250_b # base public net.minecraft.world.gen.feature.FeatureSpread field_242251_c # spread public net.minecraft.world.gen.feature.ConfiguredFeature func_242765_a(Lnet/minecraft/world/ISeedReader;Lnet/minecraft/world/gen/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;)Z # place 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 #=====================#