Player hasLineOfSight() - always true

Discussion in 'Plugin Development' started by TichoCZ, Dec 27, 2012.

Thread Status:
Not open for further replies.
  1. I tested hasLineOfSight() method with some entities and found that method always return true for Player and Spider. But with Villager (and some other entities) was sufficiently accurate with returning true/false. Is there any way how can I use this method with Villager-like "line of sight" but for Player? Best solution I found is:
    1) spawn temporary entity with "right line of sight" (e.g Bat because it's small) on player's location​
    2) check its line of sight​
    3) de-spawn temp entity​
    But this solution have one small problem. Temporary entity appear for a small amount of time.​
    Know anybody how solve this better?​
    I'm still quite beginner in Java/Bukkit.​
     
  2. Offline

    fireblast709

    what are you trying to do?
     
  3. Check if player can see other player
     
  4. Offline

    Chlorek

    I am interested with that problem too. Anyone can help?

    #Edit
    I found trick. Spawning entity (eg. bat) when spawning mobs is disabled it works fine :D
     
  5. Offline

    chasechocolate

    if(player.canSee(otherplayer))?
     
  6. Offline

    caldabeast

    That works with invisibility and such, not with actual line of sight.
     
  7. :D I programming special gametype and I don't need hostile mobs. So I can spawn Sliverfish and it never appear. But it isn't solution for everyone. I think somebody familiar with net.minecraft.server and maybe packets can do this.

    EDIT: Just realized I can cancel CreatureSpawnEvent with specific EntityType. And... IT WORKS! But I must say goodbye to one EntityType.
     
Thread Status:
Not open for further replies.

Share This Page