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

I am trying to make a command open a GuiScreen, but when I send the command it doesn't open. I've heard it's because when the chat closes it closes all open GUIs, so I tried listeneing to GuiOpen event and if it's my GUI set a boolean to true, and if the GUI is null and the boolean is true set it to false and open my GUI. But still nothing happens. No errors or anything.

Code:

GuiScreen:

private List<GuiButton> overlayConfig = new ArrayList<GuiButton>();

@Override
public void initGui() {
    super.initGui();
    overlayConfig.add(new GuiButton(0, 50, 50, "True"));
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    drawDefaultBackground();
    overlayConfig.get(0).drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
    overlayConfig.get(0).displayString = "";
    super.drawScreen(mouseX, mouseY, partialTicks);
}

@Override
protected void mouseClicked(int x, int y, int button) {
    for (GuiButton config : overlayConfig) {
        if (config.mousePressed(Minecraft.getMinecraft(), x, y)) {
            config.enabled = !config.enabled;
        }
    }
}

Command execute code:

if (sender.getEntityWorld().isRemote)
            Minecraft.getMinecraft().displayGuiScreen(new ConfigMenu());

Event listener to try and fix my problems:

@SubscribeEvent
    public void onGuiClose(GuiOpenEvent event) {
        if(event.gui == null && justOpened) {
            Minecraft.getMinecraft().displayGuiScreen(new ConfigMenu());
            justOpened = false;
        }
        if(event.gui != null && event.gui.getClass().equals(ConfigMenu.class)) {
            justOpened = true;
        }
    }

The event is registered in my ClientProxy's postInit.

  • Author
3 hours ago, diesieben07 said:
  • Assuming this is a client-side command (ClientCommandHandler). If not, you need packets and ignore the remaining points.
  • The isRemote check is completely pointless, you are already on the client.
  • You need to wait a tick, i.e. listen for ClientTickEvent (make sure to check TickEvent#phase).

How would I wait a tick? Would I add it into the command's code, and just delay the entire thing a tick? I don't think I could do that because I think the mod is on the same thread as Minecraft. Idk I just need you to be a little less vague maybe on I should go about this.

 

Nevermind I figured it out myself. I just added a event every tick to check a boolean to see if the command was run, if so set another boolean to true and set boolean 1 to false, then if boolean 1 is false and boolean 2 is true I run the cmd.

Edited by Big_Bad_E

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.