Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

In my mod, I need to swap out the vanilla main menu (GuiMainMenu) for a custom main menu GUI that I wrote. I actually implemented this a couple of months ago using a solution I read about on the Minecraft Forums.

 

Basically, since Minecraft/FML/Forge does not post any kind of event (that I know of) when the GUI changes, I have a tick handler that checks to see if GuiMainMenu is being shown, and if it is, switches it with my custom menu. Here's the pertinent part of the TickHandler:

 

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	Minecraft mc = Minecraft.getMinecraft();
	if(mc.currentScreen instanceof GuiMainMenu) {
		mc.displayGuiScreen(ClientProxy.mainMenu);
	}
}

 

This works almost perfectly, with the exception that the vanilla main menu shows up for a fraction of a second before the TickHandler realizes and swaps it out. When I wrote this a couple of months ago, I decided that it wasn't worth pursuing further at the time.

 

Obviously I could make this work seamlessly by editing base classes, but since the code controlling the display of the initial GuiMainMenu is in Minecraft.java...that would be a very bad idea if I wanted any compatibility at all with other mods.

 

Is my hack-ish solution with the TickHandler the best way to do this at the moment? I've seen other mods do stuff like this seamlessly, but none of them are open source.

 

If there isn't any better method, I might consider writing a PR to get some kind of Forge support for GUI substitution like this. Just curious what your thoughts are.

  • Author

In my mod, I need to swap out the vanilla main menu (GuiMainMenu) for a custom main menu GUI that I wrote. I actually implemented this a couple of months ago using a solution I read about on the Minecraft Forums.

 

Basically, since Minecraft/FML/Forge does not post any kind of event (that I know of) when the GUI changes, I have a tick handler that checks to see if GuiMainMenu is being shown, and if it is, switches it with my custom menu. Here's the pertinent part of the TickHandler:

 

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	Minecraft mc = Minecraft.getMinecraft();
	if(mc.currentScreen instanceof GuiMainMenu) {
		mc.displayGuiScreen(ClientProxy.mainMenu);
	}
}

 

This works almost perfectly, with the exception that the vanilla main menu shows up for a fraction of a second before the TickHandler realizes and swaps it out. When I wrote this a couple of months ago, I decided that it wasn't worth pursuing further at the time.

 

Obviously I could make this work seamlessly by editing base classes, but since the code controlling the display of the initial GuiMainMenu is in Minecraft.java...that would be a very bad idea if I wanted any compatibility at all with other mods.

 

Is my hack-ish solution with the TickHandler the best way to do this at the moment? I've seen other mods do stuff like this seamlessly, but none of them are open source.

 

If there isn't any better method, I might consider writing a PR to get some kind of Forge support for GUI substitution like this. Just curious what your thoughts are.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.