diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index d8797ea5..661c7708 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -480,7 +480,7 @@ class PlayerAPI{ } $this->server->query("DELETE FROM players WHERE name = '" . $player->username . "';"); $this->server->api->entity->remove($player->eid); - unset($player->level->players[$this->CID]); + unset($player->level->players[$player->CID]); if($player->entity instanceof Entity){ unset($player->entity->player); //unset($player->entity); diff --git a/src/entity/Living.php b/src/entity/Living.php index 67b864b8..0f7011cd 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -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 $this->ai->mobController->updateHeadYaw(); + + } public function moveEntityWithHeading($strafe, $forward){ @@ -153,15 +155,17 @@ abstract class Living extends Entity implements Pathfindable{ $var8 = 0.16277136 / ($friction*$friction*$friction); if($this->onGround){ + //all mobs have ai enabled in nc for now + $var5 = $this->getAIMoveSpeed(); //TODO if AIEnabled - { + //{ //TODO $var5 = getAIMoveSpeed - } + //} //else - { - $var5 = $this->landMovementFactor; - } - $var5 *= $var8; + //{ + // $var5 = $this->landMovementFactor; + //} + //$var5 *= $var8; }else{ $var5 = $this->jumpMovementFactor; } diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index 58aceb51..86725b9a 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -26,6 +26,8 @@ class MobController public $moveToX, $moveToY, $moveToZ; public $speed; public $updateMove = false; + public $isLooking = false; + public function __construct($e){ $this->entity = $e; @@ -123,12 +125,34 @@ class MobController } $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 + $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; //$w180 = Utils::wrapAngleTo180($this->finalHeadYaw - $this->entity->headYaw); diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 7c7247ff..5c8983ec 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -69,8 +69,11 @@ class Utils{ public static function wrapAngleTo180($angle) { - $angle = fmod($angle+180, 360); - return $angle < 0 ? $angle + 360 : $angle - 180; + $angle = fmod($angle, 360); + + if($angle >= 180) $angle -= 360; + if($angle < -180) $angle += 360; + return $angle; } public static function getSign($v){ return $v <=> 0;