Solved Say Animals where they have to go?

Discussion in 'Plugin Development' started by Eistee², Oct 23, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Eistee²

    Hello ,
    The tittle should say every thing,

    I want to get two animals at the same location but I really don´t know how I can say the Entitys where they have to go can some on help me?
    (no teleport)
     
  2. You can't do it without using the nms classe(s) of the entitie(s), that's a fact.
    Hence, 'm_entity' in the case is the handle of the actual entity (e.g. ((CraftLivingEntity)bukkitEntity).getHandle()).
    Code:
    if(!this.m_entity.getNavigation().a(inLocation.getX(), inLocation.getY(), inLocation.getZ(), this.getSpeed()))
    {
        PathEntity path = this.m_entity.world.a(this.getHandle(), MathHelper.floor(inLocation.getX()), (int) inLocation.getY(), MathHelper.floor(inLocation.getZ()), 20, true, false, false, true);
        if(this.m_entity instanceof EntityCreature)
            ((EntityCreature)this.m_entity).setPathEntity(path);
        this.m_entity.getNavigation().a(path, this.getSpeed());
    }
    I can't, however, explain that much how it works. What I'm actually doing is that I try to let it walk towards the specified location automatically. If that fails, I let the world create a path for me and apply that one to the entity. I don't know why that makes any difference, but it does.

    EDIT: booleans in the a()-method represent the following: 1. is able to pass open wooden doors; 2. is able to pass closed wooden doors; 3. avoids water; 4. can swim
     
    Eistee² likes this.
  3. Offline

    Eistee²


    Thanks I think this will help me :)
     
  4. And keep in mind: Entities have a maximum walking distance of 16 blocks. If the location is too far away, it'll probably result in return false at the first try. You can, if you want to, change the 5th parameter in the world.a()-method to increase the distance.
     
    Eistee² likes this.
Thread Status:
Not open for further replies.

Share This Page