From f53639c0ed46cafea3526f150de454fcecbbad08 Mon Sep 17 00:00:00 2001 From: peytonplayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Sun, 10 Sep 2023 05:16:13 -0500 Subject: [PATCH] Added Shader Profiles --- .../PeytonPlayz585/shadow/gui/GuiShaders.java | 36 +++++-- .../shadow/opengl/VertexBuffer.java | 3 +- .../shadow/shaders/Shaders.java | 102 ++++++++++++++++++ .../client/settings/GameSettings.java | 67 +++++++++++- 4 files changed, 193 insertions(+), 15 deletions(-) create mode 100644 src/main/java/net/PeytonPlayz585/shadow/shaders/Shaders.java diff --git a/src/main/java/net/PeytonPlayz585/shadow/gui/GuiShaders.java b/src/main/java/net/PeytonPlayz585/shadow/gui/GuiShaders.java index 7d0f4df..44673d3 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/gui/GuiShaders.java +++ b/src/main/java/net/PeytonPlayz585/shadow/gui/GuiShaders.java @@ -2,32 +2,35 @@ package net.PeytonPlayz585.shadow.gui; import java.io.IOException; +import net.PeytonPlayz585.shadow.shaders.Shaders; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; public class GuiShaders extends GuiScreen { protected GuiScreen parentScreen; private GuiShaders.List list; - GuiButton shaderOptions = null; + GuiButton shaderProfile = null; public GuiShaders(GuiScreen screen) { this.parentScreen = screen; } public void initGui() { + GameSettings.Options shaderProfile2 = GameSettings.Options.SHADER_PROFILE; this.buttonList.clear(); int i = 120; int j = 20; - int k = this.width - i - 10; - int j1 = this.width - i - 20; + int k = width - i - 10; + int j1 = width - i - 20; int k1 = Math.min(150, j1 / 2 - 10); GuiButton button; - this.buttonList.add(new GuiButton(6, j1 / 4 * 3 - k1 / 2, this.height - 25, k1, j, I18n.format("gui.done", new Object[0]))); - this.buttonList.add(button = new GuiButton(201, j1 / 4 - k1 / 2, this.height - 25, k1, j, "Shaders Folder")); + this.buttonList.add(new GuiButton(6, j1 / 4 * 3 - k1 / 2, height - 25, k1, j, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(button = new GuiButton(201, j1 / 4 - k1 / 2, height - 25, k1, j, "Shaders Folder")); button.enabled = false; - this.buttonList.add(shaderOptions = new GuiButton(203, k, this.height - 25, i, j, "Shader Options")); - shaderOptions.enabled = Minecraft.getMinecraft().gameSettings.shaders; + this.buttonList.add(shaderProfile = new GuiOptionButton(201, k, height - 25, shaderProfile2, Minecraft.getMinecraft().gameSettings.getKeyBinding(shaderProfile2))); + shaderProfile.enabled = Minecraft.getMinecraft().gameSettings.shaders; this.list = new GuiShaders.List(this.mc); this.list.registerScrollButtons(7, 8); } @@ -40,8 +43,19 @@ public class GuiShaders extends GuiScreen { protected void actionPerformed(GuiButton parGuiButton) { if(parGuiButton.enabled) { if(parGuiButton.id == 6) { + if(Shaders.shaderProfileChanged) { + Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources(); + Minecraft.getMinecraft().refreshResources(); + } + Shaders.shaderProfileChanged = false; + Minecraft.getMinecraft().gameSettings.saveOptions(); Minecraft.getMinecraft().displayGuiScreen(parentScreen); } + + if(parGuiButton.id == 201) { + mc.gameSettings.setOptionValue(((GuiOptionButton)parGuiButton).returnEnumOptions(), 1); + parGuiButton.displayString = mc.gameSettings.getKeyBinding(GameSettings.Options.getEnumOptions(74)); + } } } @@ -49,7 +63,7 @@ public class GuiShaders extends GuiScreen { this.drawDefaultBackground(); this.list.drawScreen(i, j, f); - this.drawCenteredString(this.fontRendererObj, "Shaders", this.width / 2, 15, 16777215); + this.drawCenteredString(this.fontRendererObj, "Shaders", width / 2, 15, 16777215); super.drawScreen(i, j, f); } @@ -58,7 +72,7 @@ public class GuiShaders extends GuiScreen { java.util.Map languageMap = new java.util.HashMap<>(); public List(Minecraft mcIn) { - super(mcIn, GuiShaders.this.width - 120 - 20, GuiShaders.this.height, 30, GuiShaders.this.height - 50, 16); + super(mcIn, GuiShaders.width - 120 - 20, GuiShaders.height, 30, GuiShaders.height - 50, 16); languageMap.put(1, "OFF"); languageMap.put(2, "High Performance PBR"); @@ -80,7 +94,7 @@ public class GuiShaders extends GuiScreen { Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources(); Minecraft.getMinecraft().refreshResources(); Minecraft.getMinecraft().gameSettings.saveOptions(); - shaderOptions.enabled = false; + shaderProfile.enabled = false; GuiShaders.this.updateScreen(); } else if(i == 1 && Minecraft.getMinecraft().gameSettings.shaders) { return; @@ -89,7 +103,7 @@ public class GuiShaders extends GuiScreen { Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources(); Minecraft.getMinecraft().refreshResources(); Minecraft.getMinecraft().gameSettings.saveOptions(); - shaderOptions.enabled = true; + shaderProfile.enabled = true; GuiShaders.this.updateScreen(); } } diff --git a/src/main/java/net/PeytonPlayz585/shadow/opengl/VertexBuffer.java b/src/main/java/net/PeytonPlayz585/shadow/opengl/VertexBuffer.java index 1ed91bd..7664dac 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/opengl/VertexBuffer.java +++ b/src/main/java/net/PeytonPlayz585/shadow/opengl/VertexBuffer.java @@ -22,8 +22,7 @@ public class VertexBuffer { EaglercraftGPU.glNewList(parInt1, GL_COMPILE); VertexFormat fmt = p_181722_1_.getVertexFormat(); ByteBuffer buf = p_181722_1_.getByteBuffer(); - EaglercraftGPU.renderBuffer(buf.position(0), fmt.eaglercraftAttribBits, 7, p_181722_1_.getVertexCount()); - p_181722_1_.reset(); + EaglercraftGPU.renderBuffer(buf, fmt.eaglercraftAttribBits, 7, p_181722_1_.getVertexCount()); EaglercraftGPU.glEndList(); } } diff --git a/src/main/java/net/PeytonPlayz585/shadow/shaders/Shaders.java b/src/main/java/net/PeytonPlayz585/shadow/shaders/Shaders.java new file mode 100644 index 0000000..3162526 --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/shaders/Shaders.java @@ -0,0 +1,102 @@ +package net.PeytonPlayz585.shadow.shaders; + +import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.EaglerDeferredConfig; +import net.minecraft.client.Minecraft; + +public class Shaders { + + public static boolean shaderProfileChanged = false; + + public void updateShaderProfile(int i) { + switch (i) { + case 1: + setShaderProfileToLow(); + break; + + case 2: + setShaderProfileToMedium(); + break; + + case 3: + setShaderProfileToHigh(); + break; + + case 4: + setShaderProfileToUltra(); + break; + } + Shaders.shaderProfileChanged = true; + } + + public void setShaderProfileToLow() { + EaglerDeferredConfig conf = Minecraft.getMinecraft().gameSettings.deferredShaderConf; + conf.wavingBlocks = false; + conf.dynamicLights = false; + conf.ssao = false; + conf.shadowsSun = 16; + conf.useEnvMap = false; + conf.lensDistortion = false; + conf.lensFlares = false; + conf.fxaa = false; + conf.shadowsColored = false; + conf.shadowsSmoothed = false; + conf.realisticWater = false; + conf.bloom = false; + conf.lightShafts = false; + conf.raytracing = false; + } + + public void setShaderProfileToMedium() { + EaglerDeferredConfig conf = Minecraft.getMinecraft().gameSettings.deferredShaderConf; + conf.wavingBlocks = true; + conf.dynamicLights = false; + conf.ssao = true; + conf.shadowsSun = 32; + conf.useEnvMap = false; + conf.lensDistortion = false; + conf.lensFlares = false; + conf.fxaa = true; + conf.shadowsColored = false; + conf.shadowsSmoothed = true; + conf.realisticWater = false; + conf.bloom = false; + conf.lightShafts = false; + conf.raytracing = false; + } + + public void setShaderProfileToHigh() { + EaglerDeferredConfig conf = Minecraft.getMinecraft().gameSettings.deferredShaderConf; + conf.wavingBlocks = true; + conf.dynamicLights = true; + conf.ssao = true; + conf.shadowsSun = 64; + conf.useEnvMap = true; + conf.lensDistortion = true; + conf.lensFlares = true; + conf.fxaa = true; + conf.shadowsColored = true; + conf.shadowsSmoothed = true; + conf.realisticWater = false; + conf.bloom = false; + conf.lightShafts = false; + conf.raytracing = false; + } + + public void setShaderProfileToUltra() { + EaglerDeferredConfig conf = Minecraft.getMinecraft().gameSettings.deferredShaderConf; + conf.wavingBlocks = true; + conf.dynamicLights = true; + conf.ssao = true; + conf.shadowsSun = 128; + conf.useEnvMap = true; + conf.lensDistortion = true; + conf.lensFlares = true; + conf.fxaa = true; + conf.shadowsColored = true; + conf.shadowsSmoothed = true; + conf.realisticWater = true; + conf.bloom = true; + conf.lightShafts = true; + conf.raytracing = true; + } +} diff --git a/src/main/java/net/minecraft/client/settings/GameSettings.java b/src/main/java/net/minecraft/client/settings/GameSettings.java index 33d5523..ce4d2d5 100644 --- a/src/main/java/net/minecraft/client/settings/GameSettings.java +++ b/src/main/java/net/minecraft/client/settings/GameSettings.java @@ -18,6 +18,7 @@ import com.google.common.collect.Sets; import net.PeytonPlayz585.shadow.Config; import net.PeytonPlayz585.shadow.CustomSky; +import net.PeytonPlayz585.shadow.shaders.Shaders; import net.lax1dude.eaglercraft.v1_8.ArrayUtils; import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; @@ -227,6 +228,9 @@ public class GameSettings { //Super Secret Setting :> public boolean secret = false; + + //Shaders + public int profile = 1; public GameSettings(Minecraft mcIn) { this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem, @@ -612,6 +616,17 @@ public class GameSettings { this.ofFogStart = 0.2F; } } + + if(parOptions == GameSettings.Options.SHADER_PROFILE) { + ++this.profile; + + if(this.profile > 4) { + this.profile = 1; + } + + Shaders shader = new Shaders(); + shader.updateShaderProfile(profile); + } this.saveOptions(); } @@ -838,6 +853,23 @@ public class GameSettings { } } else if (parOptions == GameSettings.Options.FOG_START) { return s + this.ofFogStart; + } else if (parOptions == GameSettings.Options.SHADER_PROFILE) { + switch (this.profile) { + case 1: + return s + "Low"; + + case 2: + return s + "Medium"; + + case 3: + return s + "High"; + + case 4: + return s + "Ultra"; + + default: + return s + "Low"; + } } else { return s; } @@ -1227,6 +1259,19 @@ public class GameSettings { if (astring[0].equals("secret") && astring.length >= 2) { this.secret = Boolean.valueOf(astring[1]).booleanValue(); } + + if (astring[0].equals("profile")) { + if (astring[1].equals("low")) { + this.profile = 1; + } else if (astring[1].equals("mid")) { + this.profile = 2; + } else if (astring[1].equals("high")) { + this.profile = 3; + } else if(astring[1].equals("ultra")) { + this.profile = 4; + } + System.out.println("Loaded Shader Profile: " + this.profile); + } Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode()); @@ -1357,7 +1402,24 @@ public class GameSettings { printwriter.println("ofBetterGrass:" + this.ofBetterGrass); printwriter.println("ofFogType:" + this.ofFogType); printwriter.println("ofFogStart:" + this.ofFogStart); - printwriter.print("secret:" + this.secret); + //printwriter.print("secret:" + this.secret); + switch(this.profile) { + case 1: + printwriter.println("profile:low"); + break; + + case 2: + printwriter.println("profile:mid"); + break; + + case 3: + printwriter.println("profile:high"); + break; + + case 4: + printwriter.println("profile:ultra"); + break; + } for (KeyBinding keybinding : this.keyBindings) { printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); @@ -1524,7 +1586,8 @@ public class GameSettings { CLEAR_WATER("Clear Water", false, false), BETTER_GRASS("Better Grass", false, false), FOG_FANCY("Fog", false, false), - FOG_START("Fog Start", false, false); + FOG_START("Fog Start", false, false), + SHADER_PROFILE("Profile", false, false); private final boolean enumFloat; private final boolean enumBoolean;