Advertisement
Guest User

Untitled

a guest
Feb 10th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public boolean playerWithin(Location l1, Location l2, Location pLoc) {
  2.     int x1 = Math.min(l1.getBlockX(), l2.getBlockX());
  3.     int y1 = Math.min(l1.getBlockY(), l2.getBlockY());
  4.     int z1 = Math.min(l1.getBlockZ(), l2.getBlockZ());
  5.     int x2 = Math.max(l1.getBlockX(), l2.getBlockX());
  6.     int y2 = Math.max(l1.getBlockY(), l2.getBlockY());
  7.     int z2 = Math.max(l1.getBlockZ(), l2.getBlockZ());
  8.     l1 = new Location(l1.getWorld(), x1, y1, z1);
  9.     l2 = new Location(l2.getWorld(), x2, y2, z2);
  10.  
  11.     return pLoc.getBlockX() >= l1.getBlockX()
  12.         && pLoc.getBlockX() <= l2.getBlockX()
  13.         && pLoc.getBlockY() >= l1.getBlockY()
  14.         && pLoc.getBlockY() <= l2.getBlockY()
  15.         && pLoc.getBlockZ() >= l1.getBlockZ()
  16.         && pLoc.getBlockZ() <= l2.getBlockZ();
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement