Solved Custom PathFinder problem

Discussion in 'Spigot Plugin Development' started by EdoDev2, May 14, 2016.

  1. Hi, I have a problem with my custom pathfinder.
    Here is the code:
    Code (Text):
    import net.minecraft.server.v1_9_R1.Navigation;
    import net.minecraft.server.v1_9_R1.PathEntity;
    import net.minecraft.server.v1_9_R1.PathfinderGoal;
    import org.bukkit.Location;

    import net.minecraft.server.v1_9_R1.EntityMonster;
    import org.bukkit.entity.Entity;

    public class PathFinderGoalWalkToLoc extends PathfinderGoal
    {
        private double speed;

        private EntityMonster entity;

        private Location loc;

        private Navigation navigation;

        private PathEntity pathEntity;

        private int currentLoc;

        public PathFinderGoalWalkToLoc(EntityMonster entity, Location loc, double speed)
        {
            this.entity = entity;
            this.loc = loc;
            this.currentLoc = 1;
            this.navigation = (Navigation) this.entity.getNavigation();
            this.speed = speed;

        }

        @Override
        public boolean b() {
            return false;
        }

        @Override
        public boolean a()
        {
            if (this.entity.getBukkitEntity().getLocation().distance(this.loc) == 0) {
                c.current++;
                c.executePath((Entity) entity);
                System.out.println("Debug");
                return true;
            }
            if (this.entity.getBukkitEntity().getLocation().distance(this.loc) > 0) {
                return true;
            }

            return false;
        }


        @Override
        public void c()
        {
            this.pathEntity = this.navigation.a(c.locs.get(c.current).getX(), c.locs.get(c.current).getY(), c.locs.get(c.current).getZ());
            this.navigation.a(pathEntity, speed);
        }
    }
     
    I want that a mob follow a list of locations in a list before reach the last location.
    This part of code in the method a() it isn't executed:
    Code (Text):
            if (this.entity.getBukkitEntity().getLocation().distance(this.loc) == 0) {
                c.current++;
                c.executePath((Entity) entity);
                System.out.println("Debug");
                return true;
            }
    Have you ideas?
    Thanks!
     
  2. Solved by myself!
     
  3. Would be nice if you posted your error and solution, in case anyone will see this thread in the future.
     
    • Agree Agree x 4