Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public RegionWall getWallLocation(Location location){
- Location min = region.getMinimumPoint();
- Location max = region.getMaximumPoint();
- Location northWall = new Location(world, (min.getX() > max.getX() ? min.getX() : max.getX()), location.getY(), location.getZ());
- Location southWall = new Location(world, (min.getX() > max.getX() ? max.getX() : min.getX()), location.getY(), location.getZ());
- Location eastWall = new Location(world, location.getX(), location.getY(), (min.getZ() > max.getZ() ? min.getZ() : max.getZ()));
- Location westWall = new Location(world, location.getX(), location.getY(), (min.getZ() > max.getZ() ? max.getZ() : min.getZ()));
- double toNorth = Math.abs(northWall.distanceSquared(location));
- double toSouth = Math.abs(southWall.distanceSquared(location));
- double toEast = Math.abs(eastWall.distanceSquared(location));
- double toWest = Math.abs(westWall.distanceSquared(location));
- if(toNorth <= toSouth && toNorth <= toEast && toNorth <= toWest){
- return new RegionWall(Wall.NORTH, northWall);
- }else if(toSouth <= toNorth && toSouth <= toEast && toSouth <= toWest){
- return new RegionWall(Wall.SOUTH, southWall);
- }else if(toEast <= toNorth && toEast <= toSouth && toEast <= toWest){
- return new RegionWall(Wall.EAST, eastWall);
- }else if(toWest <= toNorth && toWest <= toEast && toWest <= toSouth){
- return new RegionWall(Wall.WEST, westWall);
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment