diff --git a/data/events.xml b/data/events.xml
index dbd1eabd..e0d83a81 100644
--- a/data/events.xml
+++ b/data/events.xml
@@ -101,4 +101,8 @@
org.apollo.game.event.impl.FocusUpdateEvent
+
+ org.apollo.game.event.impl.TakeTileItemEvent
+
+
\ No newline at end of file
diff --git a/src/org/apollo/game/event/impl/RegionChangeEvent.java b/src/org/apollo/game/event/impl/RegionChangeEvent.java
index 7277a643..94755b0a 100644
--- a/src/org/apollo/game/event/impl/RegionChangeEvent.java
+++ b/src/org/apollo/game/event/impl/RegionChangeEvent.java
@@ -33,4 +33,4 @@ public final class RegionChangeEvent extends Event {
return position;
}
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/Position.java b/src/org/apollo/game/model/Position.java
index da237834..51e28819 100644
--- a/src/org/apollo/game/model/Position.java
+++ b/src/org/apollo/game/model/Position.java
@@ -60,48 +60,42 @@ public final class Position {
@Override
public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
if (obj == null) {
return false;
}
+ if (this == obj) {
+ return true;
+ }
if (getClass() != obj.getClass()) {
return false;
}
Position other = (Position) obj;
- if (height != other.height) {
- return false;
- }
- if (x != other.x) {
- return false;
- }
- if (y != other.y) {
+ if (height != other.height || x != other.x || y != other.y) {
return false;
}
return true;
}
/**
- * Gets the x coordinate of the central region.
+ * Gets the x coordinate of the central sector.
*
- * @return The x coordinate of the central region.
+ * @return The x coordinate of the central sector.
*/
- public int getCentralRegionX() {
+ public int getCentralSectorX() {
return x / 8;
}
/**
- * Gets the y coordinate of the central region.
+ * Gets the y coordinate of the central sector.
*
- * @return The y coordinate of the central region.
+ * @return The y coordinate of the central sector.
*/
- public int getCentralRegionY() {
+ public int getCentralSectorY() {
return y / 8;
}
/**
- * Gets the distance between this position and another position. Only X and Y are considered (i.e. 2 dimensions).
+ * Gets the distance between this position and another position. Only x and y are considered (i.e. 2 dimensions).
*
* @param other The other position.
* @return The distance.
@@ -109,7 +103,6 @@ public final class Position {
public int getDistance(Position other) {
int deltaX = x - other.x;
int deltaY = y - other.y;
- // TODO will rounding up interfere with other stuff?
return (int) Math.ceil(Math.sqrt(deltaX * deltaX + deltaY * deltaY));
}
@@ -123,7 +116,7 @@ public final class Position {
}
/**
- * Gets the x coordinate inside the region of this position.
+ * Gets the x coordinate inside the sector of this position.
*
* @return The local x coordinate.
*/
@@ -132,17 +125,17 @@ public final class Position {
}
/**
- * Gets the local x coordinate inside the region of the {@code base} position.
+ * Gets the local x coordinate inside the sector of the {@code base} position.
*
* @param base The base position.
* @return The local x coordinate.
*/
public int getLocalX(Position base) {
- return x - base.getTopLeftRegionX() * 8;
+ return x - base.getTopLeftSectorX() * 8;
}
/**
- * Gets the y coordinate inside the region of this position.
+ * Gets the y coordinate inside the sector of this position.
*
* @return The local y coordinate.
*/
@@ -151,13 +144,13 @@ public final class Position {
}
/**
- * Gets the local y coordinate inside the region of the {@code base} position.
+ * Gets the local y coordinate inside the sector of the {@code base} position.
*
* @param base The base position.
* @return The local y coordinate.
*/
public int getLocalY(Position base) {
- return y - base.getTopLeftRegionY() * 8;
+ return y - base.getTopLeftSectorY() * 8;
}
/**
@@ -173,20 +166,20 @@ public final class Position {
}
/**
- * Gets the x coordinate of the region.
+ * Gets the x coordinate of the sector.
*
- * @return The region x coordinate.
+ * @return The sector x coordinate.
*/
- public int getTopLeftRegionX() {
+ public int getTopLeftSectorX() {
return x / 8 - 6;
}
/**
- * Gets the y coordinate of the region.
+ * Gets the y coordinate of the sector.
*
- * @return The region y coordinate.
+ * @return The sector y coordinate.
*/
- public int getTopLeftRegionY() {
+ public int getTopLeftSectorY() {
return y / 8 - 6;
}
@@ -228,7 +221,7 @@ public final class Position {
@Override
public String toString() {
- return Position.class.getName() + " [x=" + x + ", y=" + y + ", height=" + height + "]";
+ return Position.class.getName() + " [x= " + x + ", y= " + y + ", height= " + height + "]";
}
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/region/Region.java b/src/org/apollo/game/model/region/Region.java
deleted file mode 100644
index 9de0d124..00000000
--- a/src/org/apollo/game/model/region/Region.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apollo.game.model.region;
-
-/**
- * Represents an 8x8 region.
- *
- * @author Graham
- */
-public final class Region {
-
- /**
- * The width and height of the region in tiles.
- */
- public static final int REGION_SIZE = 8;
-
-}
diff --git a/src/org/apollo/game/model/region/RegionRepository.java b/src/org/apollo/game/model/region/RegionRepository.java
deleted file mode 100644
index 7f1e9562..00000000
--- a/src/org/apollo/game/model/region/RegionRepository.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apollo.game.model.region;
-
-/**
- * Manages the repository of regions.
- *
- * @author Graham
- */
-public class RegionRepository {
-
-}
diff --git a/src/org/apollo/game/model/region/package-info.java b/src/org/apollo/game/model/region/package-info.java
deleted file mode 100644
index 1d4e5a59..00000000
--- a/src/org/apollo/game/model/region/package-info.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Contains classes which represent in-game regions, blocks of 8x8 tiles which
- * are grouped, and can be used to store ground items, temporary objects, etc.
- * efficiently.
- */
-package org.apollo.game.model.region;
-
diff --git a/src/org/apollo/game/model/sector/Sector.java b/src/org/apollo/game/model/sector/Sector.java
new file mode 100644
index 00000000..81e6b7ca
--- /dev/null
+++ b/src/org/apollo/game/model/sector/Sector.java
@@ -0,0 +1,57 @@
+package org.apollo.game.model.sector;
+
+/**
+ * Represents an 8x8 area of the map.
+ *
+ * @author Graham
+ */
+public final class Sector {
+
+ /**
+ * The width and height of the sector, in tiles.
+ */
+ public static final int SECTOR_SIZE = 8;
+
+ /**
+ * The {@link SectorCoordinates} of this sector.
+ */
+ private final SectorCoordinates coordinates;
+
+ /**
+ * Creates a new sector.
+ *
+ * @param x The x coordinate of the sector.
+ * @param y The y coordinate of the sector.
+ */
+ public Sector(int x, int y) {
+ this(new SectorCoordinates(x, y));
+ }
+
+ /**
+ * Creates a new sector with the specified {@link SectorCoordinates}.
+ *
+ * @param coordinates The coordinates.
+ */
+ public Sector(SectorCoordinates coordinates) {
+ this.coordinates = coordinates;
+ }
+
+ /**
+ * Gets the x coordinate of this sector.
+ *
+ * @return The x coordinate.
+ */
+ public int getX() {
+ return coordinates.getX();
+ }
+
+ /**
+ * Gets the y coordinate of this sector.
+ *
+ * @return The y coordinate.
+ */
+ public int getY() {
+ return coordinates.getY();
+ }
+
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/region/RegionCoordinates.java b/src/org/apollo/game/model/sector/SectorCoordinates.java
similarity index 55%
rename from src/org/apollo/game/model/region/RegionCoordinates.java
rename to src/org/apollo/game/model/sector/SectorCoordinates.java
index 3d336248..abae29ba 100644
--- a/src/org/apollo/game/model/region/RegionCoordinates.java
+++ b/src/org/apollo/game/model/sector/SectorCoordinates.java
@@ -1,29 +1,29 @@
-package org.apollo.game.model.region;
+package org.apollo.game.model.sector;
/**
- * An immutable class which contains the coordinates of a region.
+ * An immutable class representing the coordinates of a sector.
*
* @author Graham
*/
-public final class RegionCoordinates {
+public final class SectorCoordinates {
/**
- * The X coordinate.
+ * The x coordinate.
*/
private final int x;
/**
- * The Y coordinate.
+ * The y coordinate.
*/
private final int y;
/**
- * Creates the region coordinates.
+ * Creates the sector coordinates.
*
* @param x The x coordinate.
* @param y The y coordinate.
*/
- public RegionCoordinates(int x, int y) {
+ public SectorCoordinates(int x, int y) {
this.x = x;
this.y = y;
}
@@ -36,29 +36,26 @@ public final class RegionCoordinates {
if (getClass() != obj.getClass()) {
return false;
}
- final RegionCoordinates other = (RegionCoordinates) obj;
- if (x != other.x) {
- return false;
- }
- if (y != other.y) {
+ final SectorCoordinates other = (SectorCoordinates) obj;
+ if (x != other.x || y != other.y) {
return false;
}
return true;
}
/**
- * Gets the X coordinate.
+ * Gets the x coordinate.
*
- * @return The X coordinate.
+ * @return The x coordinate.
*/
public int getX() {
return x;
}
/**
- * Gets the Y coordinate.
+ * Gets the y coordinate.
*
- * @return The Y coordinate.
+ * @return The y coordinate.
*/
public int getY() {
return y;
@@ -72,4 +69,4 @@ public final class RegionCoordinates {
return hash;
}
-}
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/sector/SectorRepository.java b/src/org/apollo/game/model/sector/SectorRepository.java
new file mode 100644
index 00000000..a2fa12ff
--- /dev/null
+++ b/src/org/apollo/game/model/sector/SectorRepository.java
@@ -0,0 +1,10 @@
+package org.apollo.game.model.sector;
+
+/**
+ * A repository of sectors.
+ *
+ * @author Graham
+ */
+public class SectorRepository {
+
+}
\ No newline at end of file
diff --git a/src/org/apollo/game/model/sector/package-info.java b/src/org/apollo/game/model/sector/package-info.java
new file mode 100644
index 00000000..560b5dfe
--- /dev/null
+++ b/src/org/apollo/game/model/sector/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Contains classes which represent in-game sectors - blocks of 8x8 tiles used to store ground items, temporary objects, etc.
+ * efficiently.
+ */
+package org.apollo.game.model.sector;
\ No newline at end of file
diff --git a/src/org/apollo/net/release/r317/RegionChangeEventEncoder.java b/src/org/apollo/net/release/r317/RegionChangeEventEncoder.java
index d883d9b2..a2a396f7 100644
--- a/src/org/apollo/net/release/r317/RegionChangeEventEncoder.java
+++ b/src/org/apollo/net/release/r317/RegionChangeEventEncoder.java
@@ -16,10 +16,11 @@ public final class RegionChangeEventEncoder extends EventEncoder