Esempio n. 1
0
 public static HumanNPC spawnNPC(HumanNPC npc, Location loc) {
   try {
     WorldServer ws = getWorldServer(loc.getWorld());
     ws.addEntity(npc.getHandle());
     npc.teleport(loc);
     ws.players.remove(npc.getHandle());
     return npc;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 2
0
 // Rotates an NPC.
 public static void faceEntity(HumanNPC npc, Entity entity) {
   if (npc.getWorld() != entity.getWorld()) return;
   if (Settings.getBoolean("RealisticPathing")
       && !npc.getHandle().isInSight(((CraftEntity) entity).getHandle())) return;
   Location loc = npc.getLocation(), pl = entity.getLocation();
   double xDiff = pl.getX() - loc.getX();
   double yDiff = pl.getY() - loc.getY();
   double zDiff = pl.getZ() - loc.getZ();
   double DistanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
   double DistanceY = Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
   double yaw = (Math.acos(xDiff / DistanceXZ) * 180 / Math.PI);
   double pitch = (Math.acos(yDiff / DistanceY) * 180 / Math.PI) - 90;
   if (zDiff < 0.0) {
     yaw = yaw + (Math.abs(180 - yaw) * 2);
   }
   npc.getHandle().yaw = (float) yaw - 90;
   npc.getHandle().az = npc.getHandle().yaw;
   npc.getHandle().pitch = (float) pitch;
 }
Esempio n. 3
0
 public static void removeNPCFromPlayerList(HumanNPC npc) {
   getWorldServer(npc.getPlayer().getWorld()).players.remove(npc.getHandle());
 }
Esempio n. 4
0
 public static void despawnNPC(HumanNPC npc) {
   despawnNPC(npc.getHandle());
 }