Advertisement
Corosus

Untitled

Jan 11th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. //use this code to get the angle in degrees, ive changed it so it reverses the angle to oopsite of facing entitiy
  2.  
  3. double var16 = this.posX - this.entityToAttack.posX;
  4.                double var18 = this.posZ - this.entityToAttack.posZ;
  5.                this.rotationYaw = (float)(Math.atan2(var18, var16) * 180.0D / 3.1415927410125732D) - 90.0F;
  6.  
  7.  
  8.  
  9. //now, using that angle, get a new relative position based on your entities coords, fyi center = this, in your case
  10.  
  11. //offset angle
  12. float look = 0F;
  13. //distance, might wanna use 8 or something
  14. double dist = 1F;
  15.  
  16. double gatherX = center.posX + ((double)(-Math.sin((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  17.  
  18. double gatherY = center.posY-0.5 + (double)(-MathHelper.sin(center.rotationPitch / 180.0F * 3.1415927F) * dist) - 0D; //center.posY - 0D;
  19.  
  20. double gatherZ = center.posZ + ((double)(Math.cos((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  21.  
  22. //now you have coords to try, do basic checks like if its a valid movable to location then pathfind to it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement