Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Make entity move to a specific position (Vector)

Comments in 'Plugin Development' started by Legoboy0215, May 11, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    IDK if it is possible. If yes, how would I do it?
  2. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    I don't know, would the move() method work?
    PHP:
    $entity->move($vector->getX(), $vector->getY(), $vector->getZ());
    applqpak and Primus like this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    And you also must update entity movement, you can see how @aliuly does it here
    Last edited: May 11, 2016
    applqpak and HotFireyDeath like this.
  4. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Here:

    PHP:
    // + 6.5235748291016 x
    $wishX 87;
    $wishZ 49;
    $x = ($wishX $pl->x) / 6.5235748291016;
    $z = ($wishZ $pl->z) / 6.5235748291016;
    $pl->setMotion(new Vector3($x1$z));
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How? Is it the zupdateMovement function? What exactly does it do?
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    To clarify, I simply just want an entity (custom one) to walk towards a specific vector. Also, what would I need in a class that extends Entity?

    So far, I've found 3 functions: Level::addEntityMovement, Level::addEntityMotion and Entity::move.

    I don't understand what is the difference between movement and motion though.
    Last edited: May 12, 2016
    applqpak likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz

    That should work

    PHP:

    $X 
    128;
    $Z 128;

    $entity->setRotation(rad2deg(atan2($Z $player->z$X $player->x)) - 900);

    $yaw = ($entity->yaw 90) * M_PI 180;
    $pitch $entity->pitch M_PI 180 * -1;


    $x cos($yaw) * cos($pitch);
    $z sin($yaw) * cos($pitch);

    $mot = new Vector3($x 20$z 2);

    $entity->setMotion($mot);

  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    So $x and $z is the target coordinates, right? Do I just put it where I want it to move or do I have to put it in the Entity class of mine?
  9. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Yeah $X and $Z are the target positions and you can put it where ever you want to
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Nope, does not work. Currently debugging :)
  11. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Remember to send Position Update Packets to client ;)
    Muqsit and Legoboy0215 like this.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  13. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    So... What exactly are the entries? Also, I though it does it in doTick in Level.php?
  15. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Can someone set an example of where I would put that? I am not too sure and don't have enough time to test :( Sorry

Share This Page

Advertisement