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

Hello.

My problem is that I created a new replacement for Main Menu GUI:
 

package hu.test.gui;

import java.io.IOException;

import hu.test.utils.References;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;

@SideOnly(Side.CLIENT)
public class GuiTestMainMenu extends GuiScreen {

	private static final ResourceLocation logo = new ResourceLocation(References.MOD_ID, "logo.png");
    private static final ResourceLocation background = new ResourceLocation(References.MOD_ID, "background.png");
	
    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        drawDefaultBackground();
        drawCenteredString(this.fontRenderer, "thi is a test", 10, 10, 0xc80000);
        super.drawScreen(mouseX, mouseY, partialTicks);
    }

    @Override
    public void initGui() {
        super.initGui();
    }

    @Override
    protected void actionPerformed(GuiButton button) throws IOException {
        super.actionPerformed(button);
    }
    
    @Override
    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
        super.mouseClicked(mouseX, mouseY, mouseButton);
    }
	
}

And this is how I want to replace the MainMenu with mine.
 

@Mod.EventBusSubscriber
public static class EventHandlers
{
	@SideOnly(Side.CLIENT)
	@SubscribeEvent
	public void openGui(GuiOpenEvent event) {
		if (event.getGui() instanceof GuiOptions) {
				event.setGui(new GuiTestMainMenu());
				System.out.println("fastdqwefqwefqwefwqe");
		}
	}
}

The problem is that I experience no errors but I dont even see the log in the console.
What is the problem with my code?

  • Author
1 minute ago, diesieben07 said:

Do no use @SideOnly. Your code checks for GuiOptions. Did you open that?

Oh sorry it shoudl be GuiMainMenu But I removed sideonly not working too.

  • Author
3 minutes ago, diesieben07 said:

Post updated code. Is your event handler being called?

@Mod.EventBusSubscriber
	  public static class EventHandlers
	  {
		@SubscribeEvent
		public void openGui(GuiOpenEvent event) {
			if (event.getGui() instanceof GuiMainMenu) {
					event.setGui(new GuiKodaikMainMenu());
					System.out.println("fastdqwefqwefqwefwqe");
			}
		}
}

how do i know if its called?
sorry i have little experience in modding
I used to code plugins not mods, i just learning :)

  • Author
8 minutes ago, diesieben07 said:

Use a debugger breakpoint?

I checked it seems its not called

  • Author
4 minutes ago, diesieben07 said:

Oops, totally missed it. Your method needs to be static to use @EventBusSubscriber. Please re-read the event documentationn.

Thnak you!
Now it's working! :D

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.