Advertisement
Guest User

faceEntity(target, false/true)

a guest
Aug 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. public float[] faceEntity(Entity entityIn, boolean instant) {
  2.  
  3.         double var4 = entityIn.posX - mc.thePlayer.posX;
  4.         double var8 = entityIn.posZ - mc.thePlayer.posZ;
  5.  
  6.         EntityLivingBase var14 = (EntityLivingBase) entityIn;
  7.         double var6 = var14.posY + var14.getEyeHeight() * 0.6D - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight());
  8.  
  9.         double var141 = MathHelper.sqrt_double(var4 * var4 + var8 * var8);
  10.         float var12 = (float) (Math.atan2(var8, var4) * 180.0D / 3.141592653589793D) - 90.0F;
  11.         float var13 = (float) -(Math.atan2(var6, var141) * 180.0D / 3.141592653589793D);
  12.  
  13.         /** float agr = (float) (new Random().nextInt(35) + 10)/ 10; **/
  14.         float agr = (float) (new Random().nextInt(55) + 10) / 10;
  15.         float add = agr > 0.0F ? agr : 0.2F;
  16.  
  17.         add *= add;
  18.  
  19.         float[] rot = { updateRotation(lastYaw, var12, add), updateRotation(lastPitch, var13, 0.7F) };
  20.  
  21.         return rot;
  22.     }
  23.  
  24.     private float updateRotation(float jyaw, float aquaPitch, float mcFl) {
  25.         float var4 = MathHelper.wrapAngleTo180_float(aquaPitch - jyaw);
  26.         float tog = var4 + mcFl;
  27.         if (tog < 0.0F) {
  28.             mcFl -= tog / 6.0F;
  29.         } else if (tog > 0.0F) {
  30.             mcFl += tog / 6.0F;
  31.         }
  32.         if (var4 > mcFl) {
  33.             var4 = mcFl;
  34.         }
  35.         if (var4 < -mcFl) {
  36.             var4 = -mcFl;
  37.         }
  38.         return jyaw + var4;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement