Overhaul the config and start adding summary options

also:
- add DH vs MC lighting engine option
- add a toggle for wireframe rendering
This commit is contained in:
James Seibel
2023-06-07 22:59:49 -05:00
parent ae269b3a74
commit 72c9de354e
16 changed files with 86 additions and 99 deletions
@@ -19,7 +19,9 @@
package com.seibel.lod.common.wrappers.chunk;
import com.seibel.lod.api.enums.config.ELightGenerationMode;
import com.seibel.lod.common.wrappers.block.BlockStateWrapper;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.pos.DhBlockPos;
import com.seibel.lod.core.pos.DhChunkPos;
import com.seibel.lod.core.pos.Pos2D;
@@ -56,6 +58,9 @@ public class ChunkWrapper implements IChunkWrapper
private final LevelReader lightSource;
private final ILevelWrapper wrappedLevel;
private final boolean useMcLightingEngine;
private final boolean isDhGeneratedChunk;
private final HashMap<BlockPos, BlockState> blockStateByBlockPosCache = new HashMap<>();
@@ -66,6 +71,10 @@ public class ChunkWrapper implements IChunkWrapper
this.lightSource = lightSource;
this.wrappedLevel = wrappedLevel;
this.chunkPos = new DhChunkPos(chunk.getPos().x, chunk.getPos().z);
this.useMcLightingEngine = (Config.Client.Advanced.WorldGenerator.lightingEngine.get() == ELightGenerationMode.MINECRAFT);
// TODO is this the best way to differentiate between when we are generating chunks and when MC gave us a chunk?
this.isDhGeneratedChunk = (this.lightSource.getClass() == LightedWorldGenRegion.class);
}
@@ -164,18 +173,19 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getBlockLight(int x, int y, int z)
{
// TODO is this the best way to differentiate between when we are generating chunks and when MC gave us a chunk?
if (this.lightSource.getClass() != LightedWorldGenRegion.class)
// use the full lighting engine when the chunks are within render distance or the config requests it
if (this.useMcLightingEngine || !this.isDhGeneratedChunk)
{
// FIXME this returns 0 if the chunks unload
// MC lighting method
// (used when the chunks are within render distance)
return this.lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x+this.getMinX(), y, z+this.getMinZ()));
}
else
{
// DH lighting method
return this.getMaxBlockLightAtBlockPos(new DhBlockPos(x, y, z));
}
}
}
/**
* Note: this doesn't take into account blocks outside this chunk's borders <br>
@@ -230,11 +240,12 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getSkyLight(int x, int y, int z)
{
// TODO is this the best way to differentiate between when we are generating chunks and when MC gave us a chunk?
if (this.lightSource.getClass() != LightedWorldGenRegion.class)
// use the full lighting engine when the chunks are within render distance or the config requests it
if (this.useMcLightingEngine || !this.isDhGeneratedChunk)
{
// FIXME this returns 0 if the chunks unload
// MC lighting method
// (used when the chunks are within render distance)
return this.lightSource.getBrightness(LightLayer.SKY, new BlockPos(x+this.getMinX(), y, z+this.getMinZ()));
}
else
@@ -219,7 +219,8 @@ public class ClassicConfigGUI {
ConfigBase.INSTANCE.configFileINSTANCE.loadFromFile();
// Changelog button
if (Config.Client.AutoUpdater.enableAutoUpdater.get()) {
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get())
{
this.addBtn(new TexturedButtonWidget(
// Where the button is on the screen
this.width - 28, this.height - 28,
@@ -94,7 +94,7 @@ public class UpdateModScreen extends Screen {
);
this.addBtn( // Silent update
new Button(this.width / 2 - 75, this.height / 2 + 30, 150, 20, translate(ModInfo.ID + ".updater.silent"), (btn) -> {
Config.Client.AutoUpdater.promptForUpdate.set(false);
Config.Client.Advanced.AutoUpdater.automaticallyUpdate.set(true);
SelfUpdater.updateMod();
this.onClose();
})
@@ -106,7 +106,7 @@ public class UpdateModScreen extends Screen {
);
this.addBtn( // Never
new Button(this.width / 2 - 102, this.height / 2 + 70, 100, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> {
Config.Client.AutoUpdater.enableAutoUpdater.set(false);
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.set(false);
this.onClose();
})
);
@@ -88,13 +88,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
public static final ConfigBasedSpamLogger PREF_LOGGER =
new ConfigBasedSpamLogger(LogManager.getLogger("LodWorldGen"),
() -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenPerformance.get(),1);
() -> Config.Client.Advanced.Logging.logWorldGenPerformance.get(),1);
public static final ConfigBasedLogger EVENT_LOGGER =
new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
() -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenEvent.get());
() -> Config.Client.Advanced.Logging.logWorldGenEvent.get());
public static final ConfigBasedLogger LOAD_LOGGER =
new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
() -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenLoadEvent.get());
() -> Config.Client.Advanced.Logging.logWorldGenLoadEvent.get());
//TODO: Make actual proper support for StarLight
@@ -234,7 +234,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
if (!unsafeThreadingRecorded && !future.isDone())
{
EVENT_LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
EVENT_LOGGER.error("Unsafe MultiThreading in Chunk Generator: ", new RuntimeException("Concurrent future"));
EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
unsafeThreadingRecorded = true;
}
@@ -298,7 +298,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
if (unknownExceptionCount > EXCEPTION_COUNTER_TRIGGER) {
EVENT_LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
unknownExceptionCount = 0;
Config.Client.WorldGenerator.enableDistantGeneration.set(false);
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
}
}
@@ -396,7 +396,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
genEvent.refreshTimeout();
region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks,
ChunkStatus.STRUCTURE_STARTS, refSize/2, genEvent.lightMode, generator);
ChunkStatus.STRUCTURE_STARTS, refSize/2, generator);
adaptor.setRegion(region);
genEvent.threadedParam.makeStructFeat(region, params);
genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION,
@@ -445,7 +445,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
genEvent.resultConsumer.accept(wrappedChunk);
}
if (genEvent.lightMode == ELightGenerationMode.FANCY || isFull)
if (isFull)
{
lightEngine.retainData(target.getPos(), false);
}
@@ -547,32 +547,37 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
finally
{
genEvent.timer.nextEvent("light");
switch (region.lightMode)
boolean useMinecraftLightingEngine = Config.Client.Advanced.WorldGenerator.lightingEngine.get() == ELightGenerationMode.MINECRAFT;
if (useMinecraftLightingEngine)
{
case FANCY:
// generates chunk lighting using MC's methods
if (!Thread.interrupted())
{
stepLight.generateGroup(region.getLightEngine(), chunksToGenerate);
this.stepLight.generateGroup(region.getLightEngine(), chunksToGenerate);
}
break;
case FAST:
}
else
{
// ignores lighting
chunksToGenerate.forEach((chunk) ->
{
if (chunk instanceof ProtoChunk)
{
chunk.setLightCorrect(true); // TODO why are we checking instanceof ProtoChunk?
}
#if POST_MC_1_18_1
#if POST_MC_1_18_1
if (chunk instanceof LevelChunk)
{
LevelChunk levelChunk = (LevelChunk) chunk;
levelChunk.setLightCorrect(true);
levelChunk.setClientLightReady(true);
}
#endif
#endif
});
break;
}
genEvent.refreshTimeout();
@@ -46,7 +46,6 @@ public final class GenerationEvent
public final DhChunkPos minPos;
public final int size;
public final EDhApiWorldGenerationStep targetGenerationStep;
public final ELightGenerationMode lightMode;
public EventTimer timer = null;
public long inQueueTime;
public long timeoutTime = -1;
@@ -64,7 +63,6 @@ public final class GenerationEvent
this.size = size;
this.targetGenerationStep = targetGenerationStep;
this.threadedParam = ThreadedParameters.getOrMake(generationGroup.params);
this.lightMode = Config.Client.WorldGenerator.lightGenerationMode.get();
this.resultConsumer = resultConsumer;
}
@@ -62,7 +62,6 @@ public class LightedWorldGenRegion extends WorldGenRegion
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
public final WorldGenLevelLightEngine light;
public final ELightGenerationMode lightMode;
public final EmptyChunkGenerator generator;
public final int writeRadius;
public final int size;
@@ -92,17 +91,16 @@ public class LightedWorldGenRegion extends WorldGenRegion
#endif
public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
List<ChunkAccess> list, ChunkStatus chunkStatus, int i,
ELightGenerationMode lightMode, EmptyChunkGenerator generator)
List<ChunkAccess> chunkList, ChunkStatus chunkStatus, int writeRadius,
EmptyChunkGenerator generator)
{
super(serverLevel, list #if POST_MC_1_17_1, chunkStatus, i #endif);
this.lightMode = lightMode;
this.firstPos = list.get(0).getPos();
super(serverLevel, chunkList #if POST_MC_1_17_1, chunkStatus, writeRadius #endif);
this.firstPos = chunkList.get(0).getPos();
this.generator = generator;
light = lightEngine;
writeRadius = i;
cache = list;
size = Mth.floor(Math.sqrt(list.size()));
this.light = lightEngine;
this.writeRadius = writeRadius;
this.cache = chunkList;
this.size = Mth.floor(Math.sqrt(chunkList.size()));
}
#if POST_MC_1_17_1
@@ -258,52 +256,15 @@ public class LightedWorldGenRegion extends WorldGenRegion
/** Overriding allows us to use our own lighting engine */
@Override
public LevelLightEngine getLightEngine() {
return light;
}
/** Overriding allows us to use our own lighting engine */
@Override
public int getBrightness(LightLayer lightLayer, BlockPos blockPos)
{
if (this.lightMode != ELightGenerationMode.FAST)
{
// MC lighting method
return this.light.getLayerListener(lightLayer).getLightValue(blockPos);
}
else
{
// Fallback DH lighting methods
if (lightLayer == LightLayer.BLOCK)
{
return 0;
}
else
{
BlockPos heightmapPos = super.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos);
return (heightmapPos.getY() <= blockPos.getY()) ? this.getMaxLightLevel() : 0;
}
}
}
public LevelLightEngine getLightEngine() { return this.light; }
/** Overriding allows us to use our own lighting engine */
@Override
public int getRawBrightness(BlockPos blockPos, int i)
{
if (this.lightMode != ELightGenerationMode.FAST)
{
// MC lighting method
return this.light.getRawBrightness(blockPos, i);
}
else
{
// Fallback DH lighting methods
BlockPos heightmapPos = super.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos);
return (heightmapPos.getY() <= blockPos.getY()) ? this.getMaxLightLevel() : 0;
}
}
public int getBrightness(LightLayer lightLayer, BlockPos blockPos) { return this.light.getLayerListener(lightLayer).getLightValue(blockPos); }
/** Overriding allows us to use our own lighting engine */
@Override
public int getRawBrightness(BlockPos blockPos, int i) { return this.light.getRawBrightness(blockPos, i); }
/** Overriding allows us to use our own lighting engine */
@Override
@@ -51,7 +51,7 @@ public class FabricMain
LOGGER.info("Post-Initializing Mod");
FabricDependencySetup.runDelayedSetup();
if (Config.Client.Graphics.FogQuality.disableVanillaFog.get() && SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib"))
if (Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get() && SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib"))
ModAccessorInjector.INSTANCE.get(IBCLibAccessor.class).setRenderCustomFog(false); // Remove BCLib's fog
LOGGER.info("Mod Post-Initialized");
@@ -63,7 +63,7 @@ public class MixinFogRenderer {
Entity entity = camera.getEntity();
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
if (!isSpecialFog && cameraNotInFluid && fogMode == FogMode.FOG_TERRAIN
&& Config.Client.Graphics.FogQuality.disableVanillaFog.get())
&& Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get())
{
#if PRE_MC_1_17_1
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
@@ -106,7 +106,8 @@ public class MixinLevelRenderer
//
// ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
// }
if (Config.Client.Advanced.lodOnlyMode.get()) {
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
{
callback.cancel();
}
}
@@ -27,24 +27,28 @@ public class MixinMinecraft
method = "<init>(Lnet/minecraft/client/main/GameConfig;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V")
)
public void onOpenScreen(Minecraft instance, Screen guiScreen) {
if (!Config.Client.AutoUpdater.enableAutoUpdater.get()) { // Don't do anything if the user doesn't want it
public void onOpenScreen(Minecraft instance, Screen guiScreen)
{
if (!Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get())
{
// Don't do anything if the user doesn't want it
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
return;
}
if (SelfUpdater.onStart()) {
if (SelfUpdater.onStart())
{
instance.setScreen(new UpdateModScreen(
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion())
));
} else {
}
else
{
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
}
}
@Inject(at = @At("HEAD"), method = "close()V")
public void close(CallbackInfo ci) {
SelfUpdater.onClose();
}
public void close(CallbackInfo ci) { SelfUpdater.onClose(); }
}
@@ -17,7 +17,7 @@ public class MixinTextureUtil {
@Redirect(method = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V", remap=false))
private static void setLodBias(int target, int pname, float param) {
float biasValue = Config.Client.Graphics.AdvancedGraphics.lodBias.get().floatValue();
float biasValue = Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias.get().floatValue();
if (biasValue != 0) {
// The target is GL11.GL_TEXTURE_2D
// And the pname is GL14.GL_TEXTURE_LOD_BIAS
@@ -64,7 +64,7 @@ public class MixinFogRenderer {
Entity entity = camera.getEntity();
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
if (!isSpecialFog && cameraNotInFluid && fogMode == FogMode.FOG_TERRAIN
&& Config.Client.Graphics.FogQuality.disableVanillaFog.get())
&& Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get())
{
#if PRE_MC_1_17_1
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
@@ -114,7 +114,9 @@ public class MixinLevelRenderer
ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
if (Config.Client.Advanced.lodOnlyMode.get()) {
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
{
callback.cancel();
}
}
@@ -27,8 +27,11 @@ public class MixinMinecraft
method = "<init>(Lnet/minecraft/client/main/GameConfig;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V")
)
public void onOpenScreen(Minecraft instance, Screen guiScreen) {
if (!Config.Client.AutoUpdater.enableAutoUpdater.get()) { // Don't do anything if the user doesn't want it
public void onOpenScreen(Minecraft instance, Screen guiScreen)
{
if (!Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get())
{
// Don't do anything if the user doesn't want it
instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened
return;
}
@@ -16,8 +16,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public class MixinTextureUtil {
@Redirect(method = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V", remap=false))
private static void setLodBias(int target, int pname, float param) {
float biasValue = Config.Client.Graphics.AdvancedGraphics.lodBias.get().floatValue();
private static void setLodBias(int target, int pname, float param)
{
float biasValue = Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias.get().floatValue();
if (biasValue != 0) {
// The target is GL11.GL_TEXTURE_2D
// And the pname is GL14.GL_TEXTURE_LOD_BIAS