From 2f64fef6a69532673b94b98734c5b2d1a24d68eb Mon Sep 17 00:00:00 2001 From: Ranzu <66495944+Ranzuu@users.noreply.github.com> Date: Thu, 27 Aug 2026 23:19:55 +0200 Subject: [PATCH] Fix color leak getting into guis (Broken ColorUtils) (#2045) --- .../angelica/client/font/BatchingFontRenderer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java b/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java index 76db4472c..7087e7871 100644 --- a/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/client/font/BatchingFontRenderer.java @@ -204,10 +204,19 @@ public class BatchingFontRenderer { return (argb & 0xFF000000) | (red << 16) | (green << 8) | blue; } + /** + * True only for a perspective projection (world-space text: signs, nameplates, etc). + * GUI/HUD text uses an orthographic projection and must never be shaded by world lighting - + * mods rely on getting back the exact color they requested (e.g. GTNHLib's ColorResource). + */ + private static boolean isWorldSpaceText() { + return GLStateManager.getProjectionMatrix().m33() == 0.0f; + } + private void captureLightmapState() { final int unitBinding = GLStateManager.getTextures().getTextureUnitBindings(LIGHTMAP_TEX_UNIT).getBinding(); - final boolean active = GLStateManager.getProjectionMatrix().m33() == 0.0f && unitBinding != 0; + final boolean active = isWorldSpaceText() && unitBinding != 0; float u = 0.0f; float v = 0.0f; @@ -1236,7 +1245,7 @@ public class BatchingFontRenderer { this.beginBatch(); this.captureLightmapState(); - this.lightingFactorActive = FFPVertexLighting.modulatesVertexColor(this.lightingFactor); + this.lightingFactorActive = isWorldSpaceText() && FFPVertexLighting.modulatesVertexColor(this.lightingFactor); float curX = anchorX; try { final int totalStringLength = string.length();