Jump to content

[1.7.10] If player is on main menu?


Recommended Posts

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

Link to comment
Share on other sites

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 {
          } catch (Exception e) { }
     if (Minecraft.getMinecraft() != null)
           (new My_Shound()).play;


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

Link to comment
Share on other sites

@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 ^^" )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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