mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
uwu
This commit is contained in:
parent
60c8603c8b
commit
d0ec32dc02
5 changed files with 22 additions and 16 deletions
|
|
@ -18,8 +18,6 @@ class EntityAI
|
|||
|
||||
public $lastTask;
|
||||
|
||||
public $counter = 0;
|
||||
|
||||
public function __construct($entity){
|
||||
$this->entity = $entity;
|
||||
$this->tasks = [];
|
||||
|
|
@ -49,9 +47,6 @@ class EntityAI
|
|||
}
|
||||
|
||||
public function updateTasks(){
|
||||
if($this->counter % 3 != 0){
|
||||
return;
|
||||
}
|
||||
foreach($this->tasks as $t){
|
||||
if(!$t->isStarted && $t->canBeExecuted($this)){
|
||||
$t->isStarted = true;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class MobController
|
|||
$dz = $d->z;
|
||||
|
||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg($dx / $dz));
|
||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||
$thetaOffset = $dz <= 0 ? 90 : 270;
|
||||
$this->entity->yaw = $this->entity->headYaw = ($thetaOffset + $tan);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
$this->target = $this->findTarget($ai->entity, 6); //TODO max distance for different mobs
|
||||
if(!($this->target instanceof Entity) || !$this->target->isPlayer()){
|
||||
$this->reset();
|
||||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
$this->yaw = $ai->entity->yaw;
|
||||
|
|
@ -44,12 +45,13 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
public function onUpdate(EntityAI $ai){
|
||||
if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6 || $this->target->level->getName() != $ai->entity->level->getName()){ //TODO max distance for different mobs
|
||||
$this->reset();
|
||||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
$ai->mobController->lookOn($this->target);
|
||||
$this->selfCounter--;
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(EntityAI $ai){
|
||||
unset($this->target);
|
||||
$ai->entity->pitch = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue