.setTarget does not work

Discussion in 'Plugin Development' started by fokolo, Sep 23, 2013.

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

    fokolo

    as i see it setTarget does not work because of new pathfinder but it is not implemented to the zombie pigman and some?

    but is there a way i could setTargets?

    i think there is and i figured out this two ways:
    1. navigation - i have no idea how to use but if you say its good i will learn
    2. mob riding invisible zombie pigman (but it will be akward a bit unless you could make the mob look like he is walking on the floor) this will be achieved with NBTedit i thought about powerNBT lib

    anyway what is your thought about my options do you have other ways?
    can you help me figure out my ways?

    thanks a lot

    bump

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

    MCCoding

    fokolo
    Here is how you make a Zombie pigman man follow you with nav make sure you put it in your onEnable or it won't work.

    Code:java
    1. Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
    2. public void run() {
    3. for (Player player : Bukkit.getServer().getOnlinePlayers()) {
    4.  
    5. List<Entity> entities = player.getNearbyEntities(25.0D, 25.0D, 25.0D);
    6. for(Entity e : entities){
    7. if (e instanceof PigZombie) {
    8. PigZombie pigzomb = (PigZombie) e;
    9. Location l = player.getLocation();
    10. Navigation nav = ((EntityInsentient)((CraftEntity) golem).getHandle()).getNavigation();
    11. nav.a(l.getX(), l.getY(), l.getZ(), 1.5f //speed);
    12. }
    13. }
    14. }
    15. }
    16. }, 0, 10L);
     
  3. fokolo
    setTarget() doesn't work? Make sure to setAngry(true) first.

    For navigation, use
    Code:java
    1. LivingEntity le = someLivingEntity;
    2. Location l = someLocation;
    3. float speed = 1.75f; // someSpeed
    4. ((EntityInsentient) ((CraftLivingEntity) le).getHandle()).getNavigation().a(l.getX(), l.getY(), l.getZ(), speed);
     
  4. Offline

    fokolo

    MCCoding Assist
    setTarget work for zombie pigman

    what i need is it to work for a animal(a sheep for example) and that does not work
     
  5. Offline

    MCCoding

    fokolo
    well in the code i gave you change PigZombie to Sheep, also i found an error in my pasting change the golem to pigzombie
     
  6. Offline

    fokolo

    MCCoding
    i have a problem probably dumb one
    Navigation, EntityInsentient and CraftLivingEntity
    cannot be resolved to a type

    what are the imports i need to use?
     
  7. Offline

    MCCoding

    fokolo
    Here are the imports

    Code:java
    1. import net.minecraft.server.v1_6_R2.EntityInsentient;
    2. import net.minecraft.server.v1_6_R2.Navigation;
     
  8. Offline

    fokolo

    MCCoding
    this means im gonna need to add craftbukkit.jar?
     
  9. Offline

    MCCoding

    fokolo
    Not to sure but those are the imports i use not sure of the ones for the other jars.
     
  10. Offline

    Garris0n

    Yes.
     
  11. Offline

    jeremytrains

    fokolo MCCoding Garris0n
    Does navigation work on 1.7? I cant get navigation (any navigation method) to work on Horses in 1.7
     
  12. Offline

    MCCoding

    jeremytrains
    Well the code i posted above works, it's still working for me. Make sure you have the correct imports and are using craftbukkit.
     
  13. Offline

    jeremytrains

    MCCoding
    Have you ever tried to do this for a mounted mob? It seems it works for horses, but it only works for horses when there is no passenger
     
Thread Status:
Not open for further replies.

Share This Page