Пример #1
0
 public void lookAtPoint(final Location point) {
   if (this.getEntity().getBukkitEntity().getWorld() != point.getWorld()) return;
   final Location npcLoc = ((LivingEntity) this.getEntity().getBukkitEntity()).getEyeLocation();
   final double xDiff = point.getX() - npcLoc.getX();
   final double yDiff = point.getY() - npcLoc.getY();
   final double zDiff = point.getZ() - npcLoc.getZ();
   final double DistanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
   final double DistanceY = Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
   double newYaw = Math.acos(xDiff / DistanceXZ) * 180 / Math.PI;
   final double newPitch = Math.acos(yDiff / DistanceY) * 180 / Math.PI - 90;
   if (zDiff < 0.0) newYaw = newYaw + Math.abs(180 - newYaw) * 2;
   this.setYaw((float) (newYaw - 90));
   this.setPitch((float) newPitch);
 }
Пример #2
0
 public void putInBed(final Location bed) {
   this.getEntity().setPosition(bed.getX(), bed.getY(), bed.getZ());
   this.getEntity().a((int) bed.getX(), (int) bed.getY(), (int) bed.getZ());
 }