66import com .cleanroommc .neverenoughanimations .util .Interpolations ;
77import net .minecraft .client .Minecraft ;
88import net .minecraft .client .gui .GuiScreen ;
9- import net .minecraft .client .gui .inventory .GuiContainer ;
109import net .minecraft .client .renderer .GlStateManager ;
1110import net .minecraftforge .client .event .GuiOpenEvent ;
1211
@@ -32,6 +31,7 @@ public static boolean onGuiOpen(GuiOpenEvent event) {
3231
3332 private static IAnimatedScreen lastGui ;
3433 private static IAnimatedScreen animatedGui ;
34+ //private static boolean oldAllowAllInteractions = false;
3535 private static long startTime = 0 ;
3636 private static boolean shouldCloseLast = false ;
3737
@@ -43,6 +43,8 @@ public static void animate(IAnimatedScreen container, boolean open) {
4343 if (!open ) {
4444 startTime = -startTime ;
4545 Minecraft .getMinecraft ().setIngameFocus ();
46+ //oldAllowAllInteractions = ((GuiScreen) container).allowUserInput;
47+ //((GuiScreen) container).allowUserInput = true;
4648 }
4749 }
4850
@@ -51,7 +53,7 @@ public static float getScale(GuiScreen screen) {
5153 }
5254
5355 public static float getScale (IAnimatedScreen container ) {
54- float min = 0.75f , max = 1f ;
56+ float min = NEAConfig . openingStartScale , max = 1f ;
5557 return Interpolations .lerp (min , max , getValue (container ));
5658 }
5759
@@ -82,20 +84,37 @@ public static boolean handleScale(GuiScreen screen, boolean translateToPanel) {
8284 return screen instanceof IAnimatedScreen animatedScreen && handleScale (animatedScreen , translateToPanel );
8385 }
8486
85- public static boolean handleScale (IAnimatedScreen container , boolean translateToPanel ) {
86- float scale = getScale (container );
87+ public static boolean handleScale (IAnimatedScreen screen , boolean translateToPanel ) {
88+ float scale = getScale (screen );
8789 if (scale == 1 || NEAConfig .moveAnimationTime == 0 ) return false ;
88- if (translateToPanel ) GlStateManager .translate (container .nea$getX (), container .nea$getY (), 0 );
89- GlStateManager .translate (container .nea$getWidth () / 2f , container .nea$getHeight () / 2f , 0 );
90+ if (translateToPanel ) GlStateManager .translate (screen .nea$getX (), screen .nea$getY (), 0 );
91+ GlStateManager .translate (screen .nea$getWidth () / 2f , screen .nea$getHeight () / 2f , 0 );
9092 GlStateManager .scale (scale , scale , 1f );
91- GlStateManager .translate (-container .nea$getWidth () / 2f , -container .nea$getHeight () / 2f , 0 );
92- if (translateToPanel ) GlStateManager .translate (-container .nea$getX (), -container .nea$getY (), 0 );
93- // GlStateManager.color(1f, 1f, 1f, scale);
93+ GlStateManager .translate (-screen .nea$getWidth () / 2f , -screen .nea$getHeight () / 2f , 0 );
94+ if (translateToPanel ) GlStateManager .translate (-screen .nea$getX (), -screen .nea$getY (), 0 );
9495 return true ;
9596 }
9697
98+ public static boolean isAnimating (GuiScreen screen ) {
99+ return screen instanceof IAnimatedScreen animatedScreen && isAnimating (animatedScreen );
100+ }
101+
102+ public static boolean isAnimating (IAnimatedScreen screen ) {
103+ return getValue (screen ) < 1f ;
104+ }
105+
106+ public static boolean isAnimatingClose (GuiScreen screen ) {
107+ return screen instanceof IAnimatedScreen animatedScreen && isAnimatingClose (animatedScreen );
108+ }
109+
110+ public static boolean isAnimatingClose (IAnimatedScreen screen ) {
111+ return isAnimating (screen ) && startTime < 0 ;
112+ }
113+
97114 public static void checkGuiToClose () {
98115 if (shouldCloseLast && lastGui != null ) {
116+ //((GuiScreen) lastGui).allowUserInput = oldAllowAllInteractions;
117+ //oldAllowAllInteractions = false;
99118 Minecraft .getMinecraft ().displayGuiScreen (null );
100119 shouldCloseLast = false ;
101120 lastGui = null ;
0 commit comments