diff --git a/src/entity/ai/tasks/TaskAttackPlayer.php b/src/entity/ai/tasks/TaskAttackPlayer.php index deb9d66b..7f1a0227 100644 --- a/src/entity/ai/tasks/TaskAttackPlayer.php +++ b/src/entity/ai/tasks/TaskAttackPlayer.php @@ -29,7 +29,8 @@ class TaskAttackPlayer extends TaskTempt { $target = $this->findTarget($ai->entity, 10); if($target instanceof Entity && $target->class === ENTITY_PLAYER && $target->isPlayer()){ - $this->target = $target; + $this->target = $target; //TODO get rid of it + $ai->entity->target = $target; return true; } diff --git a/src/entity/ai/tasks/TaskTempt.php b/src/entity/ai/tasks/TaskTempt.php index 3d766ccb..e2589436 100644 --- a/src/entity/ai/tasks/TaskTempt.php +++ b/src/entity/ai/tasks/TaskTempt.php @@ -12,6 +12,7 @@ class TaskTempt extends TaskBase public function onEnd(EntityAI $ai) { unset($this->target); + unset($ai->entity->target); $ai->entity->pitch = 0; } @@ -34,6 +35,7 @@ class TaskTempt extends TaskBase $target = $this->findTarget($ai->entity, 10); if($target instanceof Entity && $target->class === ENTITY_PLAYER && $target->isPlayer() && $ai->entity->isFood($target->player->getHeldItem()->getID())){ $this->target = $target; + $ai->entity->target = $target; return true; } diff --git a/src/entity/monster/Creeper.php b/src/entity/monster/Creeper.php index 8ec5c501..2486d1a4 100644 --- a/src/entity/monster/Creeper.php +++ b/src/entity/monster/Creeper.php @@ -28,7 +28,7 @@ class Creeper extends Monster{ * @return boolean */ public function isIgnited(){ - return (boolean)$this->getState(); + return $this->getState() > 0; } public function interactWith(Entity $e, $action){ @@ -50,7 +50,17 @@ class Creeper extends Monster{ $this->timeUntilExplode = self::EXPL_TIME; } + public function attackEntity($entity){ + if(Utils::distance_noroot($entity, $this) <= 49 && !$this->isIgnited()){ + $this->ignite(); + } + + } public function update(){ + if($this->isIgnited() && $this->target instanceof Entity && Utils::distance_noroot($this->target, $this) > 49){ + $this->setIgnited(-1); //broken in vanilla too + $this->timeUntilExplode = 0; + } if($this->timeUntilExplode === 1){ $this->explode(); }