Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void moveEnt(Entity ent, Entity center) {
- float look = 0F;
- //int height = 10;
- double dist = 2F;
- double gatherX = center.posX + ((double)(-Math.sin((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
- double gatherY = center.posY - 0D;
- double gatherZ = center.posZ + ((double)(Math.cos((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
- double entDist = ent.getDistanceToEntity(center);
- double vecX = gatherX - ent.posX;
- double vecY = gatherY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
- double vecZ = gatherZ - ent.posZ;
- //vecX = ent.posX - gatherX;
- //vecY = ent.posY - gatherY;
- //vecZ = ent.posZ - gatherZ;
- double var1 = 1.0D;
- /*double var2 = ent.prevRotationPitch + (ent.rotationPitch - ent.prevRotationPitch) * var1;
- double var3 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * var1;
- double var4 = Math.cos(-var3 * 0.017453292F - 3.1415927F);
- double var5 = Math.sin(-var3 * 0.017453292F - 3.1415927F);*/
- //return Vec3D.createVector((double)(var5 * var6), (double)var7, (double)(var4 * var6));
- //vecX = center.posX - ent.posX;
- //vecY = center.posY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
- //vecZ = center.posZ - ent.posZ;
- //mod_MovePlus.displayMessage(new StringBuilder().append("vecX: " + vecX).toString());
- //tNode.bodyPiece.vecX = vecX;//tNode.bodyPiece.posX - tNode.nextNode.bodyPiece.posX;
- //tNode.bodyPiece.vecY = vecY;//tNode.bodyPiece.posY - tNode.nextNode.bodyPiece.posY;
- //tNode.bodyPiece.vecZ = vecZ;//tNode.bodyPiece.posZ - tNode.nextNode.bodyPiece.posZ;
- double var9 = (double)MathHelper.sqrt_double(vecX * vecX + vecY * vecY + vecZ * vecZ);
- //double speed = 0.2D * (Math.sqrt(dist)/10.0F);
- double speed = 0.005D;
- double newspeed = speed;// * (Math.sqrt(entDist)/1.0F);
- //tNode.bodyPiece.posX += vecX / var9 * newspeed;
- //tNode.bodyPiece.posY += vecY / var9 * newspeed;
- //tNode.bodyPiece.posZ += vecZ / var9 * newspeed;
- //tNode.bodyPiece.setPosition(tNode.bodyPiece.posX, tNode.bodyPiece.posY, tNode.bodyPiece.posZ);
- float pitch = (float)((Math.atan2(vecX, vecZ) * 180D) / 3.1415927410125732D);
- float f = (float)((Math.atan2(vecZ, vecX) * 180D) / 3.1415927410125732D);
- float angle = f;
- angle += 180;
- //pitch += 180;
- /*for(angle = f; angle < -180F; angle += 360F) { }
- for(; angle >= 180F; angle -= 360F) { }
- for(pitch = pitch; pitch < -180F; pitch += 360F) { }
- for(; pitch >= 180F; pitch -= 360F) { }*/
- for(angle = f; angle < 0F; angle += 360F) { }
- for(; angle >= 360F; angle -= 360F) { }
- for(pitch = pitch; pitch < 0F; pitch += 180F) { }
- for(; pitch >= 180F; pitch -= 180F) { }
- /*System.out.println(angle);
- System.out.println(pitch);
- System.out.println("-");*/
- //enable once 3d trig works
- angle = angle - 20;
- //pitch = pitch - 10;
- //float rad_angle =
- float rad_angle = angle * 0.01745329F;// * 3.1415927410125732F * 2F;
- float rad_pitch = pitch * 0.01745329F * 2F;// * 3.1415927410125732F * 2F;
- float uhh = 1.0F;
- float newY = uhh * (float)Math.sin(rad_pitch);
- float projection = uhh * (float)Math.cos(rad_pitch);
- projection = 1.0F;
- System.out.println(projection);
- float newX = projection * (float)Math.cos(rad_angle);
- float newZ = projection * (float)Math.sin(rad_angle);
- float newVecX = newX / uhh;
- float newVecY = newY / uhh;
- float newVecZ = newZ / uhh;
- //float var6 = 1.0F;//(float)-Math.cos(-pitch * 0.017453292F);
- //float var7 = (float)Math.sin(-pitch * 0.017453292F);
- //ent.motionX -= f3 * var6 * speed;//vecX / var9 * newspeed;
- //ent.motionY -= var7 * speed;//vecY / var9 * newspeed;
- //ent.motionZ += f4 * var6 * speed;// / var9 * newspeed;
- ent.motionX += newVecX * speed;
- //ent.motionY += newVecY * speed;
- ent.motionZ += newVecZ * speed;
- }
Advertisement
Add Comment
Please, Sign In to add comment