Jump to content

[1.12.2] [SOLVED] Check if player is on server


SuperHB

Recommended Posts

I'm working on GUI to play pong and I want to add multiplayer to it. I don't want the multiplayer menu to show up when the player is in singleplayer. I have mc.getMinecraft().isSingleplayer() called in the GUI's constructor to check if the player is playing singleplayer or not, but I'm having an issue.

 

This works perfectly fine with dedicated servers, but when playing LAN, players who join isSingleplayer() is false, but true for the host.

 

Is there any other way to fix this? (Or maybe a different way to check if on a server?)

Edited by SuperHB
solved
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Here is a simple condition to check if you are on a server: true.

In all seriousness: Please clarify, Minecraft is always using a server.

I meant if the player is in singleplayer or multiplayer. mc.getMinecraft().isSingleplayer() is false when I connect to a dedicated server or when I join a LAN server, but true if I host one. I thought once I turned on LAN to host, mc.getMinecraft().isSingleplayer() would become false, but it stays true, even if a player joins.

 

Basically, when I host a LAN, I need someway to tell the GUI that the player is no longer playing singleplayer

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.

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

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

Announcements



×
×
  • Create New...

Important Information

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