Bring back the drawLODs config

This commit is contained in:
James Seibel
2021-09-26 08:20:37 -05:00
parent 391c99fd21
commit a76436b73d
3 changed files with 39 additions and 31 deletions
@@ -33,6 +33,7 @@ import com.seibel.lod.enums.DistanceQualityDropOff;
import com.seibel.lod.enums.FogDistance;
import com.seibel.lod.enums.FogDrawOverride;
import com.seibel.lod.enums.GenerationPriority;
import com.seibel.lod.enums.HorizontalQuality;
import com.seibel.lod.enums.HorizontalResolution;
import com.seibel.lod.enums.LodTemplate;
import com.seibel.lod.enums.VerticalQuality;
@@ -46,7 +47,7 @@ import net.minecraftforge.fml.config.ModConfig;
* This handles any configuration the user has access to.
*
* @author James Seibel
* @version 9-24-2021
* @version 9-26-2021
*/
@Mod.EventBusSubscriber
public class LodConfig
@@ -79,6 +80,8 @@ public class LodConfig
public static class Graphics
{
public ForgeConfigSpec.BooleanValue drawLods;
public ForgeConfigSpec.EnumValue<FogDistance> fogDistance;
public ForgeConfigSpec.EnumValue<FogDrawOverride> fogDrawOverride;
@@ -88,7 +91,7 @@ public class LodConfig
// public ForgeConfigSpec.EnumValue<ShadingMode> shadingMode;
// public ForgeConfigSpec.EnumValue<HorizontalQuality> horizontalQuality;
public ForgeConfigSpec.EnumValue<HorizontalQuality> horizontalQuality;
public ForgeConfigSpec.EnumValue<DetailDropOff> detailDropOff;
@@ -103,6 +106,13 @@ public class LodConfig
{
builder.comment("These settings control how the LODs look.").push(this.getClass().getSimpleName());
drawLods = builder
.comment("\n\n"
+ " If true, the mod is enabled and LODs will be drawn. \n"
+ " If false, the mod will still generate LODs, \n"
+ " but they won't be rendered. \n")
.define("drawLODs", true);
fogDistance = builder
.comment("\n\n"
+ " At what distance should Fog be drawn on the LODs? \n"
@@ -148,13 +158,13 @@ public class LodConfig
+ " " + HorizontalResolution.BLOCK + ": render 256 LODs for each Chunk. \n")
.defineEnum("Draw resolution", HorizontalResolution.BLOCK);
// horizontalQuality = builder
// .comment("\n\n"
// + " This indicates how quickly LODs drop off in quality. \n"
// + " " + HorizontalQuality.LOW + ": quality drops every 4 chunks. \n"
// + " " + HorizontalQuality.MEDIUM + ": quality drops every 8 chunks. \n"
// + " " + HorizontalQuality.HIGH + ": quality drops every 16 chunks. \n")
// .defineEnum("lodDrawQuality", HorizontalQuality.MEDIUM);
horizontalQuality = builder
.comment("\n\n"
+ " This indicates how quickly LODs drop off in quality. \n"
+ " " + HorizontalQuality.LOW + ": quality drops every 4 chunks. \n"
+ " " + HorizontalQuality.MEDIUM + ": quality drops every 8 chunks. \n"
+ " " + HorizontalQuality.HIGH + ": quality drops every 16 chunks. \n")
.defineEnum("lodDrawQuality", HorizontalQuality.MEDIUM);
lodChunkRenderDistance = builder
.comment("\n\n"
@@ -17,16 +17,18 @@
*/
package com.seibel.lod.mixin;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.seibel.lod.LodMain;
import com.seibel.lod.proxy.ClientProxy;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
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.mojang.blaze3d.matrix.MatrixStack;
import com.seibel.lod.LodMain;
import com.seibel.lod.config.LodConfig;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
/**
* This class is used to mix in my rendering code
* before Minecraft starts rendering blocks.
@@ -55,7 +57,7 @@ public class MixinWorldRenderer
{
// only render if LODs are enabled and
// only render before solid blocks
if (ClientProxy.drawLods && renderType.equals(RenderType.solid()))
if (LodConfig.CLIENT.graphics.drawLods.get() && renderType.equals(RenderType.solid()))
LodMain.client_proxy.renderLods(matrixStackIn, previousPartialTicks);
}
}
@@ -52,14 +52,17 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
* and is the starting point for most of the mod.
*
* @author James_Seibel
* @version 9-23-2021
* @version 9-26-2021
*/
public class ClientProxy
{
public static final Logger LOGGER = LogManager.getLogger("LOD");
/**
* there is some setup that should only happen once,
* once this is true that setup has completed
*/
private boolean firstTimeSetupComplete = false;
public static boolean drawLods = true;
private static LodWorld lodWorld = new LodWorld();
private static LodBuilder lodBuilder = new LodBuilder();
@@ -72,13 +75,9 @@ public class ClientProxy
private MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
/**
* This is used to determine if the LODs should be regenerated
*/
/** This is used to determine if the LODs should be regenerated */
public static int previousChunkRenderDistance = 0;
/**
* This is used to determine if the LODs should be regenerated
*/
/** This is used to determine if the LODs should be regenerated */
public static int previousLodRenderDistance = 0;
/**
@@ -100,6 +99,7 @@ public class ClientProxy
/**
* Do any setup that is required to draw LODs
* and then tell the LodRenderer to draw.
*
* @param mcMatrixStack
*/
public void renderLods(MatrixStack mcMatrixStack, float partialTicks)
@@ -114,11 +114,9 @@ public class ClientProxy
{
// only run the first time setup once
if (!firstTimeSetupComplete)
{
firstFrameSetup();
}
DetailDistanceUtil.updateSettings();
if (mc == null || mc.getPlayer() == null || !lodWorld.getIsWorldLoaded())
return;
@@ -126,6 +124,7 @@ public class ClientProxy
if (lodDim == null)
return;
DetailDistanceUtil.updateSettings();
viewDistanceChangedEvent();
playerMoveEvent(lodDim);
@@ -141,10 +140,7 @@ public class ClientProxy
profiler.pop(); // get out of "terrain"
profiler.push("LOD");
if(drawLods)
{
renderer.drawLODs(lodDim, mcMatrixStack, partialTicks, mc.getProfiler());
}
renderer.drawLODs(lodDim, mcMatrixStack, partialTicks, mc.getProfiler());
profiler.pop(); // end LOD
profiler.push("terrain"); // go back into "terrain"
@@ -302,7 +298,7 @@ public class ClientProxy
if(LodConfig.CLIENT.debugging.enableDebugKeybindings.get()
&& event.getKey() == GLFW.GLFW_KEY_F6 && event.getAction() == GLFW.GLFW_PRESS)
{
drawLods = !drawLods;
LodConfig.CLIENT.graphics.drawLods.set(!LodConfig.CLIENT.graphics.drawLods.get());
}
}