Skip to content

Aim 5.46.0 ​

final class · pocketmine\entity\ai\hostile\Aim · source

Aiming helpers for mobs shooting projectiles (arrows, tridents, potions, fireballs, wind charges).

Methods ​

facing() ​

php
public static function facing(\pocketmine\math\Vector3 $pos, \pocketmine\world\World $world, \pocketmine\math\Vector3 $motion) : \pocketmine\entity\Location

Returns a location at $pos facing along $motion (projectile yaw/pitch conventions).

gaussian() ​

php
public static function gaussian() : float

Approximately normally distributed random number (mean 0, deviation 1).

mobInaccuracy() ​

php
public static function mobInaccuracy(\pocketmine\world\World $world) : float

Vanilla inaccuracy of mob projectiles: (14 - difficulty * 4) * 0.0075 per axis.

motionTowards() ​

php
public static function motionTowards(\pocketmine\math\Vector3 $from, \pocketmine\math\Vector3 $to, float $speed, float $inaccuracy = 0.0, float $lift = 0.0) : ?\pocketmine\math\Vector3

Returns the motion of a projectile shot from $from at $speed blocks per tick towards $to, randomly deviated by $inaccuracy. $lift raises the aim by that fraction of the horizontal distance to make up for gravity (arrows: 0.2).

shootArrow() ​

php
public static function shootArrow(\pocketmine\entity\Living $shooter, \pocketmine\entity\Living $target, ?\pocketmine\item\PotionType $potion = null, float $speed = 1.6) : ?\pocketmine\entity\projectile\Arrow

Shoots an arrow from the shooter's eyes at the target like a skeleton (speed 1.6, aimed above the target for gravity), optionally tipped with a potion. Returns the arrow (already spawned), or null if the target is at the shooter's eyes.

targetPoint() ​

php
public static function targetPoint(\pocketmine\entity\Entity $target, float $heightFraction = 1 / 3) : \pocketmine\math\Vector3

Returns the point a projectile should be aimed at on the target: a third of its height (vanilla), or its eyes.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.