From c1c80f1000681e0a3ee7bb8f9d9cfe3ea33e9fa7 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sat, 11 Jun 2022 22:27:16 +0930 Subject: [PATCH] Removed most cases of LodConfigWrapperSingleton --- .../common/wrappers/block/BlockDetailWrapper.java | 6 ++---- .../common/wrappers/config/ClassicConfigGUI.java | 1 + .../BatchGenerationEnvironment.java | 15 ++++++++------- .../wrappers/worldGeneration/GenerationEvent.java | 6 ++---- core | 2 +- .../fabric/mixins/client/MixinFogRenderer.java | 2 -- .../fabric/mixins/client/MixinOptionsScreen.java | 2 -- .../fabric/wrappers/FabricDependencySetup.java | 2 -- .../seibel/lod/forge/mixins/MixinFogRenderer.java | 15 ++------------- .../lod/forge/mixins/MixinOptionsScreen.java | 5 ++--- .../lod/forge/wrappers/ForgeDependencySetup.java | 4 ---- 11 files changed, 18 insertions(+), 42 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java index f6693b567..0ebd20757 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java @@ -25,6 +25,7 @@ import java.util.Random; import com.seibel.lod.common.wrappers.McObjectConverter; import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; +import com.seibel.lod.core.config.Config; import com.seibel.lod.core.enums.ELodDirection; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.DHBlockPos; @@ -32,7 +33,6 @@ import com.seibel.lod.core.util.ColorUtil; import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -53,8 +53,6 @@ import net.minecraft.world.phys.shapes.VoxelShape; as this is never dealloc until the end of runtime!! --*/ public class BlockDetailWrapper extends IBlockDetailWrapper { - private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); - public static final int FLOWER_COLOR_SCALE = 5; public static final Random random = new Random(0); @@ -262,7 +260,7 @@ public class BlockDetailWrapper extends IBlockDetailWrapper } private BlockAndTintGetter wrapColorResolver(LevelReader level) { - int blendDistance = CONFIG.client().graphics().quality().getLodBiomeBlending(); + int blendDistance = Config.Client.Graphics.Quality.lodBiomeBlending.get(); if (blendDistance == 0) { return new TintGetterOverrideFast(level); } else { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/ClassicConfigGUI.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/ClassicConfigGUI.java index a9de05023..4a87f0f99 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/ClassicConfigGUI.java @@ -59,6 +59,7 @@ import net.minecraft.client.gui.narration.NarratableEntry; * @author coolGi * @version 4-28-2022 */ +// FLOATS DONT WORK WITH THIS @SuppressWarnings("unchecked") public abstract class ClassicConfigGUI { /* diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 7994f72b9..79883ba72 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -21,6 +21,7 @@ package com.seibel.lod.common.wrappers.worldGeneration; +import com.seibel.lod.core.config.Config; import com.seibel.lod.core.logging.ConfigBasedLogger; import com.seibel.lod.core.logging.ConfigBasedSpamLogger; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; @@ -31,7 +32,6 @@ import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.lod.LodDimension; import com.seibel.lod.core.util.gridList.ArrayGridList; import com.seibel.lod.core.util.LodThreadFactory; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper; @@ -91,16 +91,15 @@ Lod Generation: 0.269023348s public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvionmentWrapper { - private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); public static final ConfigBasedSpamLogger PREF_LOGGER = new ConfigBasedSpamLogger(LogManager.getLogger("LodWorldGen"), - () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenPerformance(),1); + () -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenPerformance.get(),1); public static final ConfigBasedLogger EVENT_LOGGER = new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"), - () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenEvent()); + () -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenEvent.get()); public static final ConfigBasedLogger LOAD_LOGGER = new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"), - () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenLoadEvent()); + () -> Config.Client.Advanced.Debugging.DebugSwitch.logWorldGenLoadEvent.get()); //TODO: Make actual proper support for StarLight @@ -256,7 +255,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } public ExecutorService executors = Executors.newFixedThreadPool( - CONFIG.client().advanced().threading()._getWorldGenerationThreadPoolSize(), threadFactory); + Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()<1 ? 1 : + (int) Math.ceil(Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get()), + threadFactory); public T joinSync(CompletableFuture f) { if (!unsafeThreadingRecorded && !f.isDone()) { @@ -338,7 +339,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().setEnableDistantGeneration(false); + Config.Client.WorldGenerator.enableDistantGeneration.set(false); } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java index 0828657ea..31fa659df 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java @@ -25,11 +25,10 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.PrefEvent; +import com.seibel.lod.core.config.Config; import com.seibel.lod.core.enums.config.ELightGenerationMode; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.util.LodUtil; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper.Steps; import net.minecraft.world.level.ChunkPos; @@ -39,7 +38,6 @@ import org.apache.logging.log4j.Logger; public final class GenerationEvent { private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName()); - private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); private static int generationFutureDebugIDs = 0; final ThreadedParameters tParam; @@ -64,7 +62,7 @@ public final class GenerationEvent id = generationFutureDebugIDs++; this.target = target; this.tParam = ThreadedParameters.getOrMake(generationGroup.params); - ELightGenerationMode mode = CONFIG.client().worldGenerator().getLightGenerationMode(); + ELightGenerationMode mode = Config.Client.WorldGenerator.lightGenerationMode.get(); this.lightMode = mode; this.genAllDetails = genAllDetails; diff --git a/core b/core index 6a15705b5..fef487f69 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 6a15705b51f24cf8d435d1067d977263690ef9a4 +Subproject commit fef487f69877d6574a3e505a8f91d06e1cf5b55a diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinFogRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinFogRenderer.java index ffa03d2f9..446898bb7 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinFogRenderer.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinFogRenderer.java @@ -26,8 +26,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.mojang.blaze3d.systems.RenderSystem; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import net.minecraft.client.Camera; import net.minecraft.client.renderer.FogRenderer; diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinOptionsScreen.java index f954df5c4..e528b0e5e 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/client/MixinOptionsScreen.java @@ -23,8 +23,6 @@ import com.seibel.lod.common.wrappers.config.GetConfigScreen; import com.seibel.lod.common.wrappers.config.TexturedButtonWidget; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import net.minecraft.client.gui.screens.OptionsScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java index 533326bc8..57856c439 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java @@ -20,8 +20,6 @@ package com.seibel.lod.fabric.wrappers; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.config.LodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker; diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinFogRenderer.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinFogRenderer.java index 991950ce0..f657387cb 100644 --- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinFogRenderer.java +++ b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinFogRenderer.java @@ -19,14 +19,13 @@ package com.seibel.lod.forge.mixins; +import com.seibel.lod.core.config.Config; 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.systems.RenderSystem; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import net.minecraft.client.Camera; import net.minecraft.client.renderer.FogRenderer; @@ -55,16 +54,6 @@ public class MixinFogRenderer remap = #if MC_1_16_5 true #else false #endif) // Remap messiness due to this being added by forge. private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback) { - ILodConfigWrapperSingleton CONFIG; - try - { - CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); - } - catch (NullPointerException e) - { - return; // May happen due to forge for some reason haven't inited out thingy yet. - } - #if PRE_MC_1_17_1 FluidState fluidState = camera.getFluidInCamera(); boolean cameraNotInFluid = fluidState.isEmpty(); @@ -76,7 +65,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().getDisableVanillaFog()) + && Config.Client.Graphics.FogQuality.disableVanillaFog.get()) { #if PRE_MC_1_17_1 RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE); diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java index c7f15f0c0..ed6ed8aca 100644 --- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java +++ b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java @@ -22,8 +22,7 @@ package com.seibel.lod.forge.mixins; import com.seibel.lod.common.wrappers.config.GetConfigScreen; import com.seibel.lod.common.wrappers.config.TexturedButtonWidget; import com.seibel.lod.core.ModInfo; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; +import com.seibel.lod.core.config.Config; import net.minecraft.client.gui.screens.OptionsScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -52,7 +51,7 @@ public class MixinOptionsScreen extends Screen { @Inject(at = @At("HEAD"),method = "init") private void lodconfig$init(CallbackInfo ci) { - if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton()) + if (Config.Client.optionsButton.get()) this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif (new TexturedButtonWidget( // Where the button is on the screen diff --git a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java index 7ca3b01d7..7611aa7b4 100644 --- a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java +++ b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java @@ -21,8 +21,6 @@ package com.seibel.lod.forge.wrappers; import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.config.LodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.forge.wrappers.modAccessor.ModChecker; @@ -41,8 +39,6 @@ public class ForgeDependencySetup public static void createInitialBindings() { SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); - - SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); } public static void finishBinding()