Hi specialists, I'm looking for a better way to find out at which entity the player is looking currently. At the moment I'm using the following code by using the BlockIterator: PHP: public static function getEntityPlayerLookingAt(Player $player, int $maxDistance, bool $useCorrection = false) { /** * @var Entity */ $entity = null; $nearbyEntities = $player->getLevel()->getNearbyEntities($player->boundingBox->grow($maxDistance, $maxDistance, $maxDistance), $player); // get all blocks in looking direction until the max interact distance is reached (it's possible that startblock isn't found!) try { $itr = new BlockIterator($player->level, $player->getPosition(), $player->getDirectionVector(), $player->getEyeHeight(), $maxDistance); } catch (InvalidStateException $e) { // nothing to log here! } if ($itr !== null) { $block = null; $entity = null; while ($itr->valid()) { $itr->next(); $block = $itr->current(); $entity = self::getEntityAtPosition($nearbyEntities, $block->x, $block->y, $block->z, $useCorrection); if ($entity !== null) { break; } } } return $entity; } I've a simple question, as it's of course a performance issue doing this all the time using getNearbyEntities and the BlockIterator. Especially when i want to know if a player is looking at an enderman e.g. So just a simple question: is there a better, more performant way to do this?