mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-15 11:15:09 +01:00
fix: container blur not working on NeoForge
This commit is contained in:
@@ -3,6 +3,7 @@ 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.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -15,12 +16,28 @@ import static eu.midnightdust.blur.util.RainbowColor.hue;
|
||||
import static eu.midnightdust.blur.util.RainbowColor.hue2;
|
||||
|
||||
public class Blur {
|
||||
public static final String MOD_ID = "blur";
|
||||
public static void init() {
|
||||
BlurConfig.init("blur", BlurConfig.class);
|
||||
BlurConfig.init(MOD_ID, BlurConfig.class);
|
||||
}
|
||||
|
||||
public static boolean doFade = false;
|
||||
|
||||
public static void onRender(DrawContext context, int width, int height, MinecraftClient client) {
|
||||
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
|
||||
client.gameRenderer.renderBlur();
|
||||
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.
|
||||
}
|
||||
|
||||
public static void onScreenChange() {
|
||||
if (screenHasBlur) {
|
||||
if (doFade) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package eu.midnightdust.blur.mixin;
|
||||
|
||||
import eu.midnightdust.blur.Blur;
|
||||
import eu.midnightdust.blur.config.BlurConfig;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
@@ -20,4 +22,8 @@ public class MixinHandledScreen extends Screen {
|
||||
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();
|
||||
}
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,18 +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) {
|
||||
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();
|
||||
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.
|
||||
Blur.onRender(context, width, height, this.client);
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "renderInGameBackground")
|
||||
public void blur$getBackgroundEnabled(DrawContext context, CallbackInfo ci) {
|
||||
|
||||
@@ -8,13 +8,13 @@ import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
|
||||
@Mod(value = "blur", dist = Dist.CLIENT)
|
||||
@Mod(value = Blur.MOD_ID, dist = Dist.CLIENT)
|
||||
public class BlurNeoForge {
|
||||
public BlurNeoForge() {
|
||||
Blur.init();
|
||||
}
|
||||
|
||||
@EventBusSubscriber(modid = "blur", bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(modid = Blur.MOD_ID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
||||
public static class ClientGameEvents {
|
||||
@SubscribeEvent
|
||||
public static void endClientTick(ClientTickEvent.Post event) {
|
||||
|
||||
Reference in New Issue
Block a user