Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 @Override
 public void onUpdate() {
   target = null;
   if (Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() != null
       && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem()
           instanceof ItemBow
       && Minecraft.getMinecraft().gameSettings.keyBindUseItem.pressed) {
     target = EntityUtils.getClosestEntity(true, true);
     aimAtTarget();
   }
 }