real head yaw fixed

This commit is contained in:
GameHerobrine 2024-01-09 08:51:15 +03:00
parent 9d6322f587
commit 88cec22404
4 changed files with 41 additions and 10 deletions

View file

@ -480,7 +480,7 @@ class PlayerAPI{
} }
$this->server->query("DELETE FROM players WHERE name = '" . $player->username . "';"); $this->server->query("DELETE FROM players WHERE name = '" . $player->username . "';");
$this->server->api->entity->remove($player->eid); $this->server->api->entity->remove($player->eid);
unset($player->level->players[$this->CID]); unset($player->level->players[$player->CID]);
if($player->entity instanceof Entity){ if($player->entity instanceof Entity){
unset($player->entity->player); unset($player->entity->player);
//unset($player->entity); //unset($player->entity);

View file

@ -135,6 +135,8 @@ abstract class Living extends Entity implements Pathfindable{
//Yaw rotation in 1.5 is handled in a bit different place but hopefully this will work too //Yaw rotation in 1.5 is handled in a bit different place but hopefully this will work too
$this->ai->mobController->updateHeadYaw(); $this->ai->mobController->updateHeadYaw();
} }
public function moveEntityWithHeading($strafe, $forward){ public function moveEntityWithHeading($strafe, $forward){
@ -153,15 +155,17 @@ abstract class Living extends Entity implements Pathfindable{
$var8 = 0.16277136 / ($friction*$friction*$friction); $var8 = 0.16277136 / ($friction*$friction*$friction);
if($this->onGround){ if($this->onGround){
//all mobs have ai enabled in nc for now
$var5 = $this->getAIMoveSpeed();
//TODO if AIEnabled //TODO if AIEnabled
{ //{
//TODO $var5 = getAIMoveSpeed //TODO $var5 = getAIMoveSpeed
} //}
//else //else
{ //{
$var5 = $this->landMovementFactor; // $var5 = $this->landMovementFactor;
} //}
$var5 *= $var8; //$var5 *= $var8;
}else{ }else{
$var5 = $this->jumpMovementFactor; $var5 = $this->jumpMovementFactor;
} }

View file

@ -26,6 +26,8 @@ class MobController
public $moveToX, $moveToY, $moveToZ; public $moveToX, $moveToY, $moveToZ;
public $speed; public $speed;
public $updateMove = false; public $updateMove = false;
public $isLooking = false;
public function __construct($e){ public function __construct($e){
$this->entity = $e; $this->entity = $e;
@ -123,12 +125,34 @@ class MobController
} }
$this->entity->renderYawOffset = self::limitAngle2($this->entity->headYaw, $this->entity->renderYawOffset, $v5); $this->entity->renderYawOffset = self::limitAngle2($this->entity->headYaw, $this->entity->renderYawOffset, $v5);
} }
$this->entity->headYaw = $this->entity->renderYawOffset;
} }
public function rotateTick(){ //TODO handle more rotation public function rotateTick(){ //TODO handle more rotation
$this->entity->pitch = 0;
if($this->isLooking){
$this->isLooking = false;
//TODO
}else{
$this->entity->headYaw = self::limitAngle($this->entity->headYaw, $this->entity->renderYawOffset, 10);
}
/* Some stuff for pathfinder - nc doesnt have it now
* float var11 = MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset);
if (!this.entity.getNavigator().noPath())
{
if (var11 < -75.0F)
{
this.entity.rotationYawHead = this.entity.renderYawOffset - 75.0F;
}
if (var11 > 75.0F)
{
this.entity.rotationYawHead = this.entity.renderYawOffset + 75.0F;
}
}
*/
//$this->entity->lastHeadYaw = $this->entity->headYaw; //$this->entity->lastHeadYaw = $this->entity->headYaw;
//$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw); //$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw);

View file

@ -69,8 +69,11 @@ class Utils{
public static function wrapAngleTo180($angle) public static function wrapAngleTo180($angle)
{ {
$angle = fmod($angle+180, 360); $angle = fmod($angle, 360);
return $angle < 0 ? $angle + 360 : $angle - 180;
if($angle >= 180) $angle -= 360;
if($angle < -180) $angle += 360;
return $angle;
} }
public static function getSign($v){ public static function getSign($v){
return $v <=> 0; return $v <=> 0;