Need help with entity targeting

Discussion in 'Plugin Development' started by Anerdson, Aug 19, 2013.

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

    Anerdson

    Hello,

    As the name suggests, i need help with entity targeting.

    More specifically, i need to know how to make an entity follow a player
    What i have pieced together is:
    Code:java
    1. List<Entity> entities = player.getNearbyEntities(x,y,z);
    2.  
    3. for(Entity e : entities){
    4. if(e == EntityType.SHEEP){
    5. Sheep sheep = (Sheep) e;
    6. sheep.setTarget(player);
    7. }
    8. }


    Whats wrong with this?
     
  2. I don't think sheep can follow players, if you would do this with a dog it would probably work. The documentation is kinda shady about it :/
     
  3. Offline

    Lactem

    That looks good, except for one thing: You're checking if the Entity == an EntityType. Try if(e.getType() == EntityType.SHEEP) { }.
     
    blackwolf12333 and Axe2760 like this.
  4. lol, how did I mis that :p
     
  5. Offline

    KingNyuels

    When it stll doesn't work: Try with this (Maybe it works): Mouseklick in here

    KingNyuels
     
Thread Status:
Not open for further replies.

Share This Page