Entity Navigation

Discussion in 'Plugin Development' started by CaptainUniverse, Oct 18, 2014.

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

    CaptainUniverse

    Hey guys I hear you can make any entity follow a player using navigation but first how do I get it, and second how do I set it to a certain location?
     
  2. Offline

    xTrollxDudex

    Cast the entity to EntityInsentient and use .getNavigation()

    Then, you can use a(int, int, int) to move the entity to the coordinates, xyz format. Make sure to cancel targeting events, or the entity can get distracted.

    You can check out http://forums.bukkit.org/threads/tut-making-a-livingentity-walk-to-a-specific-tile.139086/
     
    Funergy and rbrick like this.
  3. Offline

    97WaterPolo

    xTrollxDudex
    I solved my problem earlier by casting my Bukkit Pig entity to a "CraftPig", but whenever I tried to cast the pig to EntityInsentient, I kept getting ClassCastException, can't cast from CraftPig to EntityInsentient. Many people on the thread suggested I do that, but for some reason it didn't work, any idea why?
     
  4. Offline

    xTrollxDudex

    I'll have to check my sources but I'm pretty sure you cast EntityLiving to it?
     
  5. Offline

    97WaterPolo

    xTrollxDudex
    I was able to cast living entity, but it didn't have a .getNavigation() method for it.
     
  6. Offline

    xTrollxDudex

    Did you cast EntityLiving to EntityInsentient?
     
  7. Offline

    97WaterPolo

    xTrollxDudex
    Yep, tried the multi cast, in the end it still didn't work, I THInk the error was still cannot cast CraftPig to EntityInsentient. If you'd like I can get some errors and example code if needed as I am dumbfounded.
     
  8. Offline

    TheCodingCat

  9. Offline

    CaptainUniverse

    Hey guys xTrollxDudex I'm casting a sheep to entityinsetient and I got an error saying I can not cast CraftSheep to EntityInsetient Do I need to get handle or something?

    Ok I also tried
    ((EntityInsentient)(((CraftEntity)sheep)).getHandle()).getNavigation().a(loc.getX(), loc.getY(), loc.getZ());
    but now It wont follow me. I even cancelled the EntityTargetEvent What do I do?

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

    xTrollxDudex

    Are you sure it runs? You may need to resort to pathfinders if you continue to run into this problem.
     
  11. Offline

    CaptainUniverse

    Yes it does run. But I don't want to extend EntityPathFinders
    xTrollxDudex how would you do this can I have some code please for maybe spawning a sheep then making it run to the sender? thanks
     
  12. Offline

    97WaterPolo

    CaptainUniverse
    I had the exact same issue, I ended up using

    Code:java
    1. return ((CraftPig)p).getHandle().getNavigation().a(l.getX(), l.getY(), l.getZ(), .25);


    Try using CraftSheep if that is a valid class.
     
Thread Status:
Not open for further replies.

Share This Page