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

How to add movement to an Entity?

Comments in 'Plugin Development' started by Hotshot_9930, Nov 11, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I have already created the entity:
    PHP:
    public function spawnBot($x$y$z$world$nametag) {
            
    $chunk $world->getChunk($x>>4$z>>4);
            
    $nbt $this->getNBT($x$y$z00);
            
    $bot Entity::createEntity("Zombie"$chunk$nbt);
            
    $bot->setNameTag($nametag);
            
    $bot->spawnToAll();
            
    $this->getLogger()->critical("PocketBot has been spawned");
        }
     
    But I have no idea how to add movement to it.

    Also, how do I get a specific entity in a world? My current code:
    PHP:
        public function getBot() {
            
    $level $this->getBotLevel();
            foreach(
    $level->getEntities() as $entity) {
                if(
    $entity->getX() == $this->getBotX() && $entity->getY() == $this->getBotY() && $entity->getZ() == $this->getBotZ()) {
                    return 
    $entity;
                    }
            }
        }
    But it doesn't work.
    Muqsit likes this.
  2. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    Try, teleporting it back and then again and again. Or you can create a movement pattern and create a task that's teleport the Zombie to the pattern for teleport use $bot->teleport // ;) I'm trying the same thing. I;ll post an update when i figue it out.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Teleporting is one of the worst ways to make a mob walk/move. It looks glitchy.
    There is a way to make the mob walk, but I'm not entirely sure how to do i t.
    thebigsmileXD likes this.
  4. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    How about this??? https://github.com/milk0417/EntityManager , It has an API idk.. Anyway take a look at it alright.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    SetEntityMotionPacket
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
  7. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    PHP:
    $bot->getId()
    returns its entity ID.
    When you have its ID (look above), you can use $level->getEntity($id);
    Muqsit likes this.
  8. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Thanks :D I'll test this later when I can.

Share This Page

Advertisement