Disable fade rendering when immersive portals and sodium are active at once.

This commit is contained in:
Acuadragon100
2026-04-23 12:07:31 +02:00
parent 30143cbbcb
commit ca550a0a57
6 changed files with 10 additions and 103 deletions
@@ -1,95 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.logging.DhLogger;
/**
* Runtime detection and compatibility handling for Immersive Portals
*/
public class ImmersivePortalsCompat
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static volatile Boolean isImmersivePortalsPresent = null;
private static volatile Boolean isImmersivePortalsActive = null;
/**
* Check if Immersive Portals is present in the mod environment
*/
public static boolean isImmersivePortalsPresent()
{
if (isImmersivePortalsPresent == null)
{
synchronized (ImmersivePortalsCompat.class)
{
if (isImmersivePortalsPresent == null)
{
try
{
// Try to load an Immersive Portals class
Class.forName("qouteall.imm_ptl.core.IPMcHelper");
isImmersivePortalsPresent = true;
LOGGER.info("Immersive Portals detected - enabling compatibility features");
}
catch (ClassNotFoundException e)
{
isImmersivePortalsPresent = false;
LOGGER.debug("Immersive Portals not detected - using standard level management");
}
}
}
}
return isImmersivePortalsPresent;
}
/**
* Check if Immersive Portals compatibility should be active
* This checks both presence and configuration
*/
public static boolean isImmersivePortalsActive()
{
if (isImmersivePortalsActive == null)
{
synchronized (ImmersivePortalsCompat.class)
{
if (isImmersivePortalsActive == null)
{
// TODO: Add configuration check here
isImmersivePortalsActive = isImmersivePortalsPresent();
}
}
}
return isImmersivePortalsActive;
}
/**
* Reset detection cache (useful for testing)
*/
public static void resetDetection()
{
synchronized (ImmersivePortalsCompat.class)
{
isImmersivePortalsPresent = null;
isImmersivePortalsActive = null;
}
}
}
@@ -116,6 +116,7 @@ public class FabricMain extends AbstractModInitializer implements ClientModIniti
this.tryCreateModCompatAccessor("optifine", IOptifineAccessor.class, OptifineAccessor::new);
this.tryCreateModCompatAccessor("bclib", IBCLibAccessor.class, BCLibAccessor::new);
this.tryCreateModCompatAccessor("c2me", IC2meAccessor.class, C2meAccessor::new);
this.tryCreateModCompatAccessor("imm_ptl_core", IImmersivePortalsAccessor.class, ImmersivePortalsAccessor::new);
#if MC_VER >= MC_1_19_4
// 1.19.4 is the lowest version Iris supports DH
this.tryCreateModCompatAccessor("iris", IIrisAccessor.class, IrisAccessor::new);
@@ -75,8 +75,10 @@ import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapp
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
@@ -176,7 +178,7 @@ public class MixinLevelRenderer
ClientLevelWrapper wrapper = (ClientLevelWrapper) ClientApi.RENDER_STATE.clientLevelWrapper;
// Apply Immersive Portals compatibility only when IP is detected
if (com.seibel.distanthorizons.common.ImmersivePortalsCompat.isImmersivePortalsActive())
if (ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class) != null)
{
if (!wrapper.isDhLevelLoaded())
{
@@ -24,10 +24,8 @@ import com.seibel.distanthorizons.common.AbstractModInitializer;
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
import com.seibel.distanthorizons.forge.wrappers.modAccessor.ModChecker;
import com.seibel.distanthorizons.forge.wrappers.modAccessor.OptifineAccessor;
@@ -104,6 +102,7 @@ public class ForgeMain extends AbstractModInitializer
{
this.tryCreateModCompatAccessor("optifine", IOptifineAccessor.class, OptifineAccessor::new);
this.tryCreateModCompatAccessor("oculus", IIrisAccessor.class, OculusAccessor::new);
this.tryCreateModCompatAccessor("imm_ptl_core", IImmersivePortalsAccessor.class, ImmersivePortalsAccessor::new);
#if MC_VER < MC_1_17_1
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY,
@@ -244,7 +244,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
if (ClientApi.RENDER_STATE.clientLevelWrapper instanceof ClientLevelWrapper)
{
ClientLevelWrapper wrapper = (ClientLevelWrapper) ClientApi.RENDER_STATE.clientLevelWrapper;
if (ImmersivePortalsCompat.isImmersivePortalsActive())
if (ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class) != null)
{
if (!wrapper.isDhLevelLoaded())
{
@@ -274,7 +274,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
if (ClientApi.RENDER_STATE.clientLevelWrapper instanceof ClientLevelWrapper)
{
ClientLevelWrapper wrapper = (ClientLevelWrapper) ClientApi.RENDER_STATE.clientLevelWrapper;
if (ImmersivePortalsCompat.isImmersivePortalsActive())
if (ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class) != null)
{
if (!wrapper.isDhLevelLoaded())
{
@@ -301,7 +301,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
if (ClientApi.RENDER_STATE.clientLevelWrapper instanceof ClientLevelWrapper)
{
ClientLevelWrapper wrapper = (ClientLevelWrapper) ClientApi.RENDER_STATE.clientLevelWrapper;
if (ImmersivePortalsCompat.isImmersivePortalsActive())
if (ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class) != null)
{
if (!wrapper.isDhLevelLoaded())
{