Solved Stop Entity Movement and Clear Target?

Discussion in 'Plugin Development' started by funkystudios, Dec 24, 2012.

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

    funkystudios

    In a plugin I am developing, I have found out how to move an entity around and set the target of the entity. Using the following code:

    Forces the entity to walk to x, y, z:
    Code:
    EntityCreature ec = getHandle();
    PathEntity pf = ((CraftWorld) ec.getBukkitEntity().getWorld()).getHandle().a(ec, x, y, z, 48F, true, false, false, true);
    ec.getNavigation().a(pf, 0.25F);
    Forces the entity to target the entity, 'target':
    Code:
    EntityCreature ec = getHandle();
    ec.b(((CraftCreature) target).getHandle());
    1.) How would I clear the movement of the entity and stop it in its path.
    2.) How do I clear the entity's target and stop it from attacking.

    As much as I hate it.... bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  2. 1)
    Code:
    entityLiving.getNavigation().g()
    clears the current PathEntity and thus makes the entity stop moving (method name as of 1.4.5, don't think it changed in 1.4.6). Keep in mind that running AI pathfinders may set another PathEntity at any point of time (unless you are working with a "dumb" entity without any natural AI, of course)

    2)
    You could simply set the target to null?
    Code:
    entityLiving.b((EntityLiving) null)
    (mind the cast to EntityLiving, as "b(null)" is ambiguous and could be any method called "b" with only 1 non-primitive argument)
     
  3. Offline

    funkystudios

    Bone008 Thank you very much! Both solutions work great.
     
Thread Status:
Not open for further replies.

Share This Page