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.

[1.15] Detect when Player joins world/server for the first time via Events

Featured Replies

Hi

Yes it is.

If you look at the Event class in net.minecraftforge.eventbus.api, then use your IDEA to show you all Events derived from Event, you'll find a long list of possible events which can do just about whatever you want.  If you browse through the list for likely-looking names, it won't take you long to find the appropriate one.  The documentation for Event classes is quite good.

 

-TGG

  • Author
21 minutes ago, TheGreyGhost said:

Hi

Yes it is.

If you look at the Event class in net.minecraftforge.eventbus.api, then use your IDEA to show you all Events derived from Event, you'll find a long list of possible events which can do just about whatever you want.  If you browse through the list for likely-looking names, it won't take you long to find the appropriate one.  The documentation for Event classes is quite good.

 

-TGG

Yes, that worked, but I could only EntityJoinWorldEvent and that seemed close, but wrong. If you know of any other way please tell me

 

PS. It does not need to be an event. Anything will work

Hi

Sounds like EntityJoinWorldEvent is a good enough match?

You can check if the entity is a player.

You can store data in the world that keeps track of every player that has ever joined it (WorldSavedData).

--> you can tell when a player has joined the world/server for the first time.

-TGG

  • Author
Just now, TheGreyGhost said:

hi

Sorry, no I don't.

 

But google shows me that this open source project does, you might try that..

 

https://www.programcreek.com/java-api-examples/?code=DaedalusGame/BetterWithAddons/BetterWithAddons-master/src/main/java/betterwithaddons/handler/TerratorialData.java

 

-TGG

Thanks, I see what I can learn

 

-Kid Koder

  • 2 weeks later...
  • Author
On 4/6/2020 at 4:59 AM, diesieben07 said:

Not sure why WorldSavedData was suggested.

You should instead use a capability registered to the player or getPersistentData.

 

PlayerLoggedInEvent is also more appropriate than EntityJoinWorldEvent.

Great! I'm doing cappibilys, but the totrial I'm using says I need to use the NBTBase class. It apperes to be renamed/removed, what is the new name/replacement?

Thanks,

Kid Koder

 

PS. The tutorial is at https://www.planetminecraft.com/blog/forge-tutorial-capability-system/

Edited by KidKoderMod033109
Added tutorial

  • Author
17 minutes ago, diesieben07 said:

To be honest, capabilities are really overkill here. Just use getPersistentData, all you need to store is a boolean flag.

To learn about capabilities, refer to the documentation.

Oh ya! About that a boolean flag won't really work. I need to store to whole objects into the player. 

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.