Пример #1
0
  public static void openConfigScreen() {
    for (ModContainer mod : Loader.instance().getModList()) {
      if (mod.getModId() == null) continue;

      if (mod.getModId().equals(Main.MOD_ID)) {
        try {
          IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(mod);
          GuiScreen newScreen =
              guiFactory
                  .mainConfigGuiClass()
                  .getConstructor(GuiScreen.class)
                  .newInstance(Main.mc.currentScreen);
          Main.mc.displayGuiScreen(newScreen);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
Пример #2
0
 @SubscribeEvent
 public void onButtonClickPost(GuiScreenEvent.ActionPerformedEvent.Post event) {
   if (event.gui instanceof GuiOptions) {
     if (event.button.id == 1725) {
       try {
         IModGuiFactory guiFactory =
             FMLClientHandler.instance()
                 .getGuiFactoryFor(Loader.instance().getIndexedModList().get(Reference.MOD_ID));
         GuiScreen newScreen =
             guiFactory
                 .mainConfigGuiClass()
                 .getConstructor(GuiScreen.class)
                 .newInstance(event.gui);
         event.gui.mc.displayGuiScreen(newScreen);
       } catch (Exception ex) {
       }
     }
   }
 }