From 0c031588aa17190629bae8479ee5614c7b29170d Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 2 Sep 2022 15:14:03 +0930 Subject: [PATCH] Fixed issue #390 (problems with BCLib fog) --- 1.18.2.properties | 4 +-- .../minecraft/MinecraftRenderWrapper.java | 5 ++++ coreSubProjects | 2 +- .../main/java/com/seibel/lod/FabricMain.java | 17 +++++++++---- .../wrappers/modAccessor/BCLibAccessor.java | 25 +++++++++++++++++++ 5 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/BCLibAccessor.java diff --git a/1.18.2.properties b/1.18.2.properties index 308a8051c..96c178c03 100644 --- a/1.18.2.properties +++ b/1.18.2.properties @@ -17,7 +17,7 @@ architectury_version=4.4.59 sodium_version=mc1.18.2-0.4.1 iris_version=1.18.x-v1.2.5 immersive_portals_version = v1.0.4-1.18 - bclib_version= + bclib_version=1.4.5 # Fabric mod run # 0 = Don't enable and don't run @@ -28,7 +28,7 @@ architectury_version=4.4.59 enable_sodium=1 enable_lithium=0 enable_iris=0 - enable_bclib=0 + enable_bclib=1 # Forge loader forge_version=40.0.18 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 b9999f405..d689fe851 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 @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.objects.DHChunkPos; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; @@ -41,6 +42,8 @@ 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.minecraft.IMinecraftRenderWrapper; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.IBCLibAccessor; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import com.seibel.lod.common.wrappers.McObjectConverter; @@ -144,6 +147,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Color getFogColor(float partialTicks) { + if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib")) + return ModAccessorInjector.INSTANCE.get(IBCLibAccessor.class).getFogColor(); // BCLib uses a different fog method so we need to use that instead if they are loaded #if PRE_MC_1_17_1 float[] colorValues = new float[4]; diff --git a/coreSubProjects b/coreSubProjects index 1aaae5c1d..a5ade02de 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1aaae5c1da8b64b036cbe55a0b95f2a13c1f47d6 +Subproject commit a5ade02dec989c0be8b9e47cab94fa2dee3546cb diff --git a/fabric/src/main/java/com/seibel/lod/FabricMain.java b/fabric/src/main/java/com/seibel/lod/FabricMain.java index a0607057a..d16f805f6 100644 --- a/fabric/src/main/java/com/seibel/lod/FabricMain.java +++ b/fabric/src/main/java/com/seibel/lod/FabricMain.java @@ -23,20 +23,20 @@ import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.api.external.methods.events.abstractEvents.DhApiAfterDhInitEvent; import com.seibel.lod.core.api.external.methods.events.abstractEvents.DhApiBeforeDhInitEvent; +import com.seibel.lod.core.config.Config; import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector; import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.logging.DhLoggerBuilder; -import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; -import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; -import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; -import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.*; +import com.seibel.lod.wrappers.modAccessor.BCLibAccessor; import com.seibel.lod.wrappers.modAccessor.OptifineAccessor; import com.seibel.lod.wrappers.modAccessor.SodiumAccessor; import com.seibel.lod.wrappers.modAccessor.StarlightAccessor; import com.seibel.lod.wrappers.FabricDependencySetup; import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixins; /** * Initialize and setup the Mod.
@@ -45,7 +45,7 @@ import org.apache.logging.log4j.Logger; * * @author coolGi * @author Ran - * @version 8-15-2022 + * @version 9-2-2022 */ public class FabricMain { @@ -55,6 +55,10 @@ public class FabricMain LOGGER.info("Post-Initializing Mod"); FabricDependencySetup.runDelayedSetup(); LodCommonMain.initConfig(); + + if (Config.Client.Graphics.FogQuality.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"); } @@ -78,6 +82,9 @@ public class FabricMain if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("optifine")) { ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor()); } + if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib")) { + ModAccessorInjector.INSTANCE.bind(IBCLibAccessor.class, new BCLibAccessor()); + } LOGGER.info(ModInfo.READABLE_NAME + " Initialized"); DhApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); diff --git a/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/BCLibAccessor.java b/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/BCLibAccessor.java new file mode 100644 index 000000000..4a378bf5e --- /dev/null +++ b/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/BCLibAccessor.java @@ -0,0 +1,25 @@ +package com.seibel.lod.wrappers.modAccessor; + +import com.seibel.lod.core.wrapperInterfaces.modAccessor.IBCLibAccessor; +import ru.bclib.config.ClientConfig; +import ru.bclib.config.Configs; +import ru.bclib.util.BackgroundInfo; + +import java.awt.*; + +public class BCLibAccessor implements IBCLibAccessor { + @Override + public String getModName() { + return "BCLib"; + } + + public void setRenderCustomFog(boolean newValue) { + // Change the value of CUSTOM_FOG_RENDERING in the bclib client config + Configs.CLIENT_CONFIG.set(ClientConfig.CUSTOM_FOG_RENDERING, newValue); + } + + @Override + public Color getFogColor() { + return new Color(BackgroundInfo.fogColorRed, BackgroundInfo.fogColorGreen, BackgroundInfo.fogColorBlue); + } +} \ No newline at end of file