Entity Walk To Location

Discussion in 'Plugin Development' started by Elimnator, Aug 4, 2014.

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

    Elimnator

    I am trying to make an entity walk to a location with this code:
    Code:
        public void moveTo(LivingEntity e, Location moveTo, float speed)
        {
            // Create a path to the location
            PathEntity path = ((EntityInsentient)((CraftLivingEntity) e).getHandle()).getNavigation().a(moveTo.getX(), moveTo.getY(), moveTo.getZ());
            // Move to that path at 'speed' speed.
            ((EntityInsentient)((CraftLivingEntity) e).getHandle()).getNavigation().a(path, speed);
        }
    But it isn't working, can anyone help?

    Anyone?

    Bump

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

    qlimax5000

    You'd need either a timed teleporter with alot of math or NMS
    Look here for a tutorial.
     
  3. Offline

    AdamQpzm

    Elimnator If the above tutorial does not help, trying explaining what exactly "doesn't work". :)
     
  4. Offline

    GreySwordz

    @ElimnatorYou could also spawn an invisible entity at that location and make that the target of the mob. Once they get there, just remove the entity.
     
    xYourFreindx likes this.
  5. Offline

    Elimnator

    AdamQpzm
    When the code runs, nothing happens.

    GreySwordz
    They won't go after the mob unless its within 16 blocks.

    qlimax5000
    That tutorial has nothing to do with making an entity walk to a location.

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

    Elimnator

  7. Offline

    fireblast709

    So it does something after all ;). Try changing GenericAttributes.b, the follow distance
     
  8. Offline

    Zacky1


    Then what you can do is set a path of mobs until that last entity is set. A bit like connect the dots.. But I do understand what you're saying. Bukkit needs the mob API asap.
     
  9. Offline

    Elimnator

    fireblast709
    How do I do that? I haven't done much in NMS.
     
  10. Offline

    Zacky1



    That'll help, but it's pretty obfuscated so you need to know what you're doing..
     
  11. Offline

    Elimnator

    Which I don't.
    So I have to override a method and somehow change the follow distance in it?
     
  12. Offline

    Zacky1

    You could do that or just modify the pathfinding goal of the entity. (Kill two birds with one stone)

    Or you could do what I said earlier that is create a path of invisible mobs a bit like connect the dots.
    That way you dont access NMS classes, the obfuscation, the headaches and a few other things :)
     
  13. Offline

    Elimnator

    Zacky1
    If I did that, how would I calculate the locations of the "dots" I would need to get all the blocks in between the two locations and somehow count every 16?
     
  14. Offline

    nuclearmissile

    Well, more or less! :D If you're familiar with the concept of a breadth-first search you might be able to write your own in order to establish pathfinding, but that's probably one of the most complex options at this point.
     
  15. Offline

    Elimnator

    Whats the most simple option? :p
     
  16. Offline

    Zacky1


    Im sure you can figure it out :)

    Yeah and since he's not advanced in Java lets stay at the easy options :p
     
  17. Offline

    nuclearmissile

    The simplest option would be to use a timer to set the living entity's velocity toward the location you want them to go, and also set their facing direction toward it, then cancel the timer once the entity gets to the end.
     
  18. Offline

    xYourFreindx


    Would that look natural? What if it runs into a wall? It would have to only be facing the goal point and since it can only move forward, it would be stuck walking into that wall forever, if I'm not mistaken.
     
  19. Offline

    nuclearmissile

    He didn't ask for natural, he asked for simple. :D And for all I know, maybe he doesn't need them to navigate complex obstacles or jump over anything ever. :p
     
  20. Offline

    xYourFreindx

    nuclearmissile Welp, let's ask the OP.

    Elimnator , would you like the mobs to be able to do ^what that guy just said? :p
     
  21. Offline

    Elimnator

    xYourFreindx
    I tried that already, didn't work. I think the best option is just to create a custom entity and override the min 16 blocks distance. That is possible right?
     
  22. Offline

    xYourFreindx

    Elimnator
    I don't know. I've never dealt with mob pathfinding. I'm just here for an extra hand in good old common sense.

    I'd sugest decompiling one of the many plugins on dev.bukkit with moving entities.
    Take the one "guards" thing for example.
    Take a look at what other people have done and decide for yourself what strategy works best for you.
    Sorry I couldn't be more help.
    Good luck!
     
  23. Offline

    Garris0n

    I'd assume the entity's pathfinders are overriding what you say. Override their pathfinders with your own that does that. Also, so you know, there's a method here that does that in one line.
     
  24. Offline

    Elimnator

    xYourFreindx
    Can you link a plugin that does that? IDK of one.
     
  25. Offline

    DevilMental

    Elimnator Look at the ressource available on the forum called PetMaker and you might find your happiness (is that even a correct sentence to say ??). If you cannot handle it, I can spoonfeed you code as long as you get to understand the code.
     
  26. Offline

    Elimnator

  27. Offline

    Gamesareme

  28. Offline

    Elimnator

    Ok, I thought it was a plugin.
     
  29. Offline

    TeeePeee

    Elimnator
    I don't know if you're still looking for a solution but I accomplished this (albeit rather sloppily) via. adding a custom pathfinder to a custom mob. I wasn't sure if it was going to work or not at first so it's still pretty gross looking and could use some optimization, but here it is anyways.

    Pathfinder: https://github.com/JordanSicherman/...v1_7_R3/pathfinders/PathfinderGoalWalkTo.java
    Entity using Pathfinder: https://github.com/JordanSicherman/.../nmscode/v1_7_R3/mobs/CustomEntityZombie.java

    This way, you can get an instance of the mob you want to walk to a location and call addPather(location, speed). You can see this in use in the CustomEntityZombie#see(...) method. It will automatically have the pathfinder removed once it reaches its location. Simply change the contents of CustomEntityZombie#populateGoals() to contain the default pathfinder set of the mob type you want.
     
  30. Offline

    Elimnator

    DevilMental
    I tried using the my pet code, but it only works for creeper, not pig zombies.

    Do I have to over right a different method for them?
     
Thread Status:
Not open for further replies.

Share This Page