Example #1
0
 private void pathStep() {
   if (pathIterator.hasNext()) {
     Node n = pathIterator.next();
     Block b = null;
     if (last == null || runningPath.checkPath(n, last, true)) {
       b = n.b;
       if (last != null) {
         this.lookAtPoint(last.b.getLocation(), b.getLocation());
       }
       getHandle().setPosition(b.getX(), b.getY(), b.getZ());
     }
     last = n;
   } else {
     getHandle()
         .setPositionRotation(
             runningPath.getEnd().getX(),
             runningPath.getEnd().getY(),
             runningPath.getEnd().getZ(),
             runningPath.getEnd().getYaw(),
             runningPath.getEnd().getPitch());
     Bukkit.getServer().getScheduler().cancelTask(taskid);
     taskid = 0;
   }
   location =
       new Location(
           getHandle().world.getWorld(), getHandle().locX, getHandle().locY, getHandle().locZ);
 }
Example #2
0
  public void usePath(NPCPath path, Runnable onFail) {
    if (taskid == 0) {
      taskid =
          Bukkit.getServer()
              .getScheduler()
              .scheduleSyncRepeatingTask(
                  DeityNPCMain.plugin,
                  new Runnable() {

                    public void run() {
                      pathStep();
                    }
                  },
                  8L,
                  8L);
    }
    pathIterator = path.getPath().iterator();
    runningPath = path;
  }