Skip to content

Instantly share code, notes, and snippets.

@aikar
Created February 19, 2016 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/d1b632fb6ff16d9e439f to your computer and use it in GitHub Desktop.
Save aikar/d1b632fb6ff16d9e439f to your computer and use it in GitHub Desktop.
public static int DISTANCE = 2000;
public static int LIMIT = DISTANCE * 2;
public static int SPAWN_SIZE = 26;
public static WastelandOutpost getCurrentRegion(Location loc) {
final int blockX = loc.getBlockX();
final int blockZ = loc.getBlockZ();
final int x = (int) Math.floor(blockX / DISTANCE);
final int z = (int) Math.floor(blockZ / DISTANCE);
final int val = (1000 * x) + z;
switch (val) {
case -1:
return WastelandOutpost.NORTH;
case 999:
return WastelandOutpost.NORTH_EAST;
case 1000:
return WastelandOutpost.EAST;
case 1001:
return WastelandOutpost.SOUTH_EAST;
case 1:
return WastelandOutpost.SOUTH;
case -999:
return WastelandOutpost.SOUTH_WEST;
case -1000:
return WastelandOutpost.WEST;
case -1001:
return WastelandOutpost.NORTH_WEST;
case 0:
return WastelandOutpost.CENTER;
default:
return WastelandOutpost.CENTER;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment