MyMommyLovesMe Posted August 16, 2016 Posted August 16, 2016 Hello MinecraftForge, can you please help me? If you can do it yourself that would be wonderful but I'm trying to get the Player's IGN once you hit them. Is there a way of doing that. OBJECTIVE: If you a hit player it will add them to a ArrayList called "Friends" once you hit another player it will clear the ArrayList and add the other player, so my idea is like if(Player is hit) Friends.clear(); Friends.add(Player's Display Name); Quote
Matryoshika Posted August 16, 2016 Posted August 16, 2016 To get access to when Player1 hits Player2, I would recommend you subscribe to the LivingHurtEvent and check if both attacker and victim are players, along with whatever other parameters you require. You can get access to the Player's display name from Entity#getDisplayNameString. (Player's extend Entity.) If you are going to do anything with that however, for example saving it, to compare later, I would heavily recommend you use the UUID instead, and simply translate it to the Player's name from the UUID. If the player ever change his name, a name-dependent system will break. Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
MyMommyLovesMe Posted August 16, 2016 Author Posted August 16, 2016 Nah, Its not going to be permanent once you close MC and reopen its suppose to not save or do anything, everything is reset, its just temporary friends. I wouldn't need anything to worry about changing names Probably should've mentioned that... Quote
Ernio Posted August 16, 2016 Posted August 16, 2016 1. Version? 2. Sided mod (present on server) or client-only? 3. Should friend list be ever saved (quit/join world/server)? 4. The logic you described: if(Player is hit) Friends.clear(); Friends.add(Player's Display Name); ...will end up with List being of size == 0 or 1. Is this desired outcome? If yes - don't use List. Make direct reference to EntityPlayer (or null). Quote Quote 1.7.10 is no longer supported by forge, you are on your own.
Recommended Posts
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.