Posted April 4, 20205 yr Hi, I want to be able to detect when the player joins a world/server for the first time using Events. Is this even possible? Thanks in advance, Kid Koder Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 5, 20205 yr 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
April 5, 20205 yr 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 Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 5, 20205 yr 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
April 5, 20205 yr Author Great! Just one problem, I have NO clue how to use WorldSavedData. I have looked at the Forge docs, but it doesn't really help me understand how to use it. Do you have any examples of WorldSavedData? Edited April 5, 20205 yr by KidKoderMod033109 Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 5, 20205 yr 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
April 5, 20205 yr 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 Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 14, 20205 yr 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 April 14, 20205 yr by KidKoderMod033109 Added tutorial Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 14, 20205 yr 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. Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
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.