diff --git a/.gitignore b/.gitignore index fdbc708..c0b3e99 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,10 @@ local.properties run/ logs/ + +# macOS +.DS_Store +**/.DS_Store + +# Local documentation / notes +docs/ diff --git a/build.gradle b/build.gradle index 9ab4ccb..efa64a5 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ plugins { id 'eclipse' id 'maven-publish' id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.8' - id 'com.gtnewhorizons.retrofuturagradle' version '1.4.0' + id 'com.gtnewhorizons.retrofuturagradle' version '1.4.1' id 'net.darkhax.curseforgegradle' version '1.1.24' apply false id 'com.modrinth.minotaur' version '2.8.7' apply false id 'com.diffplug.spotless' version '6.13.0' apply false diff --git a/src/main/java/com/cleanroommc/neverenoughanimations/NEA.java b/src/main/java/com/cleanroommc/neverenoughanimations/NEA.java index eb279e3..cb15938 100644 --- a/src/main/java/com/cleanroommc/neverenoughanimations/NEA.java +++ b/src/main/java/com/cleanroommc/neverenoughanimations/NEA.java @@ -74,6 +74,7 @@ public static void onFrameTick() { public void onGuiTick(TickEvent.ClientTickEvent event) { //OpeningAnimation.checkGuiToClose(); if (event.phase == TickEvent.Phase.END) return; + OpeningAnimation.syncKeyBindsWhileClosing(); ItemHoverAnimation.onGuiTick(); } diff --git a/src/main/java/com/cleanroommc/neverenoughanimations/animations/OpeningAnimation.java b/src/main/java/com/cleanroommc/neverenoughanimations/animations/OpeningAnimation.java index 58722aa..93f0eb1 100644 --- a/src/main/java/com/cleanroommc/neverenoughanimations/animations/OpeningAnimation.java +++ b/src/main/java/com/cleanroommc/neverenoughanimations/animations/OpeningAnimation.java @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.event.GuiOpenEvent; public class OpeningAnimation { @@ -21,8 +22,17 @@ public static boolean onGuiOpen(GuiOpenEvent event) { public static boolean onGuiOpen(GuiScreen screen) { if (screen instanceof IAnimatedScreen animatedScreen) { - if (Minecraft.getMinecraft().currentScreen == null) { + GuiScreen current = Minecraft.getMinecraft().currentScreen; + if (current == null) { animate(animatedScreen, true); + } else if (current == animatedGui && startTime > 0) { + // The currently displayed animated screen is being instantly replaced by another + // animated screen while its opening animation is still running. This happens e.g. in + // creative mode where vanilla first opens GuiInventory and its initGui immediately + // swaps to GuiContainerCreative. Transfer the running opening animation to the new + // screen so neither the opening nor the later closing animation gets lost. + animatedGui = animatedScreen; + lastGui = animatedScreen; } } else if (Minecraft.getMinecraft().currentScreen == lastGui && screen == null && !shouldCloseLast) { if (animatedGui == null || getValue(animatedGui) >= 1f || startTime > 0) { @@ -118,10 +128,17 @@ public static boolean isAnimatingClose(IAnimatedScreen screen) { return isAnimating(screen) && startTime < 0; } + public static void syncKeyBindsWhileClosing() { + if ((lastGui != null && animatedGui == lastGui && startTime < 0) || shouldCloseLast) { + KeyBinding.updateKeyBindState(); + } + } + public static void checkGuiToClose() { if (shouldCloseLast && lastGui != null) { //((GuiScreen) lastGui).allowUserInput = oldAllowAllInteractions; //oldAllowAllInteractions = false; + KeyBinding.updateKeyBindState(); Minecraft.getMinecraft().displayGuiScreen(null); shouldCloseLast = false; lastGui = null;