mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-13 10:25:09 +01:00
Blur 3.1.0 - 1.20 & Fade Out Fix
- Update to 1.20 - Fix fade out applying to screens without blur - Enable fade out effect by default
This commit is contained in:
@@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.19.4
|
||||
yarn_mappings=1.19.4+build.2
|
||||
loader_version=0.14.19
|
||||
minecraft_version=1.20
|
||||
yarn_mappings=1.20+build.1
|
||||
loader_version=0.14.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version=3.0.1
|
||||
mod_version=3.1.0
|
||||
maven_group=com.tterrag.blur
|
||||
archives_base_name=blur
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_version=0.79.0+1.19.4
|
||||
satin_version=1.11.0
|
||||
midnightlib_version=1.2.1-fabric
|
||||
fabric_version=0.83.0+1.20
|
||||
satin_version=1.13.0
|
||||
midnightlib_version=1.4.1-fabric
|
||||
|
||||
@@ -11,6 +11,8 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Blur implements ClientModInitializer {
|
||||
|
||||
public static final String MODID = "blur";
|
||||
@@ -49,7 +51,7 @@ public class Blur implements ClientModInitializer {
|
||||
doFade = false;
|
||||
}
|
||||
prevScreen = newGui.getClass().getName();
|
||||
} else if (newGui == null && BlurConfig.fadeOutTimeMillis > 0 && !BlurConfig.blurExclusions.contains(prevScreen)) {
|
||||
} else if (newGui == null && BlurConfig.fadeOutTimeMillis > 0 && !Objects.equals(prevScreen, "")) {
|
||||
blur.setUniformValue("Radius", (float) BlurConfig.radius);
|
||||
start = System.currentTimeMillis();
|
||||
doFade = true;
|
||||
@@ -57,25 +59,26 @@ public class Blur implements ClientModInitializer {
|
||||
screenHasBackground = false;
|
||||
start = -1;
|
||||
doFade = true;
|
||||
prevScreen = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static float getProgress(boolean fadeIn) {
|
||||
float x;
|
||||
if (fadeIn) {
|
||||
float x = Math.min((System.currentTimeMillis() - start) / (float) BlurConfig.fadeTimeMillis, 1);
|
||||
x = Math.min((System.currentTimeMillis() - start) / (float) BlurConfig.fadeTimeMillis, 1);
|
||||
if (BlurConfig.ease) x *= (2 - x); // easeInCubic
|
||||
return x;
|
||||
}
|
||||
else {
|
||||
float x = Math.max(1+(start - System.currentTimeMillis()) / (float) BlurConfig.fadeOutTimeMillis, 0);
|
||||
x = Math.max(1 + (start - System.currentTimeMillis()) / (float) BlurConfig.fadeOutTimeMillis, 0);
|
||||
if (BlurConfig.ease) x *= (2 - x); // easeOutCubic
|
||||
if (x <= 0) {
|
||||
start = 0;
|
||||
screenHasBackground = false;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static int getBackgroundColor(boolean second, boolean fadeIn) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BlurConfig extends MidnightConfig {
|
||||
@Entry(category = style, min = 0, max = 5000, width = 4)
|
||||
public static int fadeTimeMillis = 200;
|
||||
@Entry(category = style, min = 0, max = 5000, width = 4)
|
||||
public static int fadeOutTimeMillis = 0;
|
||||
public static int fadeOutTimeMillis = 200;
|
||||
@Entry(category = style)
|
||||
public static boolean ease = true;
|
||||
@Entry(category = style, isSlider = true, min = 0, max = 100)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.tterrag.blur.mixin;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.tterrag.blur.Blur;
|
||||
import com.tterrag.blur.config.BlurConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,14 +14,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public class MixinInGameHud extends DrawableHelper {
|
||||
public class MixinInGameHud {
|
||||
@Shadow private int scaledWidth;
|
||||
@Shadow private int scaledHeight;
|
||||
@Final @Shadow private MinecraftClient client;
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/util/Identifier;)V", ordinal = 0, shift = At.Shift.BEFORE), method = "render")
|
||||
public void blur$onRender(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
public void blur$onRender(DrawContext context, float tickDelta, CallbackInfo ci) {
|
||||
if (client.currentScreen == null && client.world != null && Blur.start > 0 && !BlurConfig.blurExclusions.contains(Blur.prevScreen) && Blur.screenHasBackground) {
|
||||
fillGradient(matrices, 0, 0, this.scaledWidth, this.scaledHeight, Blur.getBackgroundColor(false, false), Blur.getBackgroundColor(true, false));
|
||||
context.fillGradient(0, 0, this.scaledWidth, this.scaledHeight, Blur.getBackgroundColor(false, false), Blur.getBackgroundColor(true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tterrag.blur.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -32,7 +33,7 @@ public abstract class MixinScreen {
|
||||
}
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "renderBackground")
|
||||
public void blur$getBackgroundEnabled(MatrixStack matrices, CallbackInfo ci) {
|
||||
public void blur$getBackgroundEnabled(DrawContext context, CallbackInfo ci) {
|
||||
if (this.client != null && this.client.world != null) {
|
||||
Blur.screenHasBackground = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user