Jump to content

[1.13.2] Client server join event


ImANoobApperntly

Recommended Posts

Hey, I am trying to get a event triggered on whenever the user joins a server.
nothing I've tried seem to be working though
I have tried the EntityJoinWorldEvent but that crashes my game if I join singleplayer.
PlayerEvent.PlayerLoggedInEvent only works on singleplayer and also triggers when someone else joins if I open it to lan.
and I cant call the Minecraft.getInstance().player; in the class because its null all the time.

also I tried calling the Minecraft.getInstance().player in the FMLClientSetupEvent but thats also equals to null
when is the player not null?...

Thank you in advance.

Edited by ImANoobApperntly
Added more info
Link to comment
Share on other sites

What are you trying to do, from an end-user perspective? Minecraft#getInstance is setup very, very early and shouldn’t be null in that event.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Im sorry I ment the Minecraft#getInstance#player
the player is still null when I tried calling it in the fmlSetupClientEvent
I wanna check there username and uuid for when they start the mod
but since I coudn't get the player in the FMLClientSetupEvent I tried on a server/world join but can't get that to work either.
 

Link to comment
Share on other sites

59 minutes ago, Cadiboo said:

What are you trying to do, from an end-user perspective?

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Permission checks must be done server side.
The player event is called right before Minecraft#player is set. You can access the player with Event#getPlayer()

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

1 hour ago, ImANoobApperntly said:

I am :)

Minecraft is a client only class.

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

When using the PlayerEvent it triggers when ever any user joins the server (open the world to lan and join with second minecraft) and Minecraft#player is still null in the event for some reason
also PlayerEvent doesn't get called when joining a server (opening the other minecrafts lan)

all I need is the mc name + uuid in either when joining a server or in the home screen of minecraft.
but I cant seem to get the events to trigger when joining a server and Minecraft#player is always null :/ 

Link to comment
Share on other sites

5 hours ago, ImANoobApperntly said:

but I cant seem to get the events to trigger when joining a server and Minecraft#player is always null :/ 

Further to what everyone else has said - use the EntityJoinWorldEvent#getEntity() method, checking if it's instanceof EntityPlayer.

Attempting to use the Minecraft class server side will crash your game when run on a dedicated server, because Minecraft doesn't exist server-side.  So drop that idea now, it's a non-starter.

  • Thanks 1
Link to comment
Share on other sites

6 hours ago, desht said:

Further to what everyone else has said - use the EntityJoinWorldEvent#getEntity() method, checking if it's instanceof EntityPlayer.

Attempting to use the Minecraft class server side will crash your game when run on a dedicated server, because Minecraft doesn't exist server-side.  So drop that idea now, it's a non-starter

Thank you very much that worked just as I wanted :)

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.