Discussion in 'Plugin Help/Development/Requests' started by VortexGmer, May 18, 2015.
So I have this and when I face the opposite direction They are still affected?
Does this happen to all entities? What version of Bukkit do you have?
@VortexGmer its because p.haslineofsight() is checking if they can see anything or if there dead
No it doesn't. It checks whether they can see the entity specified.
Yes, And it doesn't work!
@VortexGmer You should answer the questions above, and provide the code that you are using
I think you may misunderstand the method. It returns true if an entity is capable of seeing the other entity. Turning around means that yes it is out of the POV, but you are still capable of seeing the entity by turning back around. The method is only useful for checking if the entity can be seen at any angle. It will return false when the two entities are separated by a wall or something similar.
In order to get a real target you must raycast forward from the player's head and find the closest entity within the ray.
Yes, It happens to all entities, Bukkit 1.8.1-Snapshot
how do I do this?
Moved to Bukkit alternatives
Bukkit never released 1.8 so an alternative.
Try Debugging first, then try seeing if any other entities can use .hasLineOfSign on a other different entity (e.g. a minecart, or a villager, armourstand ect.). Entities such as minecart should always return false.
Why would entities like a minecart always return false?
Did what I say not make sense before? The method returns true no matter what as long as two entities are capable of being seen by each other, or in other words, there is no wall of blocks in between them. It doesn't check which way the camera is facing or anything because that would be incredible impossible server side when you have things like latency and different FOV settings on clients. If you want to find anything within the view of a player's POV then you would have to raycast a line, or several lines if u want the full view, but as I said before there is no way to know a clients FOV and so you'll never have 100% reliable results.
Separate names with a comma.