Let a Entity follow the player

Discussion in 'Plugin Development' started by Typ, Sep 12, 2017.

Thread Status:
Not open for further replies.
  1. Hey,
    how can I create an Entity, for example a chicken, and let it always follow a Player?
    I already tried it with Pathfinder from NMS, but maybe I did somethink wrong, or it doesn't work so...

    yeah, and I use Minecraft 1.12.1, there are almost no tutorials for nms 1.12 :/ Hopefully someone here knows, how I can do this.

    greetings Typ
     
  2. Offline

    travja

    Quick Google search on custom entities yields:

    https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/
    https://hypixel.net/threads/how-to-make-custom-entities-spigot-bukkit-tutorial-1-8-and-up.332442/

    As always, when working with NMS/Reflection, make sure that your field and method names match your server version fields and methods. You can dig a little deeper to check for yourself by decompiling the Spigot jar, but it does take a little bit of knowledge and knowing what to look for where. Good luck!
     
  3. Offline

    Horsey

    A way to make your plugin version independent would be to remove the entity's AI, and apply a vector to have it move towards the Player. so the code to get the vector would be: PlayerLoc#toVector().subtract(EntityLoc#toVector())

    Another advantage is that the entity will continue to follow the player even if it is more than 16 (I think that's the limit) blocks away.

    However, the entity wouldn't be able to path-find around obstacles, and it would try to 'fly' directly at the player (unless you code that, probably a bit hard).
     
Thread Status:
Not open for further replies.

Share This Page