mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-16 19:55:10 +01:00
Architectury port, EMI compat
This commit is contained in:
85
common/src/main/java/eu/midnightdust/blur/Blur.java
Normal file
85
common/src/main/java/eu/midnightdust/blur/Blur.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package eu.midnightdust.blur;
|
||||
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
import eu.midnightdust.blur.util.RainbowColor;
|
||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.Double;
|
||||
|
||||
import static eu.midnightdust.blur.BlurInfo.*;
|
||||
import static eu.midnightdust.blur.util.RainbowColor.hue;
|
||||
import static eu.midnightdust.blur.util.RainbowColor.hue2;
|
||||
|
||||
public class Blur {
|
||||
public static void init() {
|
||||
BlurConfig.init("blur", BlurConfig.class);
|
||||
}
|
||||
|
||||
public static boolean doFade = false;
|
||||
|
||||
public static void onScreenChange() {
|
||||
if (screenHasBlur) {
|
||||
if (doFade) {
|
||||
start = System.currentTimeMillis();
|
||||
doFade = false;
|
||||
}
|
||||
} else if (prevScreenHasBlur && BlurConfig.fadeOutTimeMillis > 0) {
|
||||
start = System.currentTimeMillis();
|
||||
doFade = true;
|
||||
} else {
|
||||
start = -1;
|
||||
doFade = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateProgress(boolean fadeIn) {
|
||||
double x;
|
||||
if (fadeIn) {
|
||||
x = Math.min((System.currentTimeMillis() - start) / (double) BlurConfig.fadeTimeMillis, 1);
|
||||
}
|
||||
else {
|
||||
x = Math.max(1 + (start - System.currentTimeMillis()) / (double) BlurConfig.fadeOutTimeMillis, 0);
|
||||
if (x <= 0) {
|
||||
start = -1;
|
||||
}
|
||||
}
|
||||
x = BlurConfig.animationCurve.apply(x, fadeIn);
|
||||
x = Math.clamp(0, 1, x);
|
||||
|
||||
progress = Double.valueOf(x).floatValue();
|
||||
}
|
||||
|
||||
public static int getBackgroundColor(boolean second) {
|
||||
int a = second ? BlurConfig.gradientEndAlpha : BlurConfig.gradientStartAlpha;
|
||||
var col = MidnightColorUtil.hex2Rgb(second ? BlurConfig.gradientEnd : BlurConfig.gradientStart);
|
||||
if (BlurConfig.rainbowMode) col = second ? Color.getHSBColor(hue, 1, 1) : Color.getHSBColor(hue2, 1, 1);
|
||||
int r = (col.getRGB() >> 16) & 0xFF;
|
||||
int b = (col.getRGB() >> 8) & 0xFF;
|
||||
int g = col.getRGB() & 0xFF;
|
||||
float prog = progress;
|
||||
a *= prog;
|
||||
r *= prog;
|
||||
g *= prog;
|
||||
b *= prog;
|
||||
return a << 24 | r << 16 | b << 8 | g;
|
||||
}
|
||||
public static int getRotation() {
|
||||
if (BlurConfig.rainbowMode) return RainbowColor.rotation;
|
||||
return BlurConfig.gradientRotation;
|
||||
}
|
||||
public static void renderRotatedGradient(DrawContext context, int width, int height) {
|
||||
float diagonal = Math.sqrt((float) width*width + height*height);
|
||||
int smallestDimension = Math.min(width, height);
|
||||
|
||||
Matrix4f posMatrix = context.getMatrices().peek().getPositionMatrix();
|
||||
posMatrix.rotationZ(Math.toRadians(getRotation()));
|
||||
posMatrix.setTranslation(width / 2f, height / 2f, 0); // 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
|
||||
posMatrix.rotationZ(0);
|
||||
}
|
||||
}
|
||||
28
common/src/main/java/eu/midnightdust/blur/BlurInfo.java
Normal file
28
common/src/main/java/eu/midnightdust/blur/BlurInfo.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package eu.midnightdust.blur;
|
||||
|
||||
public class BlurInfo {
|
||||
public static long start;
|
||||
public static float progress;
|
||||
|
||||
public static boolean prevScreenHasBlur;
|
||||
public static boolean screenHasBlur;
|
||||
|
||||
public static boolean prevScreenHasBackground;
|
||||
public static boolean screenHasBackground;
|
||||
|
||||
public static boolean doTest = true;
|
||||
public static boolean screenChanged = true;
|
||||
public static long lastScreenChange = System.currentTimeMillis();
|
||||
|
||||
public static void reset() {
|
||||
// Here, we reset all tests, to check if the new screen has blur and/or a background
|
||||
prevScreenHasBlur = screenHasBlur;
|
||||
prevScreenHasBackground = screenHasBackground;
|
||||
screenHasBlur = false;
|
||||
screenHasBackground = false;
|
||||
doTest = true;
|
||||
screenChanged = true;
|
||||
start = -1;
|
||||
lastScreenChange = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package eu.midnightdust.blur.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
|
||||
public class BlurConfig extends MidnightConfig {
|
||||
public static final String ANIMATIONS = "animations";
|
||||
public static final String STYLE = "style";
|
||||
public static final String SCREENS = "screens";
|
||||
@Entry @Hidden public static int configVersion = 2;
|
||||
|
||||
@Entry(category = SCREENS)
|
||||
public static boolean blurContainers = true;
|
||||
@Entry(category = ANIMATIONS, min = 0, max = 2000, isSlider = true)
|
||||
public static int fadeTimeMillis = 300;
|
||||
@Entry(category = ANIMATIONS, min = 0, max = 2000, isSlider = true)
|
||||
public static int fadeOutTimeMillis = 300;
|
||||
@Entry(category = ANIMATIONS)
|
||||
public static BlurConfig.Easing animationCurve = Easing.FLAT;
|
||||
@Entry(category = STYLE)
|
||||
public static boolean useGradient = true;
|
||||
@Entry(category = STYLE, isColor = true, width = 7, min = 7)
|
||||
public static String gradientStart = "#000000";
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 255)
|
||||
public static int gradientStartAlpha = 75;
|
||||
@Entry(category = STYLE, isColor = true, width = 7, min = 7)
|
||||
public static String gradientEnd = "#000000";
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 255)
|
||||
public static int gradientEndAlpha = 75;
|
||||
@Entry(category = STYLE, isSlider = true, min = 0, max = 360)
|
||||
public static int gradientRotation = 0;
|
||||
@Entry(category = STYLE)
|
||||
public static boolean rainbowMode = false;
|
||||
@Entry(category = SCREENS) // Screens where Blur+ should not apply transition effects (mostly dynamically blurred screens)
|
||||
public static List<String> excludedScreens = Lists.newArrayList("net.irisshaders.iris.gui.screen.ShaderPackScreen");
|
||||
@Entry(category = SCREENS) // Screens where the vanilla blur effect should be force enabled
|
||||
public static List<String> forceEnabledScreens = Lists.newArrayList();
|
||||
@Entry(category = SCREENS) // Screens where the vanilla blur effect should be force disabled
|
||||
public static List<String> forceDisabledScreens = Lists.newArrayList();
|
||||
|
||||
public enum Easing {
|
||||
// Based on https://gist.github.com/dev-hydrogen/21a66f83f0386123e0c0acf107254843
|
||||
// Thank you very much!
|
||||
|
||||
FLAT(x -> x, x -> x),
|
||||
SINE(x -> 1 - cos(x * PI) / 2, x -> sin(x * PI) / 2),
|
||||
QUAD(x -> x * x, x -> 1 - (1 - x) * (1 - x)),
|
||||
CUBIC(x -> x * x * x, x -> 1 - pow(1 - x, 3)),
|
||||
QUART(x -> x * x * x * x, x -> 1 - pow(1 - x, 4)),
|
||||
QUINT(x -> x * x * x * x * x, x -> 1 - pow(1 - x, 5)),
|
||||
EXPO(x -> x == 0 ? 0 : pow(2, 10 * x - 10), x -> x == 1 ? 1 : 1 - pow(2, -10 * x)),
|
||||
CIRC(x -> 1 - sqrt(1 - pow(x, 2)), x -> sqrt(1 - pow(x - 1, 2))),
|
||||
BACK(x -> 2.70158 * x * x * x - 1.70158 * x * x,x -> 1 + 2.70158 * pow(x - 1, 3) + 1.70158 * pow(x - 1, 2)),
|
||||
ELASTIC(x -> x == 0 ? 0 : x == 1 ? 1 : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * ((2 * PI) / 3)), x -> x == 0 ? 0 : x == 1 ? 1 : pow(2, -10 * x) * sin((x * 10 - 0.75) * ((2 * PI) / 3)) + 1);
|
||||
|
||||
final Function<Double, Number> functionIn;
|
||||
final Function<Double, Number> functionOut;
|
||||
|
||||
Easing(Function<Double, Number> functionIn, Function<Double, Number> functionOut) {
|
||||
this.functionIn = functionIn;
|
||||
this.functionOut = functionOut;
|
||||
}
|
||||
public Double apply(Double x, boolean in) {
|
||||
if (in) return functionIn.apply(x).doubleValue();
|
||||
return functionOut.apply(x).doubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of midnightcontrols.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlurMixinPlugin implements IMixinConfigPlugin {
|
||||
private String mixinPackage;
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
this.mixinPackage = mixinPackage + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
final String mixinName = mixinClassName.substring(this.mixinPackage.length());
|
||||
final String packageName = mixinName.substring(0, mixinName.lastIndexOf('.'));
|
||||
|
||||
if (packageName.startsWith("emi") && !PlatformFunctions.isModLoaded("emi"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.Blur;
|
||||
import eu.midnightdust.blur.BlurInfo;
|
||||
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 = 1)
|
||||
private float blur$modifyRadius(float radius) { // Modify the radius based on the animation progress
|
||||
if (!BlurInfo.screenChanged && BlurInfo.start >= 0) // Only update the progress after all tests have been completed
|
||||
Blur.updateProgress(BlurInfo.screenHasBlur);
|
||||
return radius * BlurInfo.progress;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(HandledScreen.class)
|
||||
public class MixinHandledScreen extends Screen {
|
||||
protected MixinHandledScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@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(delta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.Blur;
|
||||
import eu.midnightdust.blur.BlurInfo;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
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(InGameHud.class)
|
||||
public class MixinInGameHud {
|
||||
@Final @Shadow private MinecraftClient client;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
public void blur$renderFadeOut(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { // Adds a fade-out effect when a player is in a world and closes all screens
|
||||
if (client.currentScreen == null && client.world != null && BlurInfo.start >= 0 && BlurInfo.prevScreenHasBlur) {
|
||||
BlurInfo.doTest = false;
|
||||
BlurInfo.screenChanged = false;
|
||||
this.client.gameRenderer.renderBlur(tickCounter.getTickDelta(true));
|
||||
this.client.getFramebuffer().beginWrite(false);
|
||||
|
||||
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
31
common/src/main/java/eu/midnightdust/blur/mixin/MixinMinecraftClient.java
Executable file
31
common/src/main/java/eu/midnightdust/blur/mixin/MixinMinecraftClient.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.Blur;
|
||||
import eu.midnightdust.blur.BlurInfo;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class MixinMinecraftClient {
|
||||
|
||||
@Inject(method = "setScreen",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
opcode = Opcodes.PUTFIELD))
|
||||
private void blur$onScreenOpen(Screen newScreen, CallbackInfo info) {
|
||||
if (BlurInfo.lastScreenChange < System.currentTimeMillis() - 100) { // For some reason, in certain scenarios the screen is set to a new one multiple times in a tick. We want to avoid that.
|
||||
|
||||
// Here, we reset all tests, to check if the new screen has blur and/or a background
|
||||
BlurInfo.reset();
|
||||
|
||||
// Manually activate the onScreenChange method when all screens are closed (in-game)
|
||||
if (newScreen == null) Blur.onScreenChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
71
common/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java
Executable file
71
common/src/main/java/eu/midnightdust/blur/mixin/MixinScreen.java
Executable file
@@ -0,0 +1,71 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.BlurInfo;
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
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 eu.midnightdust.blur.Blur;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen {
|
||||
@Shadow @Final protected Text title;
|
||||
@Shadow protected MinecraftClient client;
|
||||
@Shadow public abstract void renderInGameBackground(DrawContext context);
|
||||
@Shadow public int width;
|
||||
@Shadow public int height;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$processScreenChange(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (!BlurInfo.doTest && BlurInfo.screenChanged) { // After the tests for blur and background color have been completed
|
||||
Blur.onScreenChange();
|
||||
BlurInfo.screenChanged = false;
|
||||
}
|
||||
|
||||
if (BlurInfo.start >= 0 && !BlurInfo.screenHasBlur && BlurInfo.prevScreenHasBlur) { // Fade out in non-blurred screens
|
||||
this.client.gameRenderer.renderBlur(delta);
|
||||
this.client.getFramebuffer().beginWrite(false);
|
||||
|
||||
if (BlurInfo.prevScreenHasBackground) Blur.renderRotatedGradient(context, width, height);
|
||||
}
|
||||
BlurInfo.doTest = false; // Set the test state to completed, as tests will happen in the same tick.
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "renderInGameBackground")
|
||||
public void blur$getBackgroundEnabled(DrawContext context, CallbackInfo ci) {
|
||||
BlurInfo.screenHasBackground = true; // Test if the screen has a background
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "applyBlur", cancellable = true)
|
||||
public void blur$getBlurEnabled(float delta, CallbackInfo ci) {
|
||||
if (BlurConfig.forceDisabledScreens.contains(this.getClass().toString())) {
|
||||
ci.cancel(); return;
|
||||
}
|
||||
if (!BlurConfig.excludedScreens.contains(this.getClass().toString()))
|
||||
BlurInfo.screenHasBlur = true; // Test if the screen has blur
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "renderDarkening(Lnet/minecraft/client/gui/DrawContext;IIII)V", cancellable = true)
|
||||
public void blur$applyGradient(DrawContext context, int x, int y, int width, int height, CallbackInfo ci) {
|
||||
if (BlurConfig.useGradient) { // Replaces the background texture with a gradient
|
||||
renderInGameBackground(context);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "renderInGameBackground", cancellable = true)
|
||||
public void blur$rotatedGradient(DrawContext context, CallbackInfo ci) {
|
||||
if (BlurConfig.forceEnabledScreens.contains(this.getClass().toString()))
|
||||
(((ScreenAccessor)this)).forceApplyBlur(client.getRenderTickCounter().getTickDelta(true)); // Applies the blur effect in force-enabled screens
|
||||
|
||||
Blur.renderRotatedGradient(context, width, height); // Replaces the default gradient with our rotated one
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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(float delta);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package eu.midnightdust.blur.mixin.emi;
|
||||
|
||||
import dev.emi.emi.screen.RecipeScreen;
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RecipeScreen.class)
|
||||
public class MixinRecipeScreen extends Screen {
|
||||
|
||||
protected MixinRecipeScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "render")
|
||||
public void blur$addBlurEffect(DrawContext raw, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (BlurConfig.blurContainers) this.applyBlur(delta);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package eu.midnightdust.blur.util;
|
||||
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
|
||||
public class RainbowColor {
|
||||
public static int rotation;
|
||||
public static float hue;
|
||||
public static float hue2 = 0.35f;
|
||||
|
||||
public static void tick() {
|
||||
if (BlurConfig.rainbowMode) {
|
||||
if (hue >= 1) hue = 0f;
|
||||
hue += 0.01f;
|
||||
if (hue2 >= 1) hue2 = 0f;
|
||||
hue2 += 0.01f;
|
||||
|
||||
if (rotation >= 360) rotation = 0;
|
||||
rotation += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user