public WorldEditorException(final String msg, final Location loc) { super( msg + " at " + loc.getWorld().getName() + ":" + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ()); this.loc = loc; }
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); }