Jump to content

Recommended Posts

Posted

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);

Posted

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.

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.

Posted

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 :P Probably should've mentioned that...

Posted

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).

1.7.10 is no longer supported by forge, you are on your own.

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.