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

Posted

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

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)

  • Author

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.
 

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)

  • Author
8 minutes ago, Cadiboo said:

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

Check who the user if for a permission check in the mod

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)

  • Author
7 minutes ago, Cadiboo said:

Permission checks must be done server side

I am :)
 

7 minutes ago, Cadiboo said:

You can access the player with Event#getPlayer()

But that triggers also when other players join?!

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)

  • Author

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 :/ 

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.

  • Author
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 :)

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.