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

Move entity

Discussion in 'Development' started by #A6543, Jun 8, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    Hey. I want to boost a pig away like a snowball if a player interacts with the item id 1. I already tried something. But this only teleports the entity to a location and did not work like what I expected.
    PHP:
    public function interact(PlayerInteractEvent $event) {
    if(
    $event->getItem()->getId() == 1) {
    //Don't really know how to create the entity :/
    /*
    Code to create it?!
    */
    $entity->addMovement($x$y$z);
    }
    }
     
  2. #A6543

    #A6543 Zombie

    Messages:
    267
    No idea?
     
  3. Aviv

    Aviv Baby Zombie

    Messages:
    156
    You can try Living::knockBack()
     
  4. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    If you are using addEntityPacket to spawn the entity, you can easily move her using the MoveEntityPacket
     
  5. #A6543

    #A6543 Zombie

    Messages:
    267
    Can u give me an example?
     
  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.