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

There would be no EntityPlayer instance, but if it is a client thing, I'm sure Minecraft instance would have currentScreen set to GuiMainMenu.

If you want to know when a player leaves in multiplayer, you can use PlayerEvent.PlayerLoggedOutEvent.

  • Author

There would be no EntityPlayer instance, but if it is a client thing, I'm sure Minecraft instance would have currentScreen set to GuiMainMenu.

If you want to know when a player leaves in multiplayer, you can use PlayerEvent.PlayerLoggedOutEvent.

I have music playing from within java, not from within minecraft. So i want that music to stop when I leave the game

Create a new thread when your mod is loading (init function for example)

 

You can code a thing like this (sry i can't try it now):

 

void run() //Make a thread that run as long as the player didn't join the GuiMainMenu or exit the game
{
     while (Minecraft.getMinecraft() != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
    {
          try {
               Thread.sleep(100);
          } catch (Exception e) { }
    }
     if (Minecraft.getMinecraft() != null)
           (new My_Shound()).play;
}

 

That's kinda hardcodded but i can't see any other way

@diesieben07 i'm sorry but i think you didn't understand what DannieXD asked, he would like to know if the current game screen is the main menu, SoundEvents have nothing to do with this

 

And i think (i didn't verify every events yet), that there's no event which are called as long as the user didn't join a world

EDIT: That's why i'm purposing this hardcodded solution

 

(I hope my english wasn't too bad ^^" )

Again i'm sorry, but that's not what he asked :(

 

I want an if statment that checks if the player is on the main menu

 

So if you have any other better way to get if the player is on the main menu (GuiMainMenu), tell me and i'd be really happy cause i'm also doing this check

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.