-1 / 0 = -INFINITY

This commit is contained in:
GameHerobrine 2022-12-26 07:46:41 +03:00
parent 62571f26cd
commit 11b1a09599

View file

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