Player come into view event... or Something of the sort

Discussion in 'Plugin Development' started by meguy26, Aug 28, 2015.

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

    meguy26

    Does Bukkit has a nice event that triggers when one player can start seeing another? As in, when a player becomes visible to another an event is fired. I heard 'rumors' that Bukkit had this event, but I haven't found documentation on it yet in the Java docs.
     
  2. Offline

    blablubbabc

    Nope, I don't think so.
     
  3. @meguy26
    There's no event, however, a packet is sent to spawn the player. Using ProtocolLib you could listen for it.
     
    Konato_K likes this.
  4. Offline

    au2001

    @meguy26 The javadoc is for 1.7 though, if it has been added in bukkit alternatives it won't be shown.
     
  5. Offline

    meguy26

    @au2001
    I know, I looked through both Spigot's and Bukkit's.

    To others:
    Thanks for responding, ill look into ProtocolLib or find a different solution.
     
  6. Offline

    teej107

    @meguy26 it's all client side. One's client could have his POV changed. You can check to see if the player's crossheirs are pointing at a player.
     
  7. Offline

    meguy26

    @teej107
    That is simply not possible. The server must at the very least tell the client where other players are..

    Edit: well, proximity would work to, but whatever, I found a solution for my problem, albeit an unconventional one.
     
  8. Offline

    au2001

    @meguy26 You could try using Player#hasLineOfSight(Entity) to see if the player can see the other player.
    Then get the first player's eye direction and the difference between the other player's location.
    If it's less or equal to 45° or something like that (also check for Y), then the player should see the other.

    Might be more complicated than your way (but probably more reliable).
     
  9. Offline

    meguy26

    @au2001
    Yes, I know I can check if a player can see another, but what I wanted to do was do something when a player first comes into range of another.
     
  10. Offline

    teej107

    Yes, the server does tell the player's full location (coords, yaw, pitch) but when a Player first comes into sight, it is impossible because it is client side and due to the POV. You can however just spread the search radius the further the block is from the player to attempt to catch that players that could be in the sight of the player. I don't know how expensive that'll be though.
     
Thread Status:
Not open for further replies.

Share This Page