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 <[email protected]>
This commit is contained in:
2026-09-27 07:26:11 +02:00
co-authored by claude
parent 0a6aa90e23
commit ab70c67a4f
@@ -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"),