From 146d42bbe913ce81a57c9213dfb5a5fbc12b28aa Mon Sep 17 00:00:00 2001 From: tom lee Date: Thu, 23 Dec 2021 18:23:58 +0800 Subject: [PATCH 1/3] Fabric: Added no vanilla fog support. This isn't availible due to Forge default overrides something. Note that this noFog also won't work on custom renderer. --- .../lod/fabric/mixins/MixinFogRenderer.java | 24 +++++++++++++++++++ fabric/src/main/resources/lod.mixins.json | 1 + 2 files changed, 25 insertions(+) create mode 100644 fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java new file mode 100644 index 000000000..4b3172176 --- /dev/null +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java @@ -0,0 +1,24 @@ +package com.seibel.lod.fabric.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.seibel.lod.core.util.SingletonHandler; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; + +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.FogRenderer.FogMode; + +@Mixin(FogRenderer.class) +public class MixinFogRenderer { + private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); + + @Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V") + private static final void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) { + if (CONFIG.client().graphics().fogQuality().getDisableVanillaFog()) + FogRenderer.setupNoFog(); + } +} diff --git a/fabric/src/main/resources/lod.mixins.json b/fabric/src/main/resources/lod.mixins.json index b71c0db38..1f3b64437 100644 --- a/fabric/src/main/resources/lod.mixins.json +++ b/fabric/src/main/resources/lod.mixins.json @@ -11,6 +11,7 @@ "MixinMinecraft", "MixinOptionsScreen", "MixinWorldRenderer", + "MixinFogRenderer", "events.MixinClientLevel", "events.MixinMinecraft" ], From 6015b9a1dc6f2be3c14ca1b1ec97106f2349285e Mon Sep 17 00:00:00 2001 From: tom lee Date: Thu, 23 Dec 2021 18:26:54 +0800 Subject: [PATCH 2/3] ExperWorldGen: Increased timeout for slow CPUs --- .../common/wrappers/worldGeneration/WorldGenerationStep.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java index f15ce7851..b75e654e4 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java @@ -68,6 +68,8 @@ import net.minecraft.world.level.storage.WorldData; public final class WorldGenerationStep { + public static final int TIMEOUT_SECONDS = 30; + enum Steps { Empty, StructureStart, StructureReference, Biomes, Noise, Surface, Carvers, LiquidCarvers, Features, Light, } @@ -283,7 +285,7 @@ public final class WorldGenerationStep { } finally { iter.remove(); } - } else if (event.hasTimeout(5, TimeUnit.SECONDS)) { + } else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)) { System.err.println(event.id+": Timed out and terminated!"); try { event.terminate(); From eb4b31e8765780ea1568a001b4961f485e5e0e7b Mon Sep 17 00:00:00 2001 From: tom lee Date: Thu, 23 Dec 2021 18:28:04 +0800 Subject: [PATCH 3/3] Render: Changed rendered chunk getter to return circles --- .../minecraft/MinecraftRenderWrapper.java | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index df0959eb5..4afafe9ee 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -9,6 +9,8 @@ import com.seibel.lod.common.wrappers.misc.LightMapWrapper; import com.seibel.lod.core.handlers.IReflectionHandler; import com.seibel.lod.core.handlers.ReflectionHandler; import com.seibel.lod.core.util.LodUtil; +import com.seibel.lod.core.util.SingletonHandler; + import net.minecraft.client.renderer.LightTexture; import org.lwjgl.opengl.GL20; @@ -16,10 +18,13 @@ import com.mojang.math.Vector3f; import com.seibel.lod.core.objects.math.Mat4f; import com.seibel.lod.core.objects.math.Vec3d; import com.seibel.lod.core.objects.math.Vec3f; +import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; import com.seibel.lod.common.wrappers.McObjectConverter; +import com.seibel.lod.common.wrappers.WrapperFactory; import com.seibel.lod.common.wrappers.block.BlockPosWrapper; import com.seibel.lod.common.wrappers.chunk.ChunkPosWrapper; @@ -46,8 +51,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper private static final Minecraft MC = Minecraft.getInstance(); private static final GameRenderer GAME_RENDERER = MC.gameRenderer; - - + private static final MinecraftWrapper MC_WRAPPER = MinecraftWrapper.INSTANCE; + private static final WrapperFactory FACTORY = WrapperFactory.INSTANCE; @Override public Vec3f getLookAtVector() @@ -164,8 +169,26 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } */ - // For now, call the default method - return IMinecraftRenderWrapper.super.getVanillaRenderedChunks(); + + // For now, use a circle check + int chunkRenderDist = this.getRenderDistance(); + // if we have a odd render distance, we'll have a empty gap. This way we'll overlap by 1 instead, + // which is preferable to having a hole in the world + chunkRenderDist = chunkRenderDist % 2 == 0 ? chunkRenderDist : chunkRenderDist - 1; + + AbstractChunkPosWrapper centerChunkPos = MC_WRAPPER.getPlayerChunkPos(); + + // add every position within render distance + HashSet renderedPos = new HashSet(); + for (int chunkDeltaX = -chunkRenderDist; chunkDeltaX <= chunkRenderDist; chunkDeltaX++) + { + for(int chunkDeltaZ = -chunkRenderDist; chunkDeltaZ <= chunkRenderDist; chunkDeltaZ++) + { + if (chunkDeltaX*chunkDeltaX+chunkDeltaZ*chunkDeltaZ >= chunkRenderDist*chunkRenderDist) continue; + renderedPos.add(FACTORY.createChunkPos(centerChunkPos.getX() + chunkDeltaX, centerChunkPos.getZ() + chunkDeltaZ)); + } + } + return renderedPos; } @Override @@ -173,7 +196,26 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { // TODO: Implement this! // For now, call the default method - return IMinecraftRenderWrapper.super.getVanillaRenderedChunks(); + + // For now, use a circle check + int chunkRenderDist = this.getRenderDistance(); + // if we have a odd render distance, we'll have a empty gap. This way we'll overlap by 1 instead, + // which is preferable to having a hole in the world + chunkRenderDist = chunkRenderDist % 2 == 0 ? chunkRenderDist : chunkRenderDist - 1; + + AbstractChunkPosWrapper centerChunkPos = MC_WRAPPER.getPlayerChunkPos(); + + // add every position within render distance + HashSet renderedPos = new HashSet(); + for (int chunkDeltaX = -chunkRenderDist; chunkDeltaX <= chunkRenderDist; chunkDeltaX++) + { + for(int chunkDeltaZ = -chunkRenderDist; chunkDeltaZ <= chunkRenderDist; chunkDeltaZ++) + { + if (chunkDeltaX*chunkDeltaX+chunkDeltaZ*chunkDeltaZ >= chunkRenderDist*chunkRenderDist) continue; + renderedPos.add(FACTORY.createChunkPos(centerChunkPos.getX() + chunkDeltaX, centerChunkPos.getZ() + chunkDeltaZ)); + } + } + return renderedPos; }