Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] If player is on main menu?
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Bugzoo

[1.7.10] If player is on main menu?

By Bugzoo, September 6, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Bugzoo    2

Bugzoo

Bugzoo    2

  • Diamond Finder
  • Bugzoo
  • Members
  • 2
  • 268 posts
Posted September 6, 2014

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

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6671

diesieben07

diesieben07    6671

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6671
  • 45601 posts
Posted September 6, 2014

When the main menu is displayed there is no player yet. What are you trying to do?

  • Quote

Share this post


Link to post
Share on other sites

imadnsn    37

imadnsn

imadnsn    37

  • Creeper Killer
  • imadnsn
  • Members
  • 37
  • 186 posts
Posted September 6, 2014

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.

  • Quote

Share this post


Link to post
Share on other sites

Bugzoo    2

Bugzoo

Bugzoo    2

  • Diamond Finder
  • Bugzoo
  • Members
  • 2
  • 268 posts
Posted September 7, 2014

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

  • Quote

Share this post


Link to post
Share on other sites

toss    0

toss

toss    0

  • Tree Puncher
  • toss
  • Members
  • 0
  • 24 posts
Posted September 7, 2014

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

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6671

diesieben07

diesieben07    6671

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6671
  • 45601 posts
Posted September 7, 2014

Ouch. There are SoundEvents for a reason.

  • Quote

Share this post


Link to post
Share on other sites

toss    0

toss

toss    0

  • Tree Puncher
  • toss
  • Members
  • 0
  • 24 posts
Posted September 7, 2014

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

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6671

diesieben07

diesieben07    6671

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6671
  • 45601 posts
Posted September 7, 2014

He wants to play his music from within the game. That can be done with sound events.

  • Quote

Share this post


Link to post
Share on other sites

toss    0

toss

toss    0

  • Tree Puncher
  • toss
  • Members
  • 0
  • 24 posts
Posted September 7, 2014

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

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6671

diesieben07

diesieben07    6671

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6671
  • 45601 posts
Posted September 7, 2014

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

THIS is what he wants. And this is also the problem. Play music through the minecraft system. Don't do your own stuff.
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Rohman
      [1.12.2 Build 2847] Server Crash on startup

      By Rohman · Posted 24 minutes ago

      Here you go. Thanks for having a look. debug(1).log
    • diesieben07
      Server Cannot Start

      By diesieben07 · Posted 45 minutes ago

      You installed a client-only mod (Controllable) on the server. Mods have the ability to indicate their client-only-ness to Forge and it will not load the mod on a server. This mod has not done so, please report this bug to the mod author.
    • diesieben07
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By diesieben07 · Posted 51 minutes ago

      Why would you replace them?! This is a simple method override and you are calling super. There is no need to replace anything. Again: Please learn Java basics before making a mod.
    • diesieben07
      [1.12.2 Build 2847] Server Crash on startup

      By diesieben07 · Posted 54 minutes ago

      Post the debug.log file.
    • diesieben07
      Need your help pls

      By diesieben07 · Posted 54 minutes ago

      1.8.9 is no longer supported on this forum due to it's age. Update to a modern version of Minecraft to receive support.
  • Topics

    • Rohman
      2
      [1.12.2 Build 2847] Server Crash on startup

      By Rohman
      Started 1 hour ago

    • The_Unkown675
      1
      Server Cannot Start

      By The_Unkown675
      Started 4 hours ago

    • J0WAY
      17
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY
      Started Thursday at 10:10 PM

    • _jiriik_
      1
      Need your help pls

      By _jiriik_
      Started 2 hours ago

    • Kuaka
      0
      My Forge 1.12 and 1.12.2 Keep Crashing when i start it up

      By Kuaka
      Started 1 hour ago

  • Who's Online (See full list)

    • Ugdhar
    • vaartis
    • HussNuss
    • AkosM
    • Gnaux
    • Ollie_Bear
    • Kuaka
    • AdieCraft
    • cookiedragon234
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] If player is on main menu?
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community