Cancelling a creatures target

Discussion in 'Plugin Development' started by CorrieKay, Mar 29, 2012.

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

    CorrieKay

    Im trying to get a list of nearby mobs and cancelling their targets

    Code:java
    1. List<Entity> nearby = player1.getNearbyEntities(100, 100, 100);
    2. for(Entity entity : nearby){
    3. if(entity instanceof Creature){
    4. Creature creature = (Creature)entity;
    5. creature.setTarget(null);
    6. }
    7. }


    thing is, it just doesnt work :confused: skellies still shoot, and zombies still chase me down.
     
  2. Offline

    dillyg10

    How often are you doing this? It could be a possibility with the new Mob API that the creatures will continuesly target you.
     
  3. Offline

    CorrieKay

    This fires whenever a player utilizes a command that turns them invisible. theres a listener that prevents mobs from targetting invisible players that is working perfectly.

    this should, in theory, only need to work once.
     
  4. Offline

    dillyg10

    Hmm I'm thinkin that Bukkit might not have implemented the new Mob API's quite yet? But I could be wrong.

    I say this becuase zombies f/ex follow you in a path maze, they way they do that is a constant target at you.
     
  5. Offline

    nisovin

    Entities will continuously attempt to acquire a new target if they have none, so setting their targets to null just once isn't going to do much. They'll just retarget.

    Whoops, just read your second post. I'm not sure about this, it really should work.
     
  6. Offline

    CorrieKay

Thread Status:
Not open for further replies.

Share This Page