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

Just for context on how experience I am with this, I started Minecraft modding about a month ago, although have experience in other languages (and a tiny bit of Java) before now.

 

I'm making a client-side mod, and for the life of me I can't figure out how to open a custom GUI via command. I have the following code that works just fine:

@SubscribeEvent
    public void onKeyInput(InputEvent.KeyInputEvent event) {

        // If open GUI key is pressed on Hypixel
        if(QuickPlay.openGui.isKeyDown() && QuickPlay.onHypixel) {
            System.out.println("Open GUI key pressed");
            Minecraft.getMinecraft().displayGuiScreen(new GuiScreen(){});
        }
    }

 

A new, blank GUI is opened when the bound key is pressed and you're on the proper server. Works fine.

 

I now have a separate GUI I was hoping to open from a command ("/qpcolor"). QpColorCommand.java#execute (Implements ICommand):

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
   Minecraft.getMinecraft().displayGuiScreen(new GuiScreen(){});
}

 

QpColorCommand is registered in QuickPlay#postInit:

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
    ClientCommandHandler.instance.registerCommand(new QpColorCommand());
}

 

But, with all of this, /qpcolor does not open the GUI. Everything else in QpColorCommand#execute runs fine! I've Google'd around with no luck. I feel like I'm missing something obvious here, but I'm not sure what. Any advice?

 

Thanks!

 

EDIT:

 

I just checked the source of another mod that opens a GUI via command. It looks like they added a 2-tick delay before opening the GUI. Is this why it is not working for me? Is there a better way around this? Any advice is appreciated.

Edited by bugfroggy
Added info that I went and checked source

  • Author
12 minutes ago, diesieben07 said:

Yes, after the command executes, the chat GUI tells minecraft to close any open GUI, assuming the chat gui itself is still open. If you opened another GUI in between, it gets closed instead.

You have to open the GUI a tick later.

That makes sense! I'll try that. Thank you :)

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.