mob fixes related to time and headYaw

This commit is contained in:
GameHerobrine 2023-01-11 11:53:04 +03:00
parent 0a36a67f78
commit 21d0530d39
9 changed files with 35 additions and 27 deletions

View file

@ -35,14 +35,17 @@ class MobController
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
$thetaOffset = $dz < 0 ? 90 : 270;
$this->entity->yaw = $this->entity->headYaw = ($thetaOffset + $tan);
$calcYaw = ($thetaOffset + $tan);
$this->entity->yaw = $this->entity->headYaw = $calcYaw;
}
public function lookOffset($x, $y, $z, $pitch = true){
$tan = $z == 0 ? ($x < 0 ? 180 : 0) : (90 - rad2deg(atan($x / $z))); /*arctan(infinity) = pi/2 = (90deg) - 90 = 0*/
$thetaOffset = $z < 0 ? 90 : 270;
$calcYaw = $tan + $thetaOffset;
$this->entity->headYaw = $calcYaw;
$this->entity->yaw = $this->entity->headYaw = $calcYaw;
if($pitch){
$diff = sqrt($x * $x + $z * $z);
$calcPitch = rad2deg(atan($y / $diff));