mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-16 19:55:10 +01:00
port: Chase the Skies (1.21.6)
Surprising amount of changes – even more surprised I got this working so fast :)
This commit is contained in:
@@ -6,7 +6,7 @@ import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix3x2f;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.Double;
|
||||
@@ -92,12 +92,12 @@ public class Blur {
|
||||
float diagonal = Math.sqrt((float) width*width + height*height);
|
||||
int smallestDimension = Math.min(width, height);
|
||||
|
||||
context.getMatrices().push();
|
||||
Matrix4f posMatrix = context.getMatrices().peek().getPositionMatrix();
|
||||
posMatrix.rotationZ(Math.toRadians(getRotation()));
|
||||
posMatrix.setTranslation(width / 2f, height / 2f, -1000); // Make the gradient's center the pivot point
|
||||
context.getMatrices().pushMatrix();
|
||||
Matrix3x2f posMatrix = context.getMatrices();
|
||||
posMatrix.rotate(Math.toRadians(getRotation()));
|
||||
posMatrix.setTranslation(width / 2f, height / 2f); // Make the gradient's center the pivot point
|
||||
posMatrix.scale(diagonal / smallestDimension); // Scales the gradient to the maximum diagonal value needed
|
||||
context.fillGradient(-width / 2, -height / 2, width / 2, height / 2, Blur.getBackgroundColor(false), Blur.getBackgroundColor(true)); // Actually draw the gradient
|
||||
context.getMatrices().pop();
|
||||
context.getMatrices().popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ 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))
|
||||
@Redirect(method = "<init>", at = @At(value = "NEW", target = "net/minecraft/client/option/SimpleOption$ValidatingIntSliderCallbacks", ordinal = 3))
|
||||
private SimpleOption.ValidatingIntSliderCallbacks blur$increaseMaxBlurriness(int minInclusive, int maxInclusive) {
|
||||
if (this.menuBackgroundBlurriness == null && this.chatLineSpacing != null)
|
||||
return new SimpleOption.ValidatingIntSliderCallbacks(minInclusive, 20);
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
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.BlurInfo;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinGameRenderer {
|
||||
@ModifyVariable(method = "renderBlur", at = @At("STORE"), ordinal = 0)
|
||||
private float blur$modifyRadius(float radius) { // Modify the radius based on the animation progress
|
||||
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getMenuBackgroundBlurrinessValue()I"))
|
||||
private int blur$modifyRadius(GameOptions instance, Operation<Integer> original) {
|
||||
int radius = instance.getMenuBackgroundBlurrinessValue();
|
||||
if (!BlurInfo.screenChanged && BlurInfo.start >= 0) // Only update the progress after all tests have been completed
|
||||
Blur.updateProgress(BlurInfo.screenHasBlur);
|
||||
return radius * BlurInfo.progress;
|
||||
return (int) (radius * BlurInfo.progress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ 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))
|
||||
private void blur$renderContainerBlur(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { // Applies the blur effect in containers (Inventory, Chest, etc.)
|
||||
if (BlurConfig.blurContainers) this.applyBlur();
|
||||
if (BlurConfig.blurContainers) this.applyBlur(context);
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MixinInGameHud {
|
||||
if (client.currentScreen == null && client.world != null && BlurInfo.start >= 0 && BlurInfo.prevScreenHasBlur) {
|
||||
BlurInfo.doTest = false;
|
||||
BlurInfo.screenChanged = false;
|
||||
this.client.gameRenderer.renderBlur();
|
||||
context.applyBlur();
|
||||
|
||||
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class MixinScreen {
|
||||
@Shadow protected MinecraftClient client;
|
||||
@Shadow public int width;
|
||||
@Shadow public int height;
|
||||
@Shadow protected abstract void applyBlur();
|
||||
@Shadow protected abstract void applyBlur(DrawContext context);
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
@@ -58,7 +58,7 @@ public abstract class MixinScreen {
|
||||
private void blur$renderGradient(DrawContext context) {
|
||||
BlurInfo.screenHasBackground = true; // Test if the screen has a background
|
||||
if (BlurConfig.forceEnabledScreens.contains(this.getClass().getCanonicalName()))
|
||||
this.applyBlur();
|
||||
this.applyBlur(context);
|
||||
|
||||
Blur.renderRotatedGradient(context, width, height); // Replaces the default gradient with our rotated one
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ public abstract class MixinTitleScreen extends Screen {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "renderPanoramaBackground", at = @At("TAIL"))
|
||||
private void blur$renderTitleBlur(DrawContext context, float delta, CallbackInfo ci) { // Applies the blur effect in containers (Inventory, Chest, etc.)
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;renderPanoramaBackground(Lnet/minecraft/client/gui/DrawContext;F)V"))
|
||||
private void blur$renderTitleBlur(DrawContext context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) {
|
||||
if (BlurConfig.blurTitleScreen) {
|
||||
Blur.updateProgress(true);
|
||||
this.applyBlur();
|
||||
this.applyBlur(context);
|
||||
if (BlurConfig.darkenTitleScreen) this.renderDarkening(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public interface ScreenAccessor {
|
||||
@Invoker("applyBlur")
|
||||
void forceApplyBlur();
|
||||
}
|
||||
@@ -10,8 +10,7 @@
|
||||
"MixinInGameHud",
|
||||
"MixinMinecraftClient",
|
||||
"MixinScreen",
|
||||
"MixinTitleScreen",
|
||||
"ScreenAccessor"
|
||||
"MixinTitleScreen"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user