PathFinderAPI 1.162.0

An API to add custom Pathfinder to an Entity (can be seen as an future BukkitAPI proposal)

  1. ysl3000
    Native Minecraft Version:
    1.13
    Tested Minecraft Versions:
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    Source Code:
    https://github.com/ysl3000/PathfindergoalAPI
    Contributors:
    https://github.com/yannicklamprecht/PathfindergoalAPI/graphs/contributors
    In the last time I saw that many users had problems with using own Pathfindergoals. I decided to publish this resource to allow an easier handling with it. It can be seen as an future API-proposal. It only allows the developer to add own custom Pathfindergoals. NMS Pathfindergoals aren't handled by this API.

    I will probably do not update this plugin to 1.17.
    Recommend a server fork I shall not name that has a better API built in.
    Update to 1.16.3 is not planned. If it works have fun, If not fix it yourself.


    JavaDoc Github-Page: https://yannicklamprecht.github.io/PathfindergoalAPI/

    Example how to use it:
    Code (Text):
       Player player = p /**/;
            Zombie zombie = player.getWorld().spawn(player.getLocation(), Zombie.class);
            Insentient insentient = PathfinderGoalAPI.getAPI().getPathfindeGoalEntity(zombie);

            insentient.getGoalSelector().clearGoals();
            insentient.getGoalSelector().addPathfinderGoal(0,
                    new PathfinderGoalFollowEntity(insentient, player, 10, 1));

    Example how to write your own Pathfindergoals (you need them to use it):

    Code (Text):

    public class PathfinderGoalFollowEntity implements PathfinderGoal {


      private final LivingEntity entity;
      private final double moveRadius;
      private boolean isAlreadySet;
      private Insentient pathfinderGoalEntity;
      private double walkSpeed;


      public PathfinderGoalFollowEntity(Insentient pathfinderGoalEntity, LivingEntity entity,
          double moveRadius, double walkSpeed) {
        this.entity = entity;
        this.moveRadius = moveRadius;
        this.pathfinderGoalEntity = pathfinderGoalEntity;
        this.walkSpeed = walkSpeed;
      }

      public boolean shouldExecute() {
        return this.isAlreadySet = !this.pathfinderGoalEntity.getNavigation().isDoneNavigating();
      }

      /**
       * Whether the goal should Terminate
       *
       * @return true if should terminate
       */
      @Override
      public boolean shouldTerminate() {
        if (!this.isAlreadySet) {
          return true;
        }
        return this.pathfinderGoalEntity.getBukkitEntity().getLocation()
            .distance(this.entity.getLocation()) > this.moveRadius;
      }

      /**
       * Runs initially and should be used to setUp goalEnvironment Condition needs to be defined thus
       * your code in it isn't called
       */
      @Override
      public void init() {
        if (!this.isAlreadySet) {
          this.pathfinderGoalEntity.getNavigation().moveTo(this.entity, walkSpeed);
        }
      }

      /**
       * Is called when {@link #shouldExecute()} returns true
       */
      @Override
      public void execute() {
        this.pathfinderGoalEntity.getControllerJump().jump();
      }

      public void reset() {

      }
    }
     

Recent Reviews

  1. MumbosHut
    MumbosHut
    5/5,
    Version: 1.152.0
    I believe this should be included in future Bukkit API updates, as PathFinding is lacking a necessary interface for developers- Thank you!
  2. Niklas409
    Niklas409
    5/5,
    Version: 1.3.3.4
    Danke, hab jetzt so lange es ohne probiert aber die 1.14 macht sich da so schwer mit XD <3
    1. ysl3000
      Author's Response
      Keep in mind to use your own goals. The default ones are not fixed yet.

      Thanks for the review.
  3. F1b3r
    F1b3r
    5/5,
    Version: 1.3.2
    OMG du bist mein Held xD Ich versuche mich schon seit Jahren an den PathfinderGoals und komme nie weiter. <3
    1. ysl3000
      Author's Response
      Thanks for the review.
  4. HealPot
    HealPot
    5/5,
    Version: version 1.3
    Excellent Idea. Please keep it up.
    1. ysl3000
      Author's Response
      Thanks for the review.