Advertisement
Corosus

Untitled

Jan 7th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. /* coords: unrotated world coord, rotation: quantify to 90, start: uncentered world coords for structure start point, size: structure size */
  2.     public static ChunkCoordinates rotateNew(ChunkCoordinates coords, int direction, Vec3 start, Vec3 size) {
  3.        
  4.         System.out.println("direction: " + direction);
  5.        
  6.         //center is not offsetted
  7.         //coords should be offset 0.5 before rotate math, guarantees no strange offset issues, flooring cleans it up afterwards perfectly
  8.        
  9.         double rotation = (direction * Math.PI/2D);
  10.         double centerX = start.xCoord+(size.xCoord/2D);
  11.         double centerZ = start.zCoord+(size.zCoord/2D);
  12.         double vecX = (coords.posX+0.5D) - centerX;
  13.         double vecZ = (coords.posZ+0.5D) - centerZ;
  14.        
  15.         Vec3 vec = Vec3.createVectorHelper(vecX, 0, vecZ);
  16.         vec.rotateAroundY((float)rotation);
  17.         return new ChunkCoordinates((int)Math.floor(start.xCoord+vec.xCoord), coords.posY, (int)Math.floor(start.zCoord+vec.zCoord));
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement