Jump to content

Friends ArrayList


MyMommyLovesMe

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.