turt2live

Untitled

Mar 26th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1.     public RegionWall getWallLocation(Location location){
  2.         Location min = region.getMinimumPoint();
  3.         Location max = region.getMaximumPoint();
  4.         Location northWall = new Location(world, (min.getX()>max.getX()?min.getX():max.getX()), location.getY(), location.getZ());
  5.         Location southWall = new Location(world, (min.getX()>max.getX()?max.getX():min.getX()), location.getY(), location.getZ());
  6.         Location eastWall = new Location(world, location.getX(), location.getY(), (min.getZ()>max.getZ()?min.getZ():max.getZ()));
  7.         Location westWall = new Location(world, location.getX(), location.getY(), (min.getZ()>max.getZ()?max.getZ():min.getZ()));
  8.         Location ceil = new Location(world, location.getX(), (min.getY()>max.getY()?min.getY():max.getY()), location.getZ());
  9.         Location floor = new Location(world, location.getX(), (min.getY()>max.getY()?max.getY():min.getY()), location.getZ());
  10.         double toNorth = Math.abs(northWall.distanceSquared(location));
  11.         double toSouth = Math.abs(southWall.distanceSquared(location));
  12.         double toEast = Math.abs(eastWall.distanceSquared(location));
  13.         double toWest = Math.abs(westWall.distanceSquared(location));
  14.         double toFloor = Math.abs(floor.distanceSquared(location));
  15.         double toCeil = Math.abs(ceil.distanceSquared(location));
  16.         if(toNorth>=toSouth&&toNorth>=toEast&&toNorth>=toWest&&toNorth>=toFloor&&toNorth>=toCeil){
  17.             return new RegionWall(Wall.NORTH, northWall);
  18.         }else if(toSouth>=toNorth&&toSouth>=toEast&&toSouth>=toWest&&toSouth>=toFloor&&toSouth>=toCeil){
  19.             return new RegionWall(Wall.SOUTH, southWall);
  20.         }else if(toEast>=toNorth&&toEast>=toSouth&&toEast>=toWest&&toEast>=toFloor&&toEast>=toCeil){
  21.             return new RegionWall(Wall.EAST, eastWall);
  22.         }else if(toWest>=toNorth&&toWest>=toEast&&toWest>=toSouth&&toWest>=toFloor&&toWest>=toCeil){
  23.             return new RegionWall(Wall.WEST, westWall);
  24.         }else if(toCeil>=toNorth&&toCeil>=toEast&&toCeil>=toWest&&toCeil>=toFloor&&toCeil>=toSouth){
  25.             return new RegionWall(Wall.CEILING, ceil);
  26.         }else if(toFloor>=toNorth&&toFloor>=toEast&&toFloor>=toWest&&toFloor>=toCeil&&toFloor>=toSouth){
  27.             return new RegionWall(Wall.FLOOR, floor);
  28.         }
  29.         return null;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment