aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator
diff options
context:
space:
mode:
authorBucketBrigade <138534411+CookieBrigade@users.noreply.github.com>2024-10-15 17:02:40 -0500
committerGitHub <noreply@github.com>2024-10-15 22:02:40 +0000
commitcef96f0c02376a11a41ee7b95f807e5107a99a26 (patch)
tree1cd40ebda389b7e1aaa9bfcd8212c045efbac152 /src/main/java/goodgenerator
parent1d894089d0d14efde4195afc967c9be9d3db97dd (diff)
downloadGT5-Unofficial-cef96f0c02376a11a41ee7b95f807e5107a99a26.tar.gz
GT5-Unofficial-cef96f0c02376a11a41ee7b95f807e5107a99a26.tar.bz2
GT5-Unofficial-cef96f0c02376a11a41ee7b95f807e5107a99a26.zip
Antimatter Amd fix (#3375)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/goodgenerator')
-rw-r--r--src/main/java/goodgenerator/client/render/AntimatterRenderer.java55
1 files changed, 34 insertions, 21 deletions
diff --git a/src/main/java/goodgenerator/client/render/AntimatterRenderer.java b/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
index 109b362999..a6029b6f24 100644
--- a/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
+++ b/src/main/java/goodgenerator/client/render/AntimatterRenderer.java
@@ -19,6 +19,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
import cpw.mods.fml.client.registry.ClientRegistry;
import goodgenerator.blocks.tileEntity.render.TileAntimatter;
+import gregtech.GTMod;
public class AntimatterRenderer extends TileEntitySpecialRenderer {
@@ -48,6 +49,7 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
private static final int beamVertexCount = particleCount * 6 * 6;
private boolean initialized = false;
+ private boolean hasFailed = false;
// Glowy Ring
private static ShaderProgram glowProgram;
@@ -85,14 +87,12 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
}
private void init() {
- antimatterProgram = new ShaderProgram(
- GoodGenerator.resourceDomain,
- "shaders/antimatter.vert.glsl",
- "shaders/antimatter.frag.glsl");
-
- antimatterProgram.use();
-
try {
+ antimatterProgram = new ShaderProgram(
+ GoodGenerator.resourceDomain,
+ "shaders/antimatter.vert.glsl",
+ "shaders/antimatter.frag.glsl");
+
uScale = antimatterProgram.getUniformLocation("u_Scale");
uScaleSnapshot = antimatterProgram.getUniformLocation("u_ScaleSnapshot");
uTime = antimatterProgram.getUniformLocation("u_Time");
@@ -100,11 +100,13 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
uOpacity = antimatterProgram.getUniformLocation("u_Opacity");
uColorCore = antimatterProgram.getUniformLocation("u_ColorCore");
uColorSpike = antimatterProgram.getUniformLocation("u_ColorSpike");
- } catch (NullPointerException e) {
- System.out.println(e.getMessage());
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
return;
}
+ antimatterProgram.use();
+
GL20.glUniform3f(uColorCore, TileAntimatter.coreR, TileAntimatter.coreG, TileAntimatter.coreB);
GL20.glUniform3f(uColorSpike, TileAntimatter.spikeR, TileAntimatter.spikeG, TileAntimatter.spikeB);
GL20.glUniform1f(uOpacity, 1);
@@ -113,25 +115,27 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
loadModels();
- protomatterProgram = new ShaderProgram(
- GoodGenerator.resourceDomain,
- "shaders/protomatter.vert.glsl",
- "shaders/protomatter.frag.glsl");
+ int uCubeCount = -1;
+ int uProtomatterVertices = -1;
- int uCubeCount;
- int uProtomatterVertices;
try {
+ protomatterProgram = new ShaderProgram(
+ GoodGenerator.resourceDomain,
+ "shaders/protomatter.vert.glsl",
+ "shaders/protomatter.frag.glsl");
+
uProtomatterVertices = protomatterProgram.getUniformLocation("u_Vertices");
uCubeCount = protomatterProgram.getUniformLocation("u_CubeCount");
uProtomatterTime = protomatterProgram.getUniformLocation("u_Time");
uProtomatterScale = protomatterProgram.getUniformLocation("u_Scale");
uProtomatterColor = protomatterProgram.getUniformLocation("u_Color");
uProtomatterSpiralRadius = protomatterProgram.getUniformLocation("u_SpiralRadius");
- } catch (NullPointerException e) {
- return;
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
}
protomatterProgram.use();
+
FloatBuffer bufferBeamVertexID = BufferUtils.createFloatBuffer(beamVertexCount * 3);
for (int i = 0; i < beamVertexCount; i++) {
bufferBeamVertexID.put(i * 3, i);
@@ -146,6 +150,7 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
.flip();
GL20.glUniform3(uProtomatterVertices, bufferBeamVertex);
GL20.glUniform1f(uCubeCount, particleCount);
+
ShaderProgram.clear();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
@@ -154,13 +159,16 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
GoodGenerator.resourceDomain,
"shaders/glow.vert.glsl",
"shaders/glow.frag.glsl");
- uGlowColor = glowProgram.getUniformLocation("u_Color");
- glowProgram.use();
- GL20.glUniform3f(uGlowColor, 0, 1f, 1f);
- } catch (NullPointerException e) {
+ uGlowColor = glowProgram.getUniformLocation("u_Color");
+ } catch (Exception e) {
+ GTMod.GT_FML_LOGGER.error(e.getMessage());
return;
}
+
+ glowProgram.use();
+ GL20.glUniform3f(uGlowColor, 0, 1f, 1f);
+
ShaderProgram.clear();
initialized = true;
@@ -260,12 +268,17 @@ public class AntimatterRenderer extends TileEntitySpecialRenderer {
if (!Antimatter.shouldRender) return;
+ if (hasFailed) return;
+
if (!initialized) {
init();
if (!initialized) {
+ GTMod.GT_FML_LOGGER.error("Failed to properly initialize antimatter forge render");
+ hasFailed = true;
return;
}
}
+
float tx = (float) x + 0.5f;
float ty = (float) y + 0.5f;
float tz = (float) z + 0.5f;