PathFinderAPI
1.162.0An API to add custom Pathfinder to an Entity (can be seen as an future BukkitAPI proposal)
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 fork I shall not name that has a better API built in.
JavaDoc Github-Page: https://yannicklamprecht.github.io/PathfindergoalAPI/
Example how to use it:
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):
Example
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() {
}
}Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta