Jump to content

bugfroggy

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by bugfroggy

  1. 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.

×
×
  • Create New...

Important Information

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