Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int volume(Location point1, Location point2){
- int length = point1.getBlockX() - point2.getBlockX();
- int width = point1.getBlockZ() - point2.getBlockZ();
- int height = point1.getBlockY() - point2.getBlockY();
- //Doesn't make sense to have negatives here...
- debug("Parsed length, width, and height");
- Location p1 = point1;
- Location p2 = point2;
- int x1 = p1.getBlockX();
- int x2 = p2.getBlockX();
- int y1 = p1.getBlockY();
- int y2 = p2.getBlockY();
- int z1 = p1.getBlockZ();
- int z2 = p2.getBlockZ();
- maxX = x1;
- maxY = y1;
- maxZ = z1;
- minX = x2;
- minY = y2;
- minZ = z2;
- debug("Setup variables");
- if(x1 < x2){
- maxX = x2;
- minX = x1;
- }
- if(y1 < y2){
- maxX = y2;
- minX = y1;
- }
- if(z1 < z2){
- maxX = z2;
- minX = z1;
- }
- debug("Setting up volume");
- if (length < 0){
- length = length * -1;
- }
- if (width < 0){
- width = width * -1;
- }
- if (height < 0){
- height = height * -1;
- }
- return (int)(length*width*height);
- }
- public void setPoint1(Location point) {
- point1 = point;
- }
- public void setPoint2(Location point) {
- point2 = point;
- }
- public int parseInt(String s){
- try {
- Integer i = new Integer(s);
- return((int)(i));
- } catch(Exception e){
- return(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment