From 11b1a095997f4b0985744450effbb6aafba1cea6 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 26 Dec 2022 07:46:41 +0300 Subject: [PATCH] -1 / 0 = -INFINITY --- src/entity/ai/MobController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index ada3fa2b..cca01559 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -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){