Advertisement
Corosus

Untitled

Oct 23rd, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.81 KB | None | 0 0
  1. public static void moveEnt(Entity ent, Entity center) {
  2.        
  3.         float look = 0F;
  4.         //int height = 10;
  5.         double dist = 2F;
  6.         double gatherX = center.posX + ((double)(-Math.sin((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  7.         double gatherY = center.posY - 0D;
  8.         double gatherZ = center.posZ + ((double)(Math.cos((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  9.        
  10.        
  11.        
  12.         double entDist = ent.getDistanceToEntity(center);
  13.        
  14.         double vecX = gatherX - ent.posX;
  15.         double vecY = gatherY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
  16.         double vecZ = gatherZ - ent.posZ;
  17.        
  18.         //vecX = ent.posX - gatherX;
  19.         //vecY = ent.posY - gatherY;
  20.         //vecZ = ent.posZ - gatherZ;
  21.        
  22.         double var1 = 1.0D;
  23.        
  24.         /*double var2 = ent.prevRotationPitch + (ent.rotationPitch - ent.prevRotationPitch) * var1;
  25.         double var3 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * var1;
  26.         double var4 = Math.cos(-var3 * 0.017453292F - 3.1415927F);
  27.         double var5 = Math.sin(-var3 * 0.017453292F - 3.1415927F);*/
  28.        
  29.         //return Vec3D.createVector((double)(var5 * var6), (double)var7, (double)(var4 * var6));
  30.        
  31.        
  32.        
  33.        
  34.        
  35.         //vecX = center.posX - ent.posX;
  36.         //vecY = center.posY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
  37.         //vecZ = center.posZ - ent.posZ;
  38.        
  39.         //mod_MovePlus.displayMessage(new StringBuilder().append("vecX: " + vecX).toString());
  40.         //tNode.bodyPiece.vecX = vecX;//tNode.bodyPiece.posX - tNode.nextNode.bodyPiece.posX;
  41.         //tNode.bodyPiece.vecY = vecY;//tNode.bodyPiece.posY - tNode.nextNode.bodyPiece.posY;
  42.         //tNode.bodyPiece.vecZ = vecZ;//tNode.bodyPiece.posZ - tNode.nextNode.bodyPiece.posZ;
  43.         double var9 = (double)MathHelper.sqrt_double(vecX * vecX + vecY * vecY + vecZ * vecZ);
  44.         //double speed = 0.2D * (Math.sqrt(dist)/10.0F);
  45.         double speed = 0.005D;
  46.        
  47.         double newspeed = speed;// * (Math.sqrt(entDist)/1.0F);
  48.    
  49.         //tNode.bodyPiece.posX += vecX / var9 * newspeed;
  50.         //tNode.bodyPiece.posY += vecY / var9 * newspeed;
  51.         //tNode.bodyPiece.posZ += vecZ / var9 * newspeed;
  52.        
  53.         //tNode.bodyPiece.setPosition(tNode.bodyPiece.posX, tNode.bodyPiece.posY, tNode.bodyPiece.posZ);
  54.        
  55.         float pitch = (float)((Math.atan2(vecX, vecZ) * 180D) / 3.1415927410125732D);
  56.        
  57.         float f = (float)((Math.atan2(vecZ, vecX) * 180D) / 3.1415927410125732D);
  58.        
  59.         float angle = f;
  60.        
  61.         angle += 180;
  62.         //pitch += 180;
  63.        
  64.         /*for(angle = f; angle < -180F; angle += 360F) { }
  65.         for(; angle >= 180F; angle -= 360F) { }
  66.         for(pitch = pitch; pitch < -180F; pitch += 360F) { }
  67.         for(; pitch >= 180F; pitch -= 360F) { }*/
  68.        
  69.         for(angle = f; angle < 0F; angle += 360F) { }
  70.         for(; angle >= 360F; angle -= 360F) { }
  71.         for(pitch = pitch; pitch < 0F; pitch += 180F) { }
  72.         for(; pitch >= 180F; pitch -= 180F) { }
  73.        
  74.        
  75.        
  76.         /*System.out.println(angle);
  77.         System.out.println(pitch);
  78.         System.out.println("-");*/
  79.        
  80.         //enable once 3d trig works
  81.         angle = angle - 20;
  82.         //pitch = pitch - 10;
  83.        
  84.         //float rad_angle =
  85.        
  86.        
  87.         float rad_angle = angle * 0.01745329F;// * 3.1415927410125732F * 2F;
  88.         float rad_pitch = pitch * 0.01745329F * 2F;// * 3.1415927410125732F * 2F;
  89.        
  90.         float uhh = 1.0F;
  91.        
  92.         float newY = uhh * (float)Math.sin(rad_pitch);
  93.         float projection = uhh * (float)Math.cos(rad_pitch);
  94.         projection = 1.0F;
  95.         System.out.println(projection);
  96.         float newX = projection * (float)Math.cos(rad_angle);
  97.         float newZ = projection * (float)Math.sin(rad_angle);
  98.        
  99.         float newVecX = newX / uhh;
  100.         float newVecY = newY / uhh;
  101.         float newVecZ = newZ / uhh;
  102.        
  103.         //float var6 = 1.0F;//(float)-Math.cos(-pitch * 0.017453292F);
  104.         //float var7 = (float)Math.sin(-pitch * 0.017453292F);
  105.        
  106.         //ent.motionX -= f3 * var6 * speed;//vecX / var9 * newspeed;
  107.         //ent.motionY -= var7 * speed;//vecY / var9 * newspeed;
  108.         //ent.motionZ += f4 * var6 * speed;// / var9 * newspeed;
  109.        
  110.         ent.motionX += newVecX * speed;
  111.         //ent.motionY += newVecY * speed;
  112.         ent.motionZ += newVecZ * speed;
  113.        
  114.     }
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement