1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Entity: How to add task or event to it when created

Discussion in 'Development' started by benda95280, May 14, 2020.

  1. benda95280

    benda95280 Witch

    Messages:
    53
    GitHub:
    benda95280
  2. mlsdmitry0

    mlsdmitry0 Spider

    Messages:
    12
    How about this? Insert this code to BaseEntity in entityBaseTick
    PHP:
    public function entityBaseTick(int $tickDiff 1): bool
    {
       if (
    $this->properties->rotationPerTick !== 0) {
          
    $newYaw = ($this->getYaw() + $this->properties->rotationPerTick) % 360;
          
    $this->setRotation($newYaw0);
       }
       if (!
    is_null($this->getLevel()->getNearestEntity($this->asVector3(), 10Human::class, false))) {
           
    /*
            *
            * add property isUsing default equal false;
            * if isUsing === true -> break
            * set isUsing to true;
            * Run your task;
            * inside task class when it's finished change isUsing to false.
            * To all your stuff inside task.
            */
           
    }

       return 
    parent::entityBaseTick($tickDiff);
    }
     
  3. benda95280

    benda95280 Witch

    Messages:
    53
    GitHub:
    benda95280
    Nice ................... Works well, i've been able to set automatic rotation when player are near :)

    Thanks !
     
  4. mlsdmitry0

    mlsdmitry0 Spider

    Messages:
    12
    Yep, no problem! ;)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.