Increased max blur intensity & Working screen overrides

- EMI compat now works using forced blur
- Iris shader screen is now sooo much smoother
This commit is contained in:
Martin Prokoph
2024-09-06 23:33:10 +02:00
parent f68048d955
commit 8817e18a55
14 changed files with 41 additions and 112 deletions

View File

@@ -7,7 +7,6 @@ dependencies {
// Do NOT use other classes from fabric loader // Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modCompileOnly "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric" modCompileOnly "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
modCompileOnly "maven.modrinth:emi:${rootProject.emi_version}+fabric"
} }
publishing { publishing {

View File

@@ -1,5 +1,8 @@
package eu.midnightdust.blur; package eu.midnightdust.blur;
import eu.midnightdust.blur.config.BlurConfig;
import net.minecraft.client.gui.screen.Screen;
public class BlurInfo { public class BlurInfo {
public static long start; public static long start;
public static float progress; public static float progress;
@@ -14,8 +17,9 @@ public class BlurInfo {
public static boolean screenChanged = true; public static boolean screenChanged = true;
public static long lastScreenChange = System.currentTimeMillis(); public static long lastScreenChange = System.currentTimeMillis();
public static void reset() { public static void reset(Screen newScreen) {
// Here, we reset all tests, to check if the new screen has blur and/or a background // Here, we reset all tests, to check if the new screen has blur and/or a background
if (newScreen != null && BlurConfig.excludedScreens.contains(newScreen.getClass().getCanonicalName())) return;
prevScreenHasBlur = screenHasBlur; prevScreenHasBlur = screenHasBlur;
prevScreenHasBackground = screenHasBackground; prevScreenHasBackground = screenHasBackground;
screenHasBlur = false; screenHasBlur = false;

View File

@@ -39,7 +39,7 @@ public class BlurConfig extends MidnightConfig {
@Entry(category = SCREENS) // Screens where Blur+ should not apply transition effects (mostly dynamically blurred screens) @Entry(category = SCREENS) // Screens where Blur+ should not apply transition effects (mostly dynamically blurred screens)
public static List<String> excludedScreens = Lists.newArrayList("net.irisshaders.iris.gui.screen.ShaderPackScreen"); public static List<String> excludedScreens = Lists.newArrayList("net.irisshaders.iris.gui.screen.ShaderPackScreen");
@Entry(category = SCREENS) // Screens where the vanilla blur effect should be force enabled @Entry(category = SCREENS) // Screens where the vanilla blur effect should be force enabled
public static List<String> forceEnabledScreens = Lists.newArrayList(); public static List<String> forceEnabledScreens = Lists.newArrayList("dev.emi.emi.screen.RecipeScreen");
@Entry(category = SCREENS) // Screens where the vanilla blur effect should be force disabled @Entry(category = SCREENS) // Screens where the vanilla blur effect should be force disabled
public static List<String> forceDisabledScreens = Lists.newArrayList(); public static List<String> forceDisabledScreens = Lists.newArrayList();

View File

@@ -1,57 +0,0 @@
/*
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
*
* This file is part of midnightcontrols.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
*/
package eu.midnightdust.blur.mixin;
import eu.midnightdust.lib.util.PlatformFunctions;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class BlurMixinPlugin implements IMixinConfigPlugin {
private String mixinPackage;
@Override
public void onLoad(String mixinPackage) {
this.mixinPackage = mixinPackage + ".";
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
final String mixinName = mixinClassName.substring(this.mixinPackage.length());
final String packageName = mixinName.substring(0, mixinName.lastIndexOf('.'));
if (packageName.startsWith("emi") && !PlatformFunctions.isModLoaded("emi"))
return false;
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
@Override
public List<String> getMixins() {
return null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
}

View File

@@ -0,0 +1,22 @@
package eu.midnightdust.blur.mixin;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.SimpleOption;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(GameOptions.class)
public abstract class MixinGameOptions {
@Shadow @Final private SimpleOption<Integer> menuBackgroundBlurriness;
@Shadow @Final private SimpleOption<Double> chatLineSpacing;
@Redirect(method = "<init>", at = @At(value = "NEW", target = "net/minecraft/client/option/SimpleOption$ValidatingIntSliderCallbacks", ordinal = 2))
private SimpleOption.ValidatingIntSliderCallbacks blur$increaseMaxBlurriness(int minInclusive, int maxInclusive) {
if (this.menuBackgroundBlurriness == null && this.chatLineSpacing != null)
return new SimpleOption.ValidatingIntSliderCallbacks(minInclusive, 20);
return new SimpleOption.ValidatingIntSliderCallbacks(minInclusive, maxInclusive);
}
}

View File

@@ -20,9 +20,8 @@ public class MixinMinecraftClient {
opcode = Opcodes.PUTFIELD)) opcode = Opcodes.PUTFIELD))
private void blur$onScreenOpen(Screen newScreen, CallbackInfo info) { private void blur$onScreenOpen(Screen newScreen, CallbackInfo info) {
if (BlurInfo.lastScreenChange < System.currentTimeMillis() - 100) { // For some reason, in certain scenarios the screen is set to a new one multiple times in a tick. We want to avoid that. if (BlurInfo.lastScreenChange < System.currentTimeMillis() - 100) { // For some reason, in certain scenarios the screen is set to a new one multiple times in a tick. We want to avoid that.
// Here, we reset all tests, to check if the new screen has blur and/or a background // Here, we reset all tests, to check if the new screen has blur and/or a background
BlurInfo.reset(); BlurInfo.reset(newScreen);
// Manually activate the onScreenChange method when all screens are closed (in-game) // Manually activate the onScreenChange method when all screens are closed (in-game)
if (newScreen == null) Blur.onScreenChange(); if (newScreen == null) Blur.onScreenChange();

View File

@@ -45,10 +45,10 @@ public abstract class MixinScreen {
} }
@Inject(at = @At("HEAD"), method = "applyBlur", cancellable = true) @Inject(at = @At("HEAD"), method = "applyBlur", cancellable = true)
public void blur$getBlurEnabled(float delta, CallbackInfo ci) { public void blur$getBlurEnabled(float delta, CallbackInfo ci) {
if (BlurConfig.forceDisabledScreens.contains(this.getClass().toString())) { if (BlurConfig.forceDisabledScreens.contains(this.getClass().getCanonicalName())) {
ci.cancel(); return; ci.cancel(); return;
} }
if (!BlurConfig.excludedScreens.contains(this.getClass().toString())) if (!BlurConfig.excludedScreens.contains(this.getClass().getCanonicalName()))
BlurInfo.screenHasBlur = true; // Test if the screen has blur BlurInfo.screenHasBlur = true; // Test if the screen has blur
} }
@@ -62,8 +62,8 @@ public abstract class MixinScreen {
@Inject(at = @At("HEAD"), method = "renderInGameBackground", cancellable = true) @Inject(at = @At("HEAD"), method = "renderInGameBackground", cancellable = true)
public void blur$rotatedGradient(DrawContext context, CallbackInfo ci) { public void blur$rotatedGradient(DrawContext context, CallbackInfo ci) {
if (BlurConfig.forceEnabledScreens.contains(this.getClass().toString())) if (BlurConfig.forceEnabledScreens.contains(this.getClass().getCanonicalName()))
(((ScreenAccessor)this)).forceApplyBlur(client.getRenderTickCounter().getTickDelta(true)); // Applies the blur effect in force-enabled screens ((ScreenAccessor)this).forceApplyBlur(client.getRenderTickCounter().getTickDelta(true));
Blur.renderRotatedGradient(context, width, height); // Replaces the default gradient with our rotated one Blur.renderRotatedGradient(context, width, height); // Replaces the default gradient with our rotated one
ci.cancel(); ci.cancel();

View File

@@ -1,25 +0,0 @@
package eu.midnightdust.blur.mixin.emi;
import dev.emi.emi.screen.RecipeScreen;
import eu.midnightdust.blur.config.BlurConfig;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(RecipeScreen.class)
public class MixinRecipeScreen extends Screen {
protected MixinRecipeScreen(Text title) {
super(title);
}
@Inject(at = @At("HEAD"), method = "render")
public void blur$addBlurEffect(DrawContext raw, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (BlurConfig.blurContainers) this.applyBlur(delta);
}
}

View File

@@ -26,6 +26,9 @@
"blur.midnightconfig.gradientEndAlpha": "Gradient End Alpha", "blur.midnightconfig.gradientEndAlpha": "Gradient End Alpha",
"blur.midnightconfig.gradientRotation": "Gradient Rotation", "blur.midnightconfig.gradientRotation": "Gradient Rotation",
"blur.midnightconfig.excludedScreens": "Excluded Screens", "blur.midnightconfig.excludedScreens": "Excluded Screens",
"blur.midnightconfig.forceEnabledScreens": "Screens where blur should be force-enabled", "blur.midnightconfig.excludedScreens.tooltip": "Screens that Blur+ should not animate",
"blur.midnightconfig.forceDisabledScreens": "Screens where blur should be force-disabled" "blur.midnightconfig.forceEnabledScreens": "Force-enabled Screens",
"blur.midnightconfig.forceEnabledScreens.tooltip": "Screens where the vanilla blur effect should be force-enabled\nMight not work 100% of the time",
"blur.midnightconfig.forceDisabledScreens": "Force-disabled Screens",
"blur.midnightconfig.forceDisabledScreens.tooltip": "Screens where the vanilla blur effect should be force-disabled"
} }

View File

@@ -9,7 +9,8 @@
"MixinHandledScreen", "MixinHandledScreen",
"MixinMinecraftClient", "MixinMinecraftClient",
"MixinGameRenderer", "MixinGameRenderer",
"MixinInGameHud" "MixinInGameHud",
"MixinGameOptions"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View File

@@ -1,12 +0,0 @@
{
"required": true,
"package": "eu.midnightdust.blur.mixin",
"plugin": "eu.midnightdust.blur.mixin.BlurMixinPlugin",
"compatibilityLevel": "JAVA_21",
"client": [
"emi.MixinRecipeScreen"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@@ -25,8 +25,7 @@
], ],
"description": "Various enhancements for the blur effect behind Minecraft GUIs", "description": "Various enhancements for the blur effect behind Minecraft GUIs",
"mixins": [ "mixins": [
"blur.mixins.json", "blur.mixins.json"
"blur_compat.mixins.json"
], ],
"depends": { "depends": {
"minecraft": ">=1.20.5" "minecraft": ">=1.20.5"

View File

@@ -25,5 +25,3 @@ yarn_mappings_patch_neoforge_version = 1.21+build.4
# Libraries # Libraries
midnightlib_version = 1.6.3 midnightlib_version = 1.6.3
modmenu_version = 11.0.2 modmenu_version = 11.0.2
emi_version=1.1.12+1.21

View File

@@ -15,8 +15,6 @@ Various enhancements for the blur effect behind Minecraft GUIs
[[mixins]] [[mixins]]
config = "blur.mixins.json" config = "blur.mixins.json"
[[mixins]]
config = "blur_compat.mixins.json"
[[dependencies.blur]] [[dependencies.blur]]
modId = "neoforge" modId = "neoforge"