backport: adjust for 1.21.1

phew...
This commit is contained in:
Martin Prokoph
2025-07-15 18:43:59 +02:00
parent 0fd10408ca
commit 06876d98e4
11 changed files with 21 additions and 24 deletions

View File

@@ -6,7 +6,7 @@ import eu.midnightdust.lib.util.MidnightColorUtil;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import org.joml.Math; import org.joml.Math;
import org.joml.Matrix3x2f; import org.joml.Matrix4f;
import java.awt.Color; import java.awt.Color;
import java.lang.Double; import java.lang.Double;
@@ -32,7 +32,8 @@ public class Blur {
} }
public static void renderFadeout(DrawContext context, int width, int height, MinecraftClient client) { public static void renderFadeout(DrawContext context, int width, int height, MinecraftClient client) {
if (BlurInfo.start >= 0 && !BlurInfo.screenHasBlur && BlurInfo.prevScreenHasBlur) { // Fade out in non-blurred screens if (BlurInfo.start >= 0 && !BlurInfo.screenHasBlur && BlurInfo.prevScreenHasBlur) { // Fade out in non-blurred screens
client.gameRenderer.renderBlur(); client.gameRenderer.renderBlur(client.getRenderTickCounter().getTickDelta(true));
client.getFramebuffer().beginWrite(false);
if (BlurInfo.prevScreenHasBackground && BlurConfig.useGradient) Blur.renderRotatedGradient(context, width, height); if (BlurInfo.prevScreenHasBackground && BlurConfig.useGradient) Blur.renderRotatedGradient(context, width, height);
} }

View File

@@ -13,7 +13,7 @@ public abstract class MixinGameOptions {
@Shadow @Final private SimpleOption<Integer> menuBackgroundBlurriness; @Shadow @Final private SimpleOption<Integer> menuBackgroundBlurriness;
@Shadow @Final private SimpleOption<Double> chatLineSpacing; @Shadow @Final private SimpleOption<Double> chatLineSpacing;
@Redirect(method = "<init>", at = @At(value = "NEW", target = "net/minecraft/client/option/SimpleOption$ValidatingIntSliderCallbacks", ordinal = 3)) @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) { private SimpleOption.ValidatingIntSliderCallbacks blur$increaseMaxBlurriness(int minInclusive, int maxInclusive) {
if (this.menuBackgroundBlurriness == null && this.chatLineSpacing != null) if (this.menuBackgroundBlurriness == null && this.chatLineSpacing != null)
return new SimpleOption.ValidatingIntSliderCallbacks(minInclusive, 20); return new SimpleOption.ValidatingIntSliderCallbacks(minInclusive, 20);

View File

@@ -1,21 +1,18 @@
package eu.midnightdust.blur.mixin; package eu.midnightdust.blur.mixin;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import eu.midnightdust.blur.Blur; import eu.midnightdust.blur.Blur;
import eu.midnightdust.blur.BlurInfo; import eu.midnightdust.blur.BlurInfo;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(GameRenderer.class) @Mixin(GameRenderer.class)
public class MixinGameRenderer { public class MixinGameRenderer {
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getMenuBackgroundBlurrinessValue()I")) @ModifyVariable(method = "renderBlur", at = @At("STORE"), ordinal = 1)
private int blur$modifyRadius(GameOptions instance, Operation<Integer> original) { private float blur$modifyRadius(float radius) { // Modify the radius based on the animation progress
int radius = instance.getMenuBackgroundBlurrinessValue();
if (!BlurInfo.screenChanged && BlurInfo.start >= 0) // Only update the progress after all tests have been completed if (!BlurInfo.screenChanged && BlurInfo.start >= 0) // Only update the progress after all tests have been completed
Blur.updateProgress(BlurInfo.screenHasBlur); Blur.updateProgress(BlurInfo.screenHasBlur);
return (int) (radius * BlurInfo.progress); return radius * BlurInfo.progress;
} }
} }

View File

@@ -19,8 +19,8 @@ public class MixinHandledScreen extends Screen {
} }
@Inject(method = "renderBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V", shift = At.Shift.BEFORE)) @Inject(method = "renderBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V", shift = At.Shift.BEFORE))
private void blur$renderContainerBlur(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { // Applies the blur effect in containers (Inventory, Chest, etc.) private void blur$renderContainerBlur(DrawContext context, int mouseX, int mouseY, float tickDelta, CallbackInfo ci) { // Applies the blur effect in containers (Inventory, Chest, etc.)
if (BlurConfig.blurContainers) this.applyBlur(context); if (BlurConfig.blurContainers) this.applyBlur(tickDelta);
} }
@Inject(at = @At("HEAD"), method = "render") @Inject(at = @At("HEAD"), method = "render")
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {

View File

@@ -22,7 +22,8 @@ public class MixinInGameHud {
if (client.currentScreen == null && client.world != null && BlurInfo.start >= 0 && BlurInfo.prevScreenHasBlur) { if (client.currentScreen == null && client.world != null && BlurInfo.start >= 0 && BlurInfo.prevScreenHasBlur) {
BlurInfo.doTest = false; BlurInfo.doTest = false;
BlurInfo.screenChanged = false; BlurInfo.screenChanged = false;
context.applyBlur(); this.client.gameRenderer.renderBlur(tickCounter.getTickDelta(true));
this.client.getFramebuffer().beginWrite(false);
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight()); if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
} }

View File

@@ -26,8 +26,6 @@ public abstract class MixinScreen {
@Shadow protected MinecraftClient client; @Shadow protected MinecraftClient client;
@Shadow public int width; @Shadow public int width;
@Shadow public int height; @Shadow public int height;
@Shadow protected abstract void applyBlur(DrawContext context);
@Shadow protected abstract void applyBlur(float delta); @Shadow protected abstract void applyBlur(float delta);
@Inject(at = @At("HEAD"), method = "render") @Inject(at = @At("HEAD"), method = "render")

View File

@@ -17,11 +17,11 @@ public abstract class MixinTitleScreen extends Screen {
super(title); super(title);
} }
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;renderPanoramaBackground(Lnet/minecraft/client/gui/DrawContext;F)V")) @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;renderPanoramaBackground(Lnet/minecraft/client/gui/DrawContext;F)V", shift = At.Shift.AFTER))
private void blur$renderTitleBlur(DrawContext context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) { private void blur$renderTitleBlur(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (BlurConfig.blurTitleScreen) { if (BlurConfig.blurTitleScreen) {
Blur.updateProgress(true); Blur.updateProgress(true);
this.applyBlur(context); this.applyBlur(delta);
if (BlurConfig.darkenTitleScreen) this.renderDarkening(context); if (BlurConfig.darkenTitleScreen) this.renderDarkening(context);
} }
} }

View File

@@ -33,7 +33,7 @@
"blur.mixins.json" "blur.mixins.json"
], ],
"depends": { "depends": {
"minecraft": ">=1.21.2", "minecraft": ">=1.21",
"midnightlib": ">=1.7.3" "midnightlib": ">=1.7.5"
} }
} }

View File

@@ -19,7 +19,7 @@ modrinth_id=NK39zBp2
fabric_loader_version=0.16.13 fabric_loader_version=0.16.13
fabric_api_version=0.115.4+1.21.1 fabric_api_version=0.115.4+1.21.1
neoforge_version=21.1.153 neoforge_version=21.1.192
yarn_mappings_patch_neoforge_version = 1.21+build.4 yarn_mappings_patch_neoforge_version = 1.21+build.4
# Libraries # Libraries

View File

@@ -14,7 +14,7 @@ public class BlurNeoForge {
Blur.init(); Blur.init();
} }
@EventBusSubscriber(modid = Blur.MOD_ID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT) @EventBusSubscriber(modid = Blur.MOD_ID, value = Dist.CLIENT)
public static class ClientGameEvents { public static class ClientGameEvents {
@SubscribeEvent @SubscribeEvent
public static void endClientTick(ClientTickEvent.Post event) { public static void endClientTick(ClientTickEvent.Post event) {

View File

@@ -26,13 +26,13 @@ side = "CLIENT"
[[dependencies.blur]] [[dependencies.blur]]
modId = "minecraft" modId = "minecraft"
mandatory = true mandatory = true
versionRange = "[1.21.2,)" versionRange = "[1.21,1.21.1]"
ordering = "NONE" ordering = "NONE"
side = "CLIENT" side = "CLIENT"
[[dependencies.blur]] [[dependencies.blur]]
modId = "midnightlib" modId = "midnightlib"
mandatory = true mandatory = true
versionRange = "[1.7.3,)" versionRange = "[1.7.5,)"
ordering = "NONE" ordering = "NONE"
side = "CLIENT" side = "CLIENT"