Jump to content

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


KidKoderMod033109

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...
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
Link to comment
Share on other sites

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. 

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.