private void aimAtTarget() { if (target == null) return; int bowCharge = Minecraft.getMinecraft().thePlayer.getItemInUseDuration(); velocity = bowCharge / 20; velocity = (velocity * velocity + velocity * 2) / 3; if (WurstClient.INSTANCE.mods.fastBowMod.isActive()) velocity = 1; if (velocity < 0.1) { if (target instanceof EntityLivingBase) EntityUtils.faceEntityClient((EntityLivingBase) target); return; } if (velocity > 1) velocity = 1; double posX = target.posX + (target.posX - target.prevPosX) * 5 - Minecraft.getMinecraft().thePlayer.posX; double posY = target.posY + (target.posY - target.prevPosY) * 5 + target.getEyeHeight() - 0.15 - Minecraft.getMinecraft().thePlayer.posY - Minecraft.getMinecraft().thePlayer.getEyeHeight(); double posZ = target.posZ + (target.posZ - target.prevPosZ) * 5 - Minecraft.getMinecraft().thePlayer.posZ; float yaw = (float) (Math.atan2(posZ, posX) * 180 / Math.PI) - 90; double y2 = Math.sqrt(posX * posX + posZ * posZ); float g = 0.006F; float tmp = (float) (velocity * velocity * velocity * velocity - g * (g * (y2 * y2) + 2 * posY * (velocity * velocity))); float pitch = (float) -Math.toDegrees(Math.atan((velocity * velocity - Math.sqrt(tmp)) / (g * y2))); Minecraft.getMinecraft().thePlayer.rotationYaw = yaw; Minecraft.getMinecraft().thePlayer.rotationPitch = pitch; }
@Override public void update(Player player, long currentTime) { angle = (float) Math.toDegrees( Math.atan2( -(player.getPosition().getZ() - position.getZ()), player.getPosition().getX() - position.getX())); angle += (Math.sin( ((double) ((currentTime - startTime) % millisecondsToSwivel) / (double) millisecondsToSwivel) * Math.PI * 2) * degreesToSwivel); }