-
-
Save anonymous/6accfef8260f21e28e49c2d8858be0a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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