mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:11:31 +01:00
New Blur
This commit is contained in:
parent
2f1ae8155b
commit
42a1c727a6
@ -1,6 +1,5 @@
|
||||
package net.silentclient.client.gui.minecraft;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievements;
|
||||
import net.minecraft.client.gui.achievement.GuiStats;
|
||||
@ -21,7 +20,6 @@ import net.silentclient.client.gui.hud.Watermark;
|
||||
import net.silentclient.client.gui.lite.clickgui.ClickGUI;
|
||||
import net.silentclient.client.gui.modmenu.ModMenu;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
import net.silentclient.client.mods.settings.GeneralMod;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -34,7 +32,7 @@ public class GuiIngameMenu extends GuiScreen
|
||||
*/
|
||||
public void initGui()
|
||||
{
|
||||
MenuBlurUtils.loadBlur();
|
||||
// MenuBlurUtils.loadBlur();
|
||||
this.buttonList.clear();
|
||||
int i = -16;
|
||||
this.buttonList.add(new Button(1, this.width / 2 - 100, this.height / 4 + 120 + i, "Save and Quit to Title", true));
|
||||
@ -167,9 +165,9 @@ public class GuiIngameMenu extends GuiScreen
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
|
||||
Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
|
||||
}
|
||||
// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
|
||||
// Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
|
||||
// }
|
||||
super.onGuiClosed();
|
||||
}
|
||||
}
|
||||
|
79
src/main/java/net/silentclient/client/gui/util/BlurUtil.java
Normal file
79
src/main/java/net/silentclient/client/gui/util/BlurUtil.java
Normal file
@ -0,0 +1,79 @@
|
||||
package net.silentclient.client.gui.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.client.shader.ShaderGroup;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.silentclient.client.mixin.ducks.MinecraftExt;
|
||||
import net.silentclient.client.mods.util.IMixinShaderGroup;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class BlurUtil {
|
||||
private static int lastScale;
|
||||
|
||||
private static int lastScaleWidth;
|
||||
|
||||
private static int lastScaleHeight;
|
||||
|
||||
private static Framebuffer buffer;
|
||||
|
||||
private static ShaderGroup blurShader;
|
||||
|
||||
|
||||
private static final ResourceLocation shader = new ResourceLocation("shaders/post/menu_blur.json");
|
||||
|
||||
public static void initFboAndShader() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
try {
|
||||
blurShader = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), shader);
|
||||
blurShader.createBindFramebuffers(mc.displayWidth, mc.displayHeight);
|
||||
buffer = (Framebuffer) ((IMixinShaderGroup) blurShader).getMainFramebuffer();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void crop(float x, float y, float x2, float y2) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution scaledResolution = new ScaledResolution(mc);
|
||||
int factor = scaledResolution.getScaleFactor();
|
||||
GL11.glScissor((int)(x * factor), (int)((scaledResolution.getScaledHeight() - y2) * factor), (int)((x2 - x) * factor), (int)((y2 - y) * factor));
|
||||
}
|
||||
|
||||
public static void blur(float x, float y, float x2, float y2, ScaledResolution sr){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
int factor = sr.getScaleFactor();
|
||||
int factor2 = sr.getScaledWidth();
|
||||
int factor3 = sr.getScaledHeight();
|
||||
if (lastScale != factor || lastScaleWidth != factor2 || lastScaleHeight != factor3 || buffer == null || blurShader == null)
|
||||
initFboAndShader();
|
||||
lastScale = factor;
|
||||
lastScaleWidth = factor2;
|
||||
lastScaleHeight = factor3;
|
||||
GL11.glEnable(3089);
|
||||
crop(x, y, x2, y2);
|
||||
buffer.framebufferHeight = mc.displayHeight;
|
||||
buffer.framebufferWidth = mc.displayWidth;
|
||||
GlStateManager.resetColor();
|
||||
blurShader.loadShaderGroup(((Timer) ((MinecraftExt) mc).getTimer()).renderPartialTicks);
|
||||
buffer.bindFramebuffer(true);
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
GL11.glDisable(3089);
|
||||
}
|
||||
|
||||
public static void blur(float x, float y, float x2, float y2) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GlStateManager.disableAlpha();
|
||||
blur(x, y, x2, y2, new ScaledResolution(mc));
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
public static void blur2(float x, float y, float x2, float y2, float h, float w) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GlStateManager.disableAlpha();
|
||||
blur(x, y, x2 + w, y2 + h, new ScaledResolution(mc));
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
}
|
@ -2,4 +2,5 @@ package net.silentclient.client.mixin.ducks;
|
||||
|
||||
public interface MinecraftExt {
|
||||
void setSession(Object session);
|
||||
Object getTimer();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Session;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.event.impl.*;
|
||||
@ -128,6 +129,8 @@ public abstract class MinecraftMixin implements MinecraftExt {
|
||||
@Mutable
|
||||
@Shadow @Final private Session session;
|
||||
|
||||
@Shadow private Timer timer;
|
||||
|
||||
@Inject(method = "displayGuiScreen", at = @At("RETURN"), cancellable = true)
|
||||
public void displayGuiScreenInject(GuiScreen guiScreenIn, CallbackInfo ci) {
|
||||
if(Client.backgroundPanorama == null) {
|
||||
@ -317,4 +320,9 @@ public abstract class MinecraftMixin implements MinecraftExt {
|
||||
|
||||
return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,25 @@
|
||||
package net.silentclient.client.mixin.mixins;
|
||||
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.client.shader.Shader;
|
||||
import net.minecraft.client.shader.ShaderGroup;
|
||||
import net.silentclient.client.mods.util.IMixinShaderGroup;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ShaderGroup.class)
|
||||
public abstract class ShaderGroupMixin implements IMixinShaderGroup {
|
||||
@Shadow private Framebuffer mainFramebuffer;
|
||||
|
||||
@Override
|
||||
@Accessor
|
||||
public abstract List<Shader> getListShaders();
|
||||
|
||||
@Override
|
||||
public Object getMainFramebuffer() {
|
||||
return this.mainFramebuffer;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package net.silentclient.client.mods.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.shader.Shader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMixinShaderGroup {
|
||||
List<Shader> getListShaders();
|
||||
Object getMainFramebuffer();
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package net.silentclient.client.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.cosmetics.StaticResourceLocation;
|
||||
import net.silentclient.client.gui.util.BlurUtil;
|
||||
import net.silentclient.client.mixin.accessors.GuiAccessor;
|
||||
import net.silentclient.client.mixin.ducks.EntityRendererExt;
|
||||
import net.silentclient.client.mods.settings.GeneralMod;
|
||||
|
||||
import java.awt.*;
|
||||
@ -16,12 +14,15 @@ public class MenuBlurUtils {
|
||||
}
|
||||
|
||||
public static void loadBlur(boolean force) {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) {
|
||||
((EntityRendererExt) Minecraft.getMinecraft().entityRenderer).silent$loadShader(new StaticResourceLocation("shaders/post/menu_blur.json"));
|
||||
}
|
||||
// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) {
|
||||
// ((EntityRendererExt) Minecraft.getMinecraft().entityRenderer).silent$loadShader(new StaticResourceLocation("shaders/post/menu_blur.json"));
|
||||
// }
|
||||
}
|
||||
|
||||
public static void renderBackground(GuiScreen instance) {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
|
||||
BlurUtil.blur2(0, 0, 1920, 1080, 0, 0);
|
||||
}
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() && !Client.getInstance().getGlobalSettings().isLite()) {
|
||||
((GuiAccessor) instance).silent$drawGradientRect(0, 0, instance.width, instance.height, new Color(0, 0, 0, 0).getRGB(), new Color(0, 0, 0, 0).getRGB());
|
||||
} else {
|
||||
@ -34,8 +35,8 @@ public class MenuBlurUtils {
|
||||
}
|
||||
|
||||
public static void unloadBlur(boolean force) {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) {
|
||||
Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
|
||||
}
|
||||
// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) {
|
||||
// Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user