Added Shader Profiles

This commit is contained in:
peytonplayz595 2023-09-10 05:16:13 -05:00
parent ab7b820178
commit f53639c0ed
4 changed files with 193 additions and 15 deletions

View File

@ -2,32 +2,35 @@ package net.PeytonPlayz585.shadow.gui;
import java.io.IOException; import java.io.IOException;
import net.PeytonPlayz585.shadow.shaders.Shaders;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*; import net.minecraft.client.gui.*;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
public class GuiShaders extends GuiScreen { public class GuiShaders extends GuiScreen {
protected GuiScreen parentScreen; protected GuiScreen parentScreen;
private GuiShaders.List list; private GuiShaders.List list;
GuiButton shaderOptions = null; GuiButton shaderProfile = null;
public GuiShaders(GuiScreen screen) { public GuiShaders(GuiScreen screen) {
this.parentScreen = screen; this.parentScreen = screen;
} }
public void initGui() { public void initGui() {
GameSettings.Options shaderProfile2 = GameSettings.Options.SHADER_PROFILE;
this.buttonList.clear(); this.buttonList.clear();
int i = 120; int i = 120;
int j = 20; int j = 20;
int k = this.width - i - 10; int k = width - i - 10;
int j1 = this.width - i - 20; int j1 = width - i - 20;
int k1 = Math.min(150, j1 / 2 - 10); int k1 = Math.min(150, j1 / 2 - 10);
GuiButton button; 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(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, this.height - 25, k1, j, "Shaders Folder")); this.buttonList.add(button = new GuiButton(201, j1 / 4 - k1 / 2, height - 25, k1, j, "Shaders Folder"));
button.enabled = false; button.enabled = false;
this.buttonList.add(shaderOptions = new GuiButton(203, k, this.height - 25, i, j, "Shader Options")); this.buttonList.add(shaderProfile = new GuiOptionButton(201, k, height - 25, shaderProfile2, Minecraft.getMinecraft().gameSettings.getKeyBinding(shaderProfile2)));
shaderOptions.enabled = Minecraft.getMinecraft().gameSettings.shaders; shaderProfile.enabled = Minecraft.getMinecraft().gameSettings.shaders;
this.list = new GuiShaders.List(this.mc); this.list = new GuiShaders.List(this.mc);
this.list.registerScrollButtons(7, 8); this.list.registerScrollButtons(7, 8);
} }
@ -40,8 +43,19 @@ public class GuiShaders extends GuiScreen {
protected void actionPerformed(GuiButton parGuiButton) { protected void actionPerformed(GuiButton parGuiButton) {
if(parGuiButton.enabled) { if(parGuiButton.enabled) {
if(parGuiButton.id == 6) { 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); 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.drawDefaultBackground();
this.list.drawScreen(i, j, f); 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); super.drawScreen(i, j, f);
} }
@ -58,7 +72,7 @@ public class GuiShaders extends GuiScreen {
java.util.Map<Integer, String> languageMap = new java.util.HashMap<>(); java.util.Map<Integer, String> languageMap = new java.util.HashMap<>();
public List(Minecraft mcIn) { 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(1, "OFF");
languageMap.put(2, "High Performance PBR"); languageMap.put(2, "High Performance PBR");
@ -80,7 +94,7 @@ public class GuiShaders extends GuiScreen {
Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources(); Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources();
Minecraft.getMinecraft().refreshResources(); Minecraft.getMinecraft().refreshResources();
Minecraft.getMinecraft().gameSettings.saveOptions(); Minecraft.getMinecraft().gameSettings.saveOptions();
shaderOptions.enabled = false; shaderProfile.enabled = false;
GuiShaders.this.updateScreen(); GuiShaders.this.updateScreen();
} else if(i == 1 && Minecraft.getMinecraft().gameSettings.shaders) { } else if(i == 1 && Minecraft.getMinecraft().gameSettings.shaders) {
return; return;
@ -89,7 +103,7 @@ public class GuiShaders extends GuiScreen {
Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources(); Minecraft.getMinecraft().loadingScreen.eaglerShowRefreshResources();
Minecraft.getMinecraft().refreshResources(); Minecraft.getMinecraft().refreshResources();
Minecraft.getMinecraft().gameSettings.saveOptions(); Minecraft.getMinecraft().gameSettings.saveOptions();
shaderOptions.enabled = true; shaderProfile.enabled = true;
GuiShaders.this.updateScreen(); GuiShaders.this.updateScreen();
} }
} }

View File

@ -22,8 +22,7 @@ public class VertexBuffer {
EaglercraftGPU.glNewList(parInt1, GL_COMPILE); EaglercraftGPU.glNewList(parInt1, GL_COMPILE);
VertexFormat fmt = p_181722_1_.getVertexFormat(); VertexFormat fmt = p_181722_1_.getVertexFormat();
ByteBuffer buf = p_181722_1_.getByteBuffer(); ByteBuffer buf = p_181722_1_.getByteBuffer();
EaglercraftGPU.renderBuffer(buf.position(0), fmt.eaglercraftAttribBits, 7, p_181722_1_.getVertexCount()); EaglercraftGPU.renderBuffer(buf, fmt.eaglercraftAttribBits, 7, p_181722_1_.getVertexCount());
p_181722_1_.reset();
EaglercraftGPU.glEndList(); EaglercraftGPU.glEndList();
} }
} }

View File

@ -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;
}
}

View File

@ -18,6 +18,7 @@ import com.google.common.collect.Sets;
import net.PeytonPlayz585.shadow.Config; import net.PeytonPlayz585.shadow.Config;
import net.PeytonPlayz585.shadow.CustomSky; import net.PeytonPlayz585.shadow.CustomSky;
import net.PeytonPlayz585.shadow.shaders.Shaders;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils; import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
@ -227,6 +228,9 @@ public class GameSettings {
//Super Secret Setting :> //Super Secret Setting :>
public boolean secret = false; public boolean secret = false;
//Shaders
public int profile = 1;
public GameSettings(Minecraft mcIn) { public GameSettings(Minecraft mcIn) {
this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem, this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem,
@ -612,6 +616,17 @@ public class GameSettings {
this.ofFogStart = 0.2F; 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(); this.saveOptions();
} }
@ -838,6 +853,23 @@ public class GameSettings {
} }
} else if (parOptions == GameSettings.Options.FOG_START) { } else if (parOptions == GameSettings.Options.FOG_START) {
return s + this.ofFogStart; 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 { } else {
return s; return s;
} }
@ -1227,6 +1259,19 @@ public class GameSettings {
if (astring[0].equals("secret") && astring.length >= 2) { if (astring[0].equals("secret") && astring.length >= 2) {
this.secret = Boolean.valueOf(astring[1]).booleanValue(); 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()); Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
@ -1357,7 +1402,24 @@ public class GameSettings {
printwriter.println("ofBetterGrass:" + this.ofBetterGrass); printwriter.println("ofBetterGrass:" + this.ofBetterGrass);
printwriter.println("ofFogType:" + this.ofFogType); printwriter.println("ofFogType:" + this.ofFogType);
printwriter.println("ofFogStart:" + this.ofFogStart); 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) { for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1524,7 +1586,8 @@ public class GameSettings {
CLEAR_WATER("Clear Water", false, false), CLEAR_WATER("Clear Water", false, false),
BETTER_GRASS("Better Grass", false, false), BETTER_GRASS("Better Grass", false, false),
FOG_FANCY("Fog", 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 enumFloat;
private final boolean enumBoolean; private final boolean enumBoolean;