From ab70c67a4fbd758754c9f054bb518315fec05d3e Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 27 Sep 2026 07:26:11 +0200 Subject: [PATCH] Draw the title panorama behind Saturn screens on 1.21.6+ The call was commented out on 1.21.6+ (#30). From 1.21.6 CubeMapRenderer draws from one cube map texture instead of six face textures, and it crashes ("Texture view does not exist") if that texture isn't loaded. Saturn's preload registered the six faces, and the vanilla registerTextures only stores the cube map for the next resource reload, which has already run by the time preload does. - preload registers a CubemapTexture for the panorama through the TextureManager overload that loads it immediately, on 1.21.6+. Before 1.21.6 it registers the six faces as before. - The panorama is only drawn once preload has run, which also covers the splash overlay drawing the title menu on its first frames. - 1.21.6+'s RotatingCubeMapRenderer.render has no opacity, so the panorama is fully opaque there. The background blur stays 1.21.5-only (TODO, #23). Co-Authored-By: Claude Opus 5.5 --- .../impl/ui/SaturnScreenFabric.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java index 62a93a8..ece14a2 100644 --- a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java +++ b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java @@ -14,6 +14,12 @@ import net.minecraft.client.gui.CubeMapRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.RotatingCubeMapRenderer; import net.minecraft.client.gui.screen.Screen; +//? if >=1.21.6 { +import net.minecraft.client.texture.CubemapTexture; +//?} else { +/*import net.minecraft.client.texture.ResourceTexture; +import net.minecraft.client.texture.TextureManager; +*///?} //? if >=1.21.9 import net.minecraft.client.input.KeyInput; //? if <1.21.6 { @@ -21,8 +27,6 @@ import net.minecraft.client.input.KeyInput; import net.minecraft.client.render.DefaultFramebufferSet; import net.minecraft.client.util.Pool; *///?} -import net.minecraft.client.texture.ResourceTexture; -import net.minecraft.client.texture.TextureManager; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -41,14 +45,25 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { //private final Pool pool = new Pool(3); public final SaturnScreen screen; + /** Whether the panorama's textures are loaded; it isn't drawn before (e.g. under the splash). */ + private static volatile boolean panoramaReady = false; + public static void preload(MinecraftClient client) { - TextureManager textureManager = client.getTextureManager(); + //? if >=1.21.6 { + // From 1.21.6 CubeMapRenderer draws from one cube map texture made of panorama_0..5.png. + // CubeMapRenderer.registerTextures only stores it for the next resource reload, which has + // already happened by now, so register it through the overload that loads it right away. + client.getTextureManager().registerTexture(PANORAMA, new CubemapTexture(PANORAMA)); + //?} else { + /*TextureManager textureManager = client.getTextureManager(); for (int i = 0; i < 6; i++) { String var10001 = PANORAMA.getPath(); Identifier tex = PANORAMA.withPath(var10001 + "_" + i + ".png"); ResourceTexture resourceTexture = new ResourceTexture(tex); textureManager.registerTexture(tex, resourceTexture); } + *///?} + panoramaReady = true; } public SaturnScreenFabric(SaturnScreen screen) { @@ -74,13 +89,18 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { mouseX *= 2; mouseY *= 2; - // TODO: the panorama and the background blur (screen.backgroundBlur) are only drawn before - // 1.21.6 so far. See also issue #23. - if (client.world == null && client.getCurrentServerEntry() == null) { - //? if <1.21.6 + // From 1.21.6 the panorama renderer has no opacity (and takes no delta), so it's drawn fully + // opaque there. + if (panoramaReady && client.world == null && client.getCurrentServerEntry() == null) { + //? if >=1.21.6 { + ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, true); + //?} else //ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, screen.backgroundOpacity, delta); } + // TODO: the background blur (screen.backgroundBlur) is only drawn before 1.21.6 so far. See + // also issue #23. + //? if <1.21.6 { /*PostEffectProcessor postEffectProcessor = this.client.getShaderLoader().loadPostEffect( Identifier.ofVanilla("blur"),