Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2017 23:30
Show Gist options
  • Save anonymous/6accfef8260f21e28e49c2d8858be0a2 to your computer and use it in GitHub Desktop.
Save anonymous/6accfef8260f21e28e49c2d8858be0a2 to your computer and use it in GitHub Desktop.
public class EntityUtils {
public static void lookAt(EntityPlayer player, double x0, double y0, double z0) {
Vec3d pos = joazlazer.mods.amc.utility.MathHelper.toVec3d(te.getPos());
Vec3d eyePos = Minecraft.getMinecraft().player.getPositionVector().add(new Vec3d(0f, Minecraft.getMinecraft().player.getEyeHeight(), 0f));
Vec3d difference = pos.subtract(eyePos);
Vec3d normal = difference.normalize();
double yaw = Math.atan2(normal.z, normal.x);
double xz = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
double pitch = Math.atan2(normal.y, xz);
player.rotationPitch = (float) pitch;
player.rotationYawHead = (float) yaw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment