Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lolmod.entitys.ai;
- import lolmod.entitys.EntityNeutral;
- import net.minecraft.entity.ai.EntityAIBase;
- import net.minecraft.pathfinding.PathNavigate;
- public class EntityAIWalkHome extends EntityAIBase {
- private final EntityNeutral creature;
- private final double moveSpeed;
- private final PathNavigate pathfinder;
- public EntityAIWalkHome(EntityNeutral creatureIn) {
- this.creature = creatureIn;
- this.moveSpeed = 1D;
- this.pathfinder = creatureIn.getNavigator();
- this.setMutexBits(1);
- }
- /**
- * Returns whether the EntityAIBase should begin execution.
- */
- public boolean shouldExecute() {
- return this.creature.getPatienceBar()<=0 && this.creature.getDistance(this.creature.getHomePosition().getX(), this.creature.getHomePosition().getY(), this.creature.getHomePosition().getZ()) > 1;
- }
- /**
- * Returns whether an in-progress EntityAIBase should continue executing
- */
- public boolean shouldContinueExecuting() {
- return !this.pathfinder.noPath() && shouldExecute();
- }
- /**
- * Execute a one shot task or start executing a continuous task
- */
- public void startExecuting() {
- this.pathfinder.tryMoveToXYZ(this.creature.getHomePosition().getX(), this.creature.getHomePosition().getY(), this.creature.getHomePosition().getZ(), moveSpeed);
- }
- /**
- * Reset the task's internal state. Called when this task is interrupted by another one
- */
- public void resetTask() {
- this.pathfinder.clearPathEntity();
- }
- /**
- * Keep ticking a continuous task that has already been started
- */
- public void updateTask() {
- this.creature.getLookHelper().setLookPosition(this.creature.getHomePosition().getX(), this.creature.getHomePosition().getY()+2, this.creature.getHomePosition().getZ(), 10.0F, (float)this.creature.getVerticalFaceSpeed());
- this.pathfinder.tryMoveToXYZ(this.creature.getHomePosition().getX(), this.creature.getHomePosition().getY(), this.creature.getHomePosition().getZ(), moveSpeed);
- if(this.pathfinder.noPath())
- this.creature.setPatienceBar(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement