From f6ca23fcc1d13389ab9460c843a0f2126eb84443 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Thu, 18 Aug 2022 13:31:23 +0200 Subject: Blur (#94) * blurring * api * update optifine hook --- .../cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java | 7 +++---- .../oneconfig/internal/plugin/hooks/OptifineConfigHook.java | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'versions/src/main') diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java index eed82a2..50e8cef 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java @@ -29,8 +29,6 @@ package cc.polyfrost.oneconfig.internal.gui.impl; import cc.polyfrost.oneconfig.events.event.RenderEvent; import cc.polyfrost.oneconfig.events.event.ScreenOpenEvent; import cc.polyfrost.oneconfig.events.event.Stage; -import cc.polyfrost.oneconfig.gui.OneConfigGui; -import cc.polyfrost.oneconfig.internal.config.Preferences; import cc.polyfrost.oneconfig.internal.gui.BlurHandler; import cc.polyfrost.oneconfig.internal.mixin.ShaderGroupAccessor; //#if FABRIC==1 @@ -39,6 +37,7 @@ import cc.polyfrost.oneconfig.internal.mixin.ShaderGroupAccessor; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.libs.universal.UScreen; +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen; import net.minecraft.client.shader.Shader; import net.minecraft.client.shader.ShaderUniform; import net.minecraft.util.ResourceLocation; @@ -130,7 +129,7 @@ public class BlurHandlerImpl implements BlurHandler { // If a shader is not already active and the UI is // a one of ours, we should load our own blur! - if (!isShaderActive() && gui instanceof OneConfigGui && Preferences.enableBlur) { + if (!isShaderActive() && (gui instanceof OneUIScreen && ((OneUIScreen) gui).hasBackgroundBlur())) { //#if FABRIC==1 //$$ ((GameRendererAccessor) UMinecraft.getMinecraft().gameRenderer).invokeLoadShader(this.blurShader); //#else @@ -141,7 +140,7 @@ public class BlurHandlerImpl implements BlurHandler { this.progress = 0; // If a shader is active and the incoming UI is null or we have blur disabled, stop using the shader. - } else if (isShaderActive() && (gui == null || !Preferences.enableBlur)) { + } else if (isShaderActive() && (gui == null || (gui instanceof OneUIScreen && !((OneUIScreen) gui).hasBackgroundBlur()))) { String name = UMinecraft.getMinecraft().entityRenderer.getShaderGroup().getShaderGroupName(); // Only stop our specific blur ;) diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/OptifineConfigHook.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/OptifineConfigHook.java index 197d9c2..124c44e 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/OptifineConfigHook.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/OptifineConfigHook.java @@ -26,20 +26,20 @@ package cc.polyfrost.oneconfig.internal.plugin.hooks; -import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen; import java.util.Optional; public class OptifineConfigHook { public static boolean shouldNotApplyFastRender() { - if (Platform.getGuiPlatform().getCurrentScreen() instanceof OneConfigGui) { + if (Platform.getGuiPlatform().getCurrentScreen() instanceof OneUIScreen && ((OneUIScreen) Platform.getGuiPlatform().getCurrentScreen()).hasBackgroundBlur()) { return true; } for (Optional screen : GuiUtils.getScreenQueue()) { - if (screen.isPresent() && screen.get() instanceof OneConfigGui) { + if (screen.isPresent() && screen.get() instanceof OneUIScreen && ((OneUIScreen) screen.get()).hasBackgroundBlur()) { return true; } } -- cgit