diff --git a/src/entity/Animal.php b/src/entity/Animal.php index b0a349f0..16c2e311 100644 --- a/src/entity/Animal.php +++ b/src/entity/Animal.php @@ -93,19 +93,11 @@ abstract class Animal extends Creature implements Ageable, Breedable{ --$this->inLove; } } - - public function environmentUpdate(){ - if($this->server->api->getProperty("spawn-animals") !== true){ - $this->close(); - return false; - } - return parent::environmentUpdate(); - } - + public function getDrops(){ if($this->isBaby()){ return []; } return parent::getDrops(); } -} \ No newline at end of file +} diff --git a/src/entity/Creature.php b/src/entity/Creature.php index 44dd2a80..12c2195c 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -9,7 +9,7 @@ abstract class Creature extends Living{ public $inPanic; public function __construct(Level $level, $eid, $class, $type = 0, $data = []){ - $this->inPanic = false; //force for now + $this->inPanic = false; //force for now parent::__construct($level, $eid, $class, $type, $data); $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 1, "generic"); //$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type)); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 2aae4c7b..a8a60919 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -713,14 +713,15 @@ class Entity extends Position if($this->hasGravity && $support === false){ $this->speedY -= ($this->class === ENTITY_FALLING) ? 0.04 : ($this->class === ENTITY_ITEM ? 0.06 : 0.08); // TODO: replace with $gravity $update = true; - } elseif($this->lastX != $this->x && $this->lastZ != $this->z & $this->lastY != $this->z){ + } elseif($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){ // $this->speedX = 0; // $this->speedY = 0; // $this->speedZ = 0; $this->server->api->handle("entity.move", $this); $update = true; - - } + }elseif($this->lastYaw != $this->yaw || $this->lastPitch != $this->pitch){ + $update = true; + } if($update === true){ $hasUpdate = true; diff --git a/src/entity/Monster.php b/src/entity/Monster.php index 67e5bab2..510f2b83 100644 --- a/src/entity/Monster.php +++ b/src/entity/Monster.php @@ -1,12 +1,4 @@ server->api->getProperty("spawn-mobs") !== true){ - $this->close(); - return false; - } - - return $upd; - } -} \ No newline at end of file + +} diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index 5071266b..25b5fb3b 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -54,9 +54,9 @@ class MobController public function lookOn($x, $y = 0, $z = 0, $pitch = true){ if($x instanceof Vector3){ - return $this->lookOn($x->x, $x->y + ($x->getEyeHeight() ?: 0), $x->z); + return $this->lookOn($x->x, $x->y + $x->getEyeHeight(), $x->z, $pitch); } - return $this->lookOffset($x - $this->entity->x, $this->entity->y + $this->entity->height - $y, $z - $this->entity->z, $pitch); + return $this->lookOffset($x - $this->entity->x, ($this->entity->y + $this->entity->height) - $y, $z - $this->entity->z, $pitch); } public function __destruct(){ diff --git a/src/entity/ai/tasks/TaskLookAround.php b/src/entity/ai/tasks/TaskLookAround.php index 395f2ba8..d6ee4f65 100644 --- a/src/entity/ai/tasks/TaskLookAround.php +++ b/src/entity/ai/tasks/TaskLookAround.php @@ -6,7 +6,7 @@ class TaskLookAround extends TaskBase public function onStart(EntityAI $ai) { $this->selfCounter = 1; - $this->rotation = mt_rand(-180,180); + $this->rotation = mt_rand(-90, 90); } public function onEnd(EntityAI $ai) @@ -16,7 +16,7 @@ class TaskLookAround extends TaskBase public function canBeExecuted(EntityAI $ai) { - return !$ai->entity->isMoving() && Utils::randomFloat() < 0.02; + return !$ai->entity->isMoving() && Utils::randomFloat() < 0.04; } public function onUpdate(EntityAI $ai) diff --git a/src/entity/ai/tasks/TaskLookAtPlayer.php b/src/entity/ai/tasks/TaskLookAtPlayer.php index 44f96d45..6e06e3c0 100644 --- a/src/entity/ai/tasks/TaskLookAtPlayer.php +++ b/src/entity/ai/tasks/TaskLookAtPlayer.php @@ -4,10 +4,9 @@ class TaskLookAtPlayer extends TaskBase{ const S_LOOK = 0x1; const S_STOPLOOK = 0x2; public $target = false; - private $nextExecCounter = 0; private $state, $yaw, $pitch; public function canBeExecuted(EntityAI $ai){ - return !$ai->entity->isMoving() && --$this->nextExecCounter <= 0 && !@$ai->getTask("TaskLookAround")->wasExecuted && mt_rand(0,5) === 0 && Utils::randomFloat() >= 0.02; + return !$ai->entity->isMoving() && !@$ai->getTask("TaskLookAround")->isStarted && mt_rand(0, 20) == 0; } protected function findTarget($e, $r){ @@ -23,7 +22,7 @@ class TaskLookAtPlayer extends TaskBase{ } $this->yaw = $ai->entity->yaw; $this->pitch = $ai->entity->pitch; - $this->selfCounter = mt_rand(20, 40); + $this->selfCounter = mt_rand(20, 60); } public function onUpdate(EntityAI $ai){ @@ -41,7 +40,6 @@ class TaskLookAtPlayer extends TaskBase{ public function onEnd(EntityAI $ai){ unset($this->target); - $this->nextExecCounter = mt_rand(100, 200); $ai->entity->pitch = 0; } } diff --git a/src/entity/ai/tasks/TaskRandomWalk.php b/src/entity/ai/tasks/TaskRandomWalk.php index 4c684145..37a0a2b7 100644 --- a/src/entity/ai/tasks/TaskRandomWalk.php +++ b/src/entity/ai/tasks/TaskRandomWalk.php @@ -34,8 +34,8 @@ class TaskRandomWalk extends TaskBase if($ai->entity instanceof Creeper && $ai->entity->isIgnited()) { return false; } - return !@$ai->getTask("TaskLookAround")->isStarted && !@$ai->getTask("TaskLookAtPlayer")->isStarted && mt_rand(0, 120) == 0; + return !@$ai->getTask("TaskLookAround")->isStarted && !@$ai->getTask("TaskLookAtPlayer")->isStarted && mt_rand(0, 40) == 0; } -} \ No newline at end of file +}