How to get the players from nearby entities?

Discussion in 'Plugin Development' started by joehot2000, Feb 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    joehot2000

    How would i from List<Entity> ent = player.getNearbyEntities(50, 50, 50); get the PLAYERS from that? (that is when the player is sneaking, so i then want to hide the player from the other players).

    It does actuelly surprise me that nobody has even viewed it.

    Ah well, not as if you are my servants ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  2. Offline

    evilmidget38

    joehot2000 Wait at least 12 hours before you bump your own thread. As for your question, iterate through the nearby entities with your preferred method, checking either their EntityType or doing an instanceof check(check if they're an instanceof Player).
     
  3. Offline

    zXCaKeXz

    Code:
    ArrayList<Player> list = new ArrayList<Player>();
    for (Entity e: player.getNearbyEntities(50, 50, 50))
    {
        if (e instanceof Player)
            list.add((Player) e);
    }
    my way of doing it :3
     
  4. Offline

    joehot2000

    My post was already at the top, i simply posted the comment as a comment, not as a bump.

    And, ok

    Oh. a for loop, the one thing i am not good at ;)

    Thanks!

    player.hidePlayer((Player) list);

    Would that then work?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page