mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
-1 / 0 = -INFINITY
This commit is contained in:
parent
62571f26cd
commit
11b1a09599
1 changed files with 3 additions and 3 deletions
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue