Skip to content

Instantly share code, notes, and snippets.

@superblaubeere27
Last active June 9, 2020 12:29
Show Gist options
  • Save superblaubeere27/c09e4f85f1e3f0b19d3e4d7dd1313df9 to your computer and use it in GitHub Desktop.
Save superblaubeere27/c09e4f85f1e3f0b19d3e4d7dd1313df9 to your computer and use it in GitHub Desktop.
A patch for MCP (1.8 - 1.8.9) which enables GLSLSandbox MainMenu shaders
Index: src/minecraft/net/minecraft/client/gui/GuiMainMenu.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/minecraft/net/minecraft/client/gui/GuiMainMenu.java (date 1591536256953)
+++ src/minecraft/net/minecraft/client/gui/GuiMainMenu.java (date 1591536256953)
@@ -25,10 +25,12 @@
import net.minecraft.world.demo.DemoWorldServer;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.WorldInfo;
+import net.superblaubeere27.glslsandboxrenderer.GLSLSandboxShader;
import org.apache.commons.io.Charsets;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.util.glu.Project;
@@ -84,6 +86,9 @@
/** Minecraft Realms button. */
private GuiButton realmsButton;
+ private GLSLSandboxShader backgroundShader;
+ private long initTime = System.currentTimeMillis(); // Initialize as a failsafe
+
public GuiMainMenu()
{
this.openGLWarning2 = field_96138_a;
@@ -147,6 +152,12 @@
this.openGLWarning2 = I18n.format("title.oldgl2", new Object[0]);
this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
}
+
+ try {
+ this.backgroundShader = new GLSLSandboxShader("/noise.fsh");
+ } catch (IOException e) {
+ throw new IllegalStateException("Failed to load backgound shader", e);
+ }
}
/**
@@ -225,6 +236,8 @@
}
this.mc.func_181537_a(false);
+
+ initTime = System.currentTimeMillis();
}
/**
@@ -503,16 +516,28 @@
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
- GlStateManager.disableAlpha();
- this.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ GlStateManager.disableCull();
int i = 274;
int j = this.width / 2 - i / 2;
int k = 30;
- this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
- this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
+
+ this.backgroundShader.useShader(this.width, this.height, mouseX, mouseY, (System.currentTimeMillis() - initTime) / 1000f);
+
+ GL11.glBegin(GL11.GL_QUADS);
+
+ GL11.glVertex2f(-1f, -1f);
+ GL11.glVertex2f(-1f, 1f);
+ GL11.glVertex2f(1f, 1f);
+ GL11.glVertex2f(1f, -1f);
+
+ GL11.glEnd();
+
+ // Unbind shader
+ GL20.glUseProgram(0);
+
+ // Stuff enabled done by the skybox rendering
+
this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment