more entity metadata

This commit is contained in:
GameHerobrine 2023-02-24 19:39:38 +03:00
parent 447638816e
commit 93765e8cc7
6 changed files with 67 additions and 7 deletions

View file

@ -13,6 +13,9 @@ class TaskAttackPlayer extends TaskTempt
{
if(!($this->target instanceof Entity) || ($ai->entity instanceof Spider && $ai->entity->level->isDay()) || ($this->target instanceof Entity && !$this->target->isPlayer()) || (Utils::distance_noroot($this->target, $ai->entity) > 256) || $this->target->level->getName() != $ai->entity->level->getName()){
$this->reset();
if($ai->entity instanceof Enderman){
$ai->entity->setAngry(false);
}
return;
}
@ -27,12 +30,21 @@ class TaskAttackPlayer extends TaskTempt
--$this->attackTime;
}
public function onEnd(EntityAI $ai){
parent::onEnd($ai);
if($ai->entity instanceof Enderman){
$ai->entity->setAngry(false);
}
}
public function canBeExecuted(EntityAI $ai)
{
$target = $this->findTarget($ai->entity, 16);
if(($ai->entity instanceof Spider && !$ai->entity->level->isDay()) || $target instanceof Entity && $target->class === ENTITY_PLAYER && $target->isPlayer()){
$this->target = $target; //TODO get rid of it
$ai->entity->target = $target;
if($ai->entity instanceof Enderman){ //TODO find a better way
$ai->entity->setAngry(true);
}
return true;
}