mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
32 lines
733 B
PHP
32 lines
733 B
PHP
<?php
|
|
|
|
class TaskLookAround extends TaskBase
|
|
{
|
|
private $rotation;
|
|
public function onStart(EntityAI $ai)
|
|
{
|
|
$this->selfCounter = 1;
|
|
$this->rotation = mt_rand(-120, 120);
|
|
}
|
|
|
|
public function onEnd(EntityAI $ai)
|
|
{
|
|
$ai->entity->idleTime = mt_rand(20, 40);
|
|
}
|
|
|
|
public function canBeExecuted(EntityAI $ai)
|
|
{
|
|
return !$ai->entity->isMoving() && Utils::randomFloat() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
|
}
|
|
|
|
public function onUpdate(EntityAI $ai)
|
|
{
|
|
if($this->rotation === 0){
|
|
$this->selfCounter = 0;
|
|
}
|
|
$v = min(Utils::getSign($this->rotation) * 10, $this->rotation);
|
|
$ai->entity->headYaw += $v;
|
|
$this->rotation -= $v;
|
|
|
|
}
|
|
}
|