11package com .github .kdgaming0 .packcore ;
22
3+ import com .github .kdgaming0 .packcore .command .CommandOpenGui ;
34import com .github .kdgaming0 .packcore .config .ModConfig ;
45import com .github .kdgaming0 .packcore .screen .SEMainMenu ;
56import com .github .kdgaming0 .packcore .utils .ModpackInfo ;
67
78import net .minecraft .client .Minecraft ;
89import net .minecraft .client .gui .GuiMainMenu ;
10+ import net .minecraft .client .gui .GuiScreen ;
911import net .minecraft .client .settings .KeyBinding ;
12+ import net .minecraftforge .client .ClientCommandHandler ;
1013import net .minecraftforge .common .MinecraftForge ;
1114import net .minecraftforge .fml .client .registry .ClientRegistry ;
1215import net .minecraftforge .fml .common .Mod ;
1316import net .minecraftforge .fml .common .event .FMLInitializationEvent ;
1417import net .minecraftforge .fml .common .eventhandler .SubscribeEvent ;
1518import net .minecraftforge .client .event .GuiOpenEvent ;
1619
20+ import net .minecraftforge .fml .common .gameevent .TickEvent ;
1721import org .apache .logging .log4j .LogManager ;
1822import org .apache .logging .log4j .Logger ;
1923import org .lwjgl .input .Keyboard ;
@@ -23,12 +27,12 @@ public class PackCore {
2327 public static final String MOD_ID = "packcore" ;
2428 public static KeyBinding OPEN_GUI_KEY ;
2529 private static final Logger LOGGER = LogManager .getLogger (MOD_ID );
30+ public static GuiScreen screenToOpenNextTick = null ;
2631
2732 @ Mod .EventHandler
2833 public void init (FMLInitializationEvent event ) {
2934 MinecraftForge .EVENT_BUS .register (this );
30- OPEN_GUI_KEY = new KeyBinding ("Open Pack Menu" , Keyboard .KEY_K , "Pack Core" );
31- ClientRegistry .registerKeyBinding (OPEN_GUI_KEY );
35+ ClientCommandHandler .instance .registerCommand (new CommandOpenGui ());
3236 ModpackInfo .loadModpackInfo ();
3337 ModConfig .loadConfig ();
3438 }
@@ -50,4 +54,13 @@ public void onGuiOpen(GuiOpenEvent event) {
5054 }
5155 }
5256 }
57+
58+ @ SubscribeEvent
59+ public void onTick (TickEvent .ClientTickEvent event ) {
60+ if (event .phase == TickEvent .Phase .END ) return ;
61+ if (screenToOpenNextTick != null ) {
62+ Minecraft .getMinecraft ().displayGuiScreen (screenToOpenNextTick );
63+ screenToOpenNextTick = null ;
64+ }
65+ }
5366}
0 commit comments