mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-17 12:15:10 +01:00
Blur 2.5.0 - Update to 1.19, Better Exclusions & Colors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.tterrag.blur;
|
||||
|
||||
import com.tterrag.blur.config.BlurConfig;
|
||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import ladysnake.satin.api.event.ShaderEffectRenderCallback;
|
||||
import ladysnake.satin.api.managed.ManagedShaderEffect;
|
||||
import ladysnake.satin.api.managed.ShaderEffectManager;
|
||||
@@ -20,7 +21,6 @@ public class Blur implements ClientModInitializer {
|
||||
public static List<String> defaultExclusions = new ArrayList<>();
|
||||
|
||||
private long start;
|
||||
public int colorFirst, colorSecond;
|
||||
|
||||
private final ManagedShaderEffect blur = ShaderEffectManager.getInstance().manage(new Identifier(MODID, "shaders/post/fade_in_blur.json"),
|
||||
shader -> shader.setUniformValue("Radius", (float) BlurConfig.radius));
|
||||
@@ -48,11 +48,10 @@ public class Blur implements ClientModInitializer {
|
||||
private boolean doFade = false;
|
||||
public void onScreenChange(Screen newGui) {
|
||||
if (MinecraftClient.getInstance().world != null) {
|
||||
boolean excluded = newGui == null || BlurConfig.blurExclusions.contains(newGui.getClass().getName());
|
||||
boolean excluded = newGui == null || BlurConfig.blurExclusions.stream().anyMatch(exclusion -> newGui.getClass().getName().contains(exclusion));
|
||||
if (!excluded) {
|
||||
if (BlurConfig.showScreenTitle) System.out.println(newGui.getClass().getName());
|
||||
blur.setUniformValue("Radius", (float) BlurConfig.radius);
|
||||
colorFirst = Integer.parseUnsignedInt(String.valueOf(BlurConfig.gradientStartColor), 16);
|
||||
colorSecond = Integer.parseUnsignedInt(String.valueOf(BlurConfig.gradientEndColor), 16);
|
||||
if (doFade) {
|
||||
start = System.currentTimeMillis();
|
||||
doFade = false;
|
||||
@@ -69,11 +68,11 @@ public class Blur implements ClientModInitializer {
|
||||
}
|
||||
|
||||
public int getBackgroundColor(boolean second) {
|
||||
int color = second ? colorSecond : colorFirst;
|
||||
int a = color >>> 24;
|
||||
int r = (color >> 16) & 0xFF;
|
||||
int b = (color >> 8) & 0xFF;
|
||||
int g = color & 0xFF;
|
||||
int a = second ? BlurConfig.gradientEndAlpha : BlurConfig.gradientStartAlpha;
|
||||
var col = MidnightColorUtil.hex2Rgb(second ? BlurConfig.gradientEnd : BlurConfig.gradientStart);
|
||||
int r = (col.getRGB() >> 16) & 0xFF;
|
||||
int b = (col.getRGB() >> 8) & 0xFF;
|
||||
int g = col.getRGB() & 0xFF;
|
||||
float prog = INSTANCE.getProgress();
|
||||
a *= prog;
|
||||
r *= prog;
|
||||
|
||||
@@ -12,10 +12,14 @@ public class BlurConfig extends MidnightConfig {
|
||||
public static int fadeTimeMillis = 200;
|
||||
@Entry(min = 0, max = 500, width = 3)
|
||||
public static int radius = 8;
|
||||
@Entry(min = 0, max = 99999999, width = 8)
|
||||
public static int gradientStartColor = 75000000;
|
||||
@Entry(min = 0, max = 99999999, width = 8)
|
||||
public static int gradientEndColor = 75000000;
|
||||
@Entry(isColor = true, width = 7, min = 7)
|
||||
public static String gradientStart = "#000000";
|
||||
@Entry(min = 0, max = 255)
|
||||
public static int gradientStartAlpha = 75;
|
||||
@Entry(isColor = true, width = 7, min = 7)
|
||||
public static String gradientEnd = "#000000";
|
||||
@Entry(min = 0, max = 255)
|
||||
public static int gradientEndAlpha = 75;
|
||||
@Entry
|
||||
public static boolean showScreenTitle = false;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,6 @@ public abstract class MixinScreen {
|
||||
Blur.INSTANCE.onScreenChange(this.client.currentScreen);
|
||||
}
|
||||
}
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void blur$showScreenTitle(MatrixStack matrixStack, int i, int j, float f, CallbackInfo ci) {
|
||||
if (BlurConfig.showScreenTitle && this.client != null && this.client.currentScreen != null) {
|
||||
this.textRenderer.drawWithShadow(matrixStack, this.client.currentScreen.getClass().getName(), 0, 0, 16777215, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyConstant(
|
||||
method = "renderBackground(Lnet/minecraft/client/util/math/MatrixStack;I)V",
|
||||
|
||||
Reference in New Issue
Block a user