Trouble with moving LivingEntities

Discussion in 'Plugin Development' started by Jobi, Mar 9, 2013.

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

    Jobi

    In one of my plugins I have to tell a Zombie to which point it has to go. The problem is, that the code is just not working and i have no idea why. No errors, nothing.

    Code:
    Monster monster = Bukkit.getWorld("world").spawn(new Location(Bukkit.getWorld("world"),200, 12, -180), Zombie.class);
    Location l = (new Location(Bukkit.getWorld("world"),200, 12, -170));
    Block location = l.getBlock();
    EntityCreature ec = ((CraftCreature)monster).getHandle();
    PathEntity pf = ((CraftWorld)location.getWorld()).getHandle().a(ec, location.getX(), location.getY(), location.getZ(), 16.0f, true, false, false, true);
    ec.setPathEntity(pf);
    
    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  2. Offline

    Gravity

    Moved to the appropriate section
     
  3. Offline

    Cybermaxke

    Maybe you can take a look at my navigator class. ;)
    Link: here
     
  4. Offline

    Jobi

    Ok, the mob movement is now working!
    Code:
    EntityCreature ec = ((CraftCreature) monster).getHandle();
    Block to = lv.getLocation().getBlock(); //lv is a LivingEntity and the place where the mob has to go to
    PathEntity pf = ((CraftWorld) to.getWorld()).getHandle().a(ec, to.getX(), to.getY(), to.getZ(), 16.0f, true, false, false, true);
    if(creep.getMonster() instanceof PigZombie || creep.getMonster() instanceof CaveSpider || creep.getMonster() instanceof Blaze || creep.getMonster() instanceof Enderman) {
            ec.setPathEntity(pf);
    }
    else {
            Navigation nav = ec.getNavigation();
            nav.a(pf, 0.15f); //The float is the speed of the mob, i dont know the default speed
    }
    But I got a different problem. s.setTarget() is only working for the mobs in the "if" part. the mobs in the "else" wont attack any LivingEntities
     
Thread Status:
Not open for further replies.

Share This Page