Posted December 31, 20195 yr 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?
December 31, 20195 yr 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.
December 31, 20195 yr 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
December 31, 20195 yr Author 8 minutes ago, diesieben07 said: Use a debugger breakpoint? I checked it seems its not called
December 31, 20195 yr 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!
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.