Guest User

Border

a guest
Jul 9th, 2015
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. public class Border {
  2.     private Vector p1;
  3.     private Vector p2;
  4.  
  5.  
  6.     public Border(Vector p1, Vector p2) {
  7.         int x1 = Math.min(p1.getBlockX(), p2.getBlockX());
  8.         int y1 = Math.min(p1.getBlockY(), p2.getBlockY());
  9.         int z1 = Math.min(p1.getBlockZ(), p2.getBlockZ());
  10.         int x2 = Math.max(p1.getBlockX(), p2.getBlockX());
  11.         int y2 = Math.max(p1.getBlockY(), p2.getBlockY());
  12.         int z2 = Math.max(p1.getBlockZ(), p2.getBlockZ());
  13.         this.p1 = new Vector( x1, y1, z1);
  14.         this.p2 = new Vector( x2, y2, z2);
  15.     }
  16.  
  17.     public boolean contains(Location loc) {
  18.         if(loc == null) {
  19.             return false;
  20.         }
  21.         return loc.getBlockX() >= p1.getBlockX() && loc.getBlockX() <= p2.getBlockX()
  22.                 && loc.getBlockY() >= p1.getBlockY() && loc.getBlockY() <= p2.getBlockY()
  23.                 && loc.getBlockZ() >= p1.getBlockZ() && loc.getBlockZ() <= p2.getBlockZ();
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment