mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
tweaks to headYaw rotation, so it should be nearly perfect now
This commit is contained in:
parent
a5a0c0e000
commit
e4d1898613
5 changed files with 26 additions and 16 deletions
|
|
@ -6,6 +6,10 @@ class MobController
|
|||
* @var Entity
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
public $finalYaw, $finalPitch, $finalHeadYaw;
|
||||
|
||||
|
||||
public function __construct($e){
|
||||
$this->entity = $e;
|
||||
}
|
||||
|
|
@ -36,16 +40,19 @@ class MobController
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->faceEntity($this->entity->add($ox, $oy, $oz));
|
||||
if($this->entity->knockbackTime <= 0){
|
||||
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
||||
}
|
||||
|
||||
|
||||
$this->faceEntity($this->entity->add($ox, $oy, $oz));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rotateTick(){ //TODO handle more rotation
|
||||
$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);
|
||||
$w180min = min(abs($w180), 20)*Utils::getSign($w180);
|
||||
$this->entity->headYaw = Utils::wrapAngleTo360($this->entity->headYaw + $w180min);
|
||||
}
|
||||
|
||||
public function moveTo($x, $y, $z){
|
||||
return $this->moveNonInstant($x - floor($this->entity->x), $y - floor($this->entity->y), $z - floor($this->entity->z));
|
||||
}
|
||||
|
|
@ -58,7 +65,7 @@ class MobController
|
|||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||
$calcYaw = ($thetaOffset + $tan);
|
||||
$this->entity->headYaw = $this->entity->yaw = $calcYaw;
|
||||
$this->finalHeadYaw = $this->entity->yaw = $calcYaw;
|
||||
}
|
||||
|
||||
public function lookOffset($x, $y, $z, $pitch = true){
|
||||
|
|
@ -66,7 +73,7 @@ class MobController
|
|||
$thetaOffset = $z < 0 ? 90 : 270;
|
||||
$calcYaw = $tan + $thetaOffset;
|
||||
|
||||
$this->entity->yaw = $this->entity->headYaw = $calcYaw;
|
||||
$this->entity->yaw = $this->finalHeadYaw = $calcYaw;
|
||||
|
||||
if($pitch){
|
||||
$diff = sqrt($x * $x + $z * $z);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue