mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-13 10:25:09 +01:00
feat: various improvements
- Update to MidnightLib 1.7.0 and use its features to make the config screen more reliable - Fix background gradient being opaque briefly when fading out while not in a world - Fix 1.21.5 compat (still compatible with 1.21.4 as well :D)
This commit is contained in:
@@ -23,7 +23,8 @@ public class Blur {
|
||||
|
||||
public static boolean doFade = false;
|
||||
|
||||
public static void onRender(DrawContext context, int width, int height, MinecraftClient client) {
|
||||
static float lastDelta;
|
||||
public static void onRender(DrawContext context, int width, int height, MinecraftClient client, float delta) {
|
||||
if (!BlurInfo.doTest && BlurInfo.screenChanged) { // After the tests for blur and background color have been completed
|
||||
Blur.onScreenChange();
|
||||
BlurInfo.screenChanged = false;
|
||||
@@ -31,9 +32,9 @@ public class Blur {
|
||||
|
||||
if (BlurInfo.start >= 0 && !BlurInfo.screenHasBlur && BlurInfo.prevScreenHasBlur) { // Fade out in non-blurred screens
|
||||
client.gameRenderer.renderBlur();
|
||||
client.getFramebuffer().beginWrite(false);
|
||||
|
||||
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, width, height);
|
||||
if (BlurInfo.prevScreenHasBackground && BlurConfig.useGradient && lastDelta != delta) Blur.renderRotatedGradient(context, width, height);
|
||||
lastDelta = delta;
|
||||
}
|
||||
BlurInfo.doTest = false; // Set the test state to completed, as tests will happen in the same tick.
|
||||
}
|
||||
@@ -78,10 +79,7 @@ public class Blur {
|
||||
int b = (col.getRGB() >> 8) & 0xFF;
|
||||
int g = col.getRGB() & 0xFF;
|
||||
float prog = progress;
|
||||
a *= prog;
|
||||
r *= prog;
|
||||
g *= prog;
|
||||
b *= prog;
|
||||
a *= prog; r *= prog; g *= prog; b *= prog;
|
||||
return a << 24 | r << 16 | b << 8 | g;
|
||||
}
|
||||
public static int getRotation() {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class BlurConfig extends MidnightConfig {
|
||||
public static boolean blurContainers = true;
|
||||
@Entry(category = SCREENS)
|
||||
public static boolean blurTitleScreen = false;
|
||||
@Condition(requiredOption = "blurTitleScreen", visibleButLocked = true)
|
||||
@Entry(category = SCREENS)
|
||||
public static boolean darkenTitleScreen = false;
|
||||
@Entry(category = ANIMATIONS, min = 0, max = 2000, isSlider = true)
|
||||
@@ -31,14 +32,19 @@ public class BlurConfig extends MidnightConfig {
|
||||
public static int radius = 5;
|
||||
@Entry(category = STYLE)
|
||||
public static boolean useGradient = true;
|
||||
@Condition(requiredOption = "useGradient", visibleButLocked = true)
|
||||
@Entry(category = STYLE, isColor = true, width = 7, min = 7)
|
||||
public static String gradientStart = "#000000";
|
||||
@Condition(requiredOption = "useGradient", visibleButLocked = true)
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 255)
|
||||
public static int gradientStartAlpha = 75;
|
||||
@Condition(requiredOption = "useGradient", visibleButLocked = true)
|
||||
@Entry(category = STYLE, isColor = true, width = 7, min = 7)
|
||||
public static String gradientEnd = "#000000";
|
||||
@Condition(requiredOption = "useGradient", visibleButLocked = true)
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 255)
|
||||
public static int gradientEndAlpha = 75;
|
||||
@Condition(requiredOption = "useGradient", visibleButLocked = true)
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 360)
|
||||
public static int gradientRotation = 0;
|
||||
@Entry(category = STYLE)
|
||||
|
||||
@@ -24,6 +24,6 @@ public class MixinHandledScreen extends Screen {
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (PlatformFunctions.getPlatformName().equals("neoforge")) Blur.onRender(context, width, height, this.client);
|
||||
if (PlatformFunctions.getPlatformName().equals("neoforge")) Blur.onRender(context, width, height, this.client, delta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ public class MixinInGameHud {
|
||||
BlurInfo.doTest = false;
|
||||
BlurInfo.screenChanged = false;
|
||||
this.client.gameRenderer.renderBlur();
|
||||
this.client.getFramebuffer().beginWrite(false);
|
||||
|
||||
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.Blur;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(value = MidnightConfig.EntryInfo.class, remap = false)
|
||||
public abstract class MixinMidnightConfig$EntryInfo {
|
||||
@Shadow @Final public String modid;
|
||||
@Shadow @Final public String fieldName;
|
||||
@Shadow Object value;
|
||||
|
||||
@Inject(at = @At(value = "TAIL"), method = "updateFieldValue")
|
||||
private void blur$instantlyApplyRadius(CallbackInfo ci) {
|
||||
if (Objects.equals(modid, Blur.MOD_ID) && Objects.equals(fieldName, "radius"))
|
||||
MinecraftClient.getInstance().options.getMenuBackgroundBlurriness().setValue((int) value);
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MidnightConfig.MidnightConfigScreen.class)
|
||||
public abstract class MixinMidnightConfigScreen {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lcom/google/gson/Gson;fromJson(Ljava/io/Reader;Ljava/lang/Class;)Ljava/lang/Object;", shift = At.Shift.AFTER), remap = false, method = "loadValues")
|
||||
private void blur$syncRadius(CallbackInfo ci) {
|
||||
@Mixin(MidnightConfig.class)
|
||||
public abstract class MixinMidnightConfig {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lcom/google/gson/Gson;fromJson(Ljava/io/Reader;Ljava/lang/Class;)Ljava/lang/Object;", shift = At.Shift.AFTER), remap = false, method = "loadValuesFromJson")
|
||||
private static void blur$syncRadius(CallbackInfo ci) {
|
||||
BlurConfig.radius = MinecraftClient.getInstance().options.getMenuBackgroundBlurrinessValue();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = MidnightConfig.MidnightSliderWidget.class)
|
||||
public abstract class MixinMidnightSliderWidget {
|
||||
@Shadow(remap = false) @Final private MidnightConfig.EntryInfo info;
|
||||
|
||||
@Inject(at = @At(value = "TAIL"), method = "applyValue")
|
||||
private void blur$instantlyApplyRadius(CallbackInfo ci) {
|
||||
// TODO: Make more fields in MidnightLib protected instead of private and improve this
|
||||
MinecraftClient.getInstance().options.getMenuBackgroundBlurriness().setValue(Integer.parseInt(this.info.toTemporaryValue()));
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public abstract class MixinScreen {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
Blur.onRender(context, width, height, this.client);
|
||||
Blur.onRender(context, width, height, this.client, delta);
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "renderInGameBackground")
|
||||
public void blur$getBackgroundEnabled(DrawContext context, CallbackInfo ci) {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
"MixinGameRenderer",
|
||||
"MixinHandledScreen",
|
||||
"MixinInGameHud",
|
||||
"MixinMidnightConfigScreen",
|
||||
"MixinMidnightSliderWidget",
|
||||
"MixinMidnightConfig",
|
||||
"MixinMidnightConfig$EntryInfo",
|
||||
"MixinMinecraftClient",
|
||||
"MixinScreen",
|
||||
"MixinTitleScreen",
|
||||
|
||||
@@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
minecraft_version=1.21.4
|
||||
supported_versions=
|
||||
supported_versions=1.21.5
|
||||
yarn_mappings=1.21.4+build.1
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
# Mod Properties
|
||||
mod_version=5.1.3
|
||||
mod_version=5.2.0
|
||||
maven_group=eu.midnightdust.blur
|
||||
archives_base_name=blur
|
||||
release_type=release
|
||||
@@ -23,5 +23,5 @@ neoforge_version=21.4.10-beta
|
||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
|
||||
# Libraries
|
||||
midnightlib_version = 1.6.7
|
||||
midnightlib_version = 1.7.0+1.21.4
|
||||
modmenu_version = 11.0.2
|
||||
|
||||
Reference in New Issue
Block a user