package com.censoredsoftware.Demigods.Engine.Object;

import org.bukkit.Location;
import org.bukkit.World;

import com.google.common.collect.DiscreteDomain;

public class Region
{
	private int x;
	private int z;

	public Region(int x, int z)
	{
		this.x = x;
		this.z = z;
	}

	public int getX()
	{
		return x;
	}

	public int getZ()
	{
		return z;
	}

	public Location getCenter(World world)
	{
		return new Location(world, x, 128, z);
	}

	public static class Util
	{
		public static Region getRegion(Location location)
		{
			return new Region(getRegionCoordinate(location.getBlockX()), getRegionCoordinate(location.getBlockZ()));
		}

		public static Region getRegion(int X, int Z)
		{
			return new Region(getRegionCoordinate(X), getRegionCoordinate(Z));
		}

		private static int getRegionCoordinate(int number)
		{
			int temp = number % 64;
			if(temp >= 32) return number + 64 - temp;
			return number - temp;
		}

		public static Size size()
		{
			return new Size();
		}

		private static class Size extends DiscreteDomain<Integer>
		{
			@Override
			public Integer next(Integer integer)
			{
				return integer + 64;
			}

			@Override
			public Integer previous(Integer integer)
			{
				return integer - 64;
			}

			@Override
			public long distance(Integer integer, Integer integer2)
			{
				return Math.abs((getRegionCoordinate(integer) / 64) - (getRegionCoordinate(integer2) / 64));
			}
		}
	}
}

@@ -173,16 +173,127 @@
 egion%0A%7B%0A
+%09public final static int REGION_LENGTH = 46;%0A%09public final static int HALF_REGION_LENGTH = REGION_LENGTH / 2;%0A%0A
 %09private
@@ -300,16 +300,16 @@
  int x;%0A
-
 %09private
@@ -949,18 +949,29 @@
 umber %25 
-64
+REGION_LENGTH
 ;%0A%09%09%09if(
@@ -982,10 +982,26 @@
  %3E= 
-32
+HALF_REGION_LENGTH
 ) re
@@ -1014,18 +1014,29 @@
 umber + 
-64
+REGION_LENGTH
  - temp;
@@ -1268,18 +1268,29 @@
 teger + 
-64
+REGION_LENGTH
 ;%0A%09%09%09%7D%0A%0A
@@ -1372,18 +1372,29 @@
 teger - 
-64
+REGION_LENGTH
 ;%0A%09%09%09%7D%0A%0A
@@ -1522,18 +1522,29 @@
 eger) / 
-64
+REGION_LENGTH
 ) - (get
@@ -1576,10 +1576,21 @@
 ) / 
-64
+REGION_LENGTH
 ));%0A

Change region size.