nicatronTg

Shank

Feb 2nd, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1.     public int volume(Location point1, Location point2){
  2.         int length = point1.getBlockX() - point2.getBlockX();
  3.         int width = point1.getBlockZ() - point2.getBlockZ();
  4.         int height = point1.getBlockY() - point2.getBlockY();
  5.         //Doesn't make sense to have negatives here...
  6.         debug("Parsed length, width, and height");
  7.         Location p1 = point1;
  8.         Location p2 = point2;
  9.        
  10.         int x1 = p1.getBlockX();
  11.         int x2 = p2.getBlockX();
  12.         int y1 = p1.getBlockY();
  13.         int y2 = p2.getBlockY();
  14.         int z1 = p1.getBlockZ();
  15.         int z2 = p2.getBlockZ();
  16.        
  17.         maxX = x1;
  18.         maxY = y1;
  19.         maxZ = z1;
  20.         minX = x2;
  21.         minY = y2;
  22.         minZ = z2;
  23.         debug("Setup variables");
  24.         if(x1 < x2){
  25.             maxX = x2;
  26.             minX = x1;
  27.         }
  28.         if(y1 < y2){
  29.             maxX = y2;
  30.             minX = y1;
  31.         }
  32.         if(z1 < z2){
  33.             maxX = z2;
  34.             minX = z1;
  35.         }
  36.         debug("Setting up volume");
  37.         if (length < 0){
  38.             length = length * -1;
  39.         }
  40.        
  41.         if (width < 0){
  42.             width = width * -1;
  43.         }
  44.        
  45.         if (height < 0){
  46.             height = height * -1;
  47.         }
  48.         return (int)(length*width*height);
  49.     }
  50.    
  51.     public void setPoint1(Location point) {
  52.         point1 = point;
  53.     }
  54.    
  55.     public void setPoint2(Location point) {
  56.         point2 = point;
  57.     }
  58.    
  59.     public int parseInt(String s){
  60.         try {
  61.             Integer i = new Integer(s);
  62.             return((int)(i));
  63.         } catch(Exception e){
  64.             return(0);
  65.         }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment