Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean playerWithin(Location l1, Location l2, Location pLoc) {
- int x1 = Math.min(l1.getBlockX(), l2.getBlockX());
- int y1 = Math.min(l1.getBlockY(), l2.getBlockY());
- int z1 = Math.min(l1.getBlockZ(), l2.getBlockZ());
- int x2 = Math.max(l1.getBlockX(), l2.getBlockX());
- int y2 = Math.max(l1.getBlockY(), l2.getBlockY());
- int z2 = Math.max(l1.getBlockZ(), l2.getBlockZ());
- l1 = new Location(l1.getWorld(), x1, y1, z1);
- l2 = new Location(l2.getWorld(), x2, y2, z2);
- return pLoc.getBlockX() >= l1.getBlockX()
- && pLoc.getBlockX() <= l2.getBlockX()
- && pLoc.getBlockY() >= l1.getBlockY()
- && pLoc.getBlockY() <= l2.getBlockY()
- && pLoc.getBlockZ() >= l1.getBlockZ()
- && pLoc.getBlockZ() <= l2.getBlockZ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement