/** * Returns an approximate absolute (world) position of the held item. * This assumes a ModelBiped like model and a normal item. * * @param entity Assumes a ModelBiped like creature * @param mainHand If main hand position * @return Absolute position in the world */ public static @Nonnull Vec3d getItemPosition(EntityLivingBase entity, boolean mainHand) { boolean left = (mainHand ? entity.getPrimaryHand() : entity.getPrimaryHand().opposite()) == EnumHandSide.LEFT; boolean firstPerson = entity instanceof EntityPlayer && ((EntityPlayer) entity).isUser() && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0; Vec3d dir = firstPerson ? entity.getForward() : Vec3d.fromPitchYawVector(new Vec2f(entity.rotationPitch, entity.renderYawOffset)); dir = dir.rotateYaw((float) (Math.PI / 5f) * (left ? 1f : -1f)).scale(0.75f); return dir.addVector(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ); }
mousePosition = new Vec2f(mouseX, mouseY);