Fix fading when Sodium is installed

This commit is contained in:
James Seibel
2025-10-11 11:14:12 -05:00
parent 084de2b3f1
commit 4187eaf112
7 changed files with 14 additions and 41 deletions
@@ -293,7 +293,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
ClientApi.INSTANCE.renderDeferredLodsForShaders(ClientLevelWrapper.getWrapper();
#endif
this.clientApi.renderFade();
this.clientApi.renderFadeTransparent();
});
#endif
@@ -43,36 +43,25 @@ public class MixinChunkSectionsToRender
{
// needs to fire at HEAD otherwise it will be canceled by Sodium
@Inject(at = @At("HEAD"), method = "renderGroup")
// needs to fire at HEAD with a lower than normal order (less than 1000)
// otherwise it will be canceled by Sodium
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
private void renderDeferredLayer(ChunkSectionLayerGroup chunkSectionLayerGroup, CallbackInfo ci)
{
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
{
ClientApi.INSTANCE.renderFadeTransparent();
ClientApi.INSTANCE.renderDeferredLodsForShaders();
}
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRIPWIRE)
{
ClientApi.INSTANCE.renderFadeOpaque();
}
else if (chunkSectionLayerGroup == ChunkSectionLayerGroup.TRANSLUCENT)
{
ClientApi.INSTANCE.renderDeferredLodsForShaders();
}
}
// canceled by sodium, but there isn't a better way to handle it right now
// https://github.com/CaffeineMC/sodium/blob/dev/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/ChunkSectionsToRenderMixin.java
@Inject(at = @At("RETURN"), method = "renderGroup")
private void renderOpaqueFade(ChunkSectionLayerGroup chunkSectionLayerGroup, CallbackInfo ci)
{
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
if (chunkSectionLayerGroup == ChunkSectionLayerGroup.OPAQUE)
{
ClientApi.INSTANCE.renderFadeOpaque();
}
}
}
@@ -183,22 +183,6 @@ public class MixinLevelRenderer
}
@Inject(at = @At("RETURN"), method = "renderLevel")
private void postRenderLevel(GraphicsResourceAllocator graphicsResourceAllocator, DeltaTracker deltaTracker, boolean bl, Camera camera, Matrix4f matrix4f, Matrix4f matrix4f2, Matrix4f matrix4f3, GpuBufferSlice gpuBufferSlice, Vector4f vector4f, boolean bl2, CallbackInfo ci)
{
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
ClientApi.RENDER_STATE.frameTime = deltaTracker.getGameTimeDeltaTicks();
// only crash during development
if (ModInfo.IS_DEV_BUILD)
{
ClientApi.RENDER_STATE.canRenderOrThrow();
}
ClientApi.INSTANCE.renderFade();
}
#endif