From c350dc127d2e6a9113d9f8ae0cde4a36726ea1d8 Mon Sep 17 00:00:00 2001 From: CookieBrigade <138534411+CookieBrigade@users.noreply.github.com> Date: Sat, 28 Sep 2024 09:48:04 -0500 Subject: [PATCH] Hopefully fix obliterating people's gpu memory --- .../tectech/thing/block/RenderForgeOfGods.java | 16 ++++++++++++++-- .../assets/tectech/shaders/star.frag.glsl | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/tectech/thing/block/RenderForgeOfGods.java b/src/main/java/tectech/thing/block/RenderForgeOfGods.java index 04c46155c04..7a38b253ef0 100644 --- a/src/main/java/tectech/thing/block/RenderForgeOfGods.java +++ b/src/main/java/tectech/thing/block/RenderForgeOfGods.java @@ -40,6 +40,7 @@ public class RenderForgeOfGods extends TileEntitySpecialRenderer { private static float modelNormalize = .0067f * 2; private static boolean initialized = false; + private static boolean failedInit = false; private static int u_Color = -1, u_ModelMatrix = -1, u_Gamma = -1; private Matrix4fStack starModelMatrix = new Matrix4fStack(3); @@ -402,13 +403,24 @@ private void RenderRings(TileEntityForgeOfGods tile, double x, double y, double @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (failedInit) return; if (!(tile instanceof TileEntityForgeOfGods forgeTile)) return; if (forgeTile.getRingCount() < 1) return; + // If something ever fails, just early return and never try again this session if (!initialized) { init(); - initRings(); - if (!initialized) return; + if (!initialized) { + failedInit = true; + return; + } + try { + initRings(); + } catch (Exception e) { + System.out.println(e.getMessage()); + failedInit = true; + return; + } } // Based on system time to prevent tps issues from causing stutters diff --git a/src/main/resources/assets/tectech/shaders/star.frag.glsl b/src/main/resources/assets/tectech/shaders/star.frag.glsl index d5a6ff894e7..8a79e093534 100644 --- a/src/main/resources/assets/tectech/shaders/star.frag.glsl +++ b/src/main/resources/assets/tectech/shaders/star.frag.glsl @@ -24,7 +24,7 @@ void main() { vec3 originalYIQ = toYIQ(texture); vec3 yiqColor = vec3(original.x,targetYIQ.yz); vec3 finalrgb = toRGB(yiqColor); - finalrgb = pow(finalrgb,vec3(1/u_Gamma)); + finalrgb = pow(finalrgb,vec3(1.0/u_Gamma)); gl_FragColor = vec4(finalrgb,u_Color.a); } }