LookDetection 5.46.0
Whether a living entity (usually a player) is looking at a point or an entity, from its view direction (vanilla minecraft:looked_at, Java EnderMan::isLookingAtMe).
Methods
isInFieldOfView()
php
public static function isInFieldOfView(\pocketmine\entity\Living $viewer, \pocketmine\entity\Entity $entity, float $fieldOfViewDegrees) : boolReturns whether the viewer sees the entity within a field of view (degrees), checking its head, body and feet (vanilla looked_at with look_at_locations head, body, feet + 0.5).
isStaringAt()
php
public static function isStaringAt(\pocketmine\entity\Living $viewer, \pocketmine\entity\Entity $entity) : boolEnderman stare check (Java): the viewer looks at the entity's eyes within a cone narrowing with distance (cosine > 1 - 0.025 / distance) and nothing blocks the view. Wearing a carved pumpkin hides the stare.
lookCosine()
php
public static function lookCosine(\pocketmine\entity\Living $viewer, \pocketmine\math\Vector3 $point) : arrayReturns the cosine of the angle between the viewer's look direction and the direction to the point (1: dead centre), and the distance to it.
wearsCarvedPumpkin()
php
public static function wearsCarvedPumpkin(\pocketmine\entity\Living $viewer) : bool