Potential fix for splash screen crashes (#363)

* Move framebuffer static initializor to getter

* missed one

* Revert "missed one"

This reverts commit 97027c1372.

* Revert "Move framebuffer static initializor to getter"

This reverts commit 6ef65735ff.

* Initialize HudCaching on world join

* run it on the client only

* remove unused imports
This commit is contained in:
Caedis authored and GitHub committed 2024-03-08 12:40:51 -06:00
1 parent 4600bca2d0
commit 22bf48c093
1 file changed
+15 -5
@@ -3,6 +3,8 @@ package com.gtnewhorizons.angelica.hudcaching;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.eventhandler.EventPriority;
import net.minecraftforge.event.world.WorldEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
@@ -27,16 +29,14 @@ import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.client.GuiIngameForge;
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
// See LICENSE+HUDCaching.md for license information.
public class HUDCaching {
private static final Minecraft mc = Minecraft.getMinecraft();
public static Framebuffer framebuffer;
static {
framebuffer = new Framebuffer(0, 0, true);
framebuffer.setFramebufferColor(0, 0, 0, 0);
}
private static boolean dirty = true;
public static boolean renderingCacheOverride;
@@ -102,10 +102,20 @@ public class HUDCaching {
}
}
// highest so it runs before the GLSM load event
@SubscribeEvent(priority = EventPriority.HIGH)
public void onJoinWorld(WorldEvent.Load event) {
if (event.world.isRemote){
LOGGER.info("World loaded - Initializing HUDCaching");
HUDCaching.framebuffer = new Framebuffer(0, 0, true);
HUDCaching.framebuffer.setFramebufferColor(0, 0, 0, 0);
}
}
@SuppressWarnings("unused")
public static void renderCachedHud(EntityRenderer renderer, GuiIngame ingame, float partialTicks, boolean hasScreen, int mouseX, int mouseY) {
if (!OpenGlHelper.isFramebufferEnabled() || !isEnabled) {
if (!OpenGlHelper.isFramebufferEnabled() || !isEnabled || framebuffer == null) {
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
return;
}