summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2010-12-26 23:22:15 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2010-12-26 23:22:15 +0000
commit144749512509cc7a2de139916dd7d5396250662a (patch)
tree27ae90985374be6bef59694fe023abc81d2b7051
parent06d9676c099bee10bb571e4f248cbeacd5ec79b2 (diff)
downloadbukkit-144749512509cc7a2de139916dd7d5396250662a.tar
bukkit-144749512509cc7a2de139916dd7d5396250662a.tar.gz
bukkit-144749512509cc7a2de139916dd7d5396250662a.tar.lz
bukkit-144749512509cc7a2de139916dd7d5396250662a.tar.xz
bukkit-144749512509cc7a2de139916dd7d5396250662a.zip
Added chunk, world and block interfaces
-rw-r--r--src/org/bukkit/Block.java88
-rw-r--r--src/org/bukkit/BlockFace.java47
-rw-r--r--src/org/bukkit/Chunk.java23
-rw-r--r--src/org/bukkit/World.java18
4 files changed, 176 insertions, 0 deletions
diff --git a/src/org/bukkit/Block.java b/src/org/bukkit/Block.java
new file mode 100644
index 00000000..9dcd7204
--- /dev/null
+++ b/src/org/bukkit/Block.java
@@ -0,0 +1,88 @@
+
+package org.bukkit;
+
+/**
+ * Represents a block
+ */
+public interface Block {
+ /**
+ * Gets the metadata for this block
+ *
+ * @return block specific metadata
+ */
+ byte getData();
+
+ /**
+ * Gets the block at the given face
+ *
+ * @param face Face of this block to return
+ * @return Block at the given face
+ */
+ Block getFace(final BlockFace face);
+
+ /**
+ * Gets the block at the given offsets
+ *
+ * @param modX X-coordinate offset
+ * @param modY Y-coordinate offset
+ * @param modZ Z-coordinate offset
+ * @return Block at the given offsets
+ */
+ Block getRelative(final int modX, final int modY, final int modZ);
+
+ /**
+ * Gets the type-ID of this block
+ *
+ * @return block type-ID
+ */
+ int getType();
+
+ /**
+ * Gets the world which contains this Block
+ *
+ * @return World containing this block
+ */
+ World getWorld();
+
+ /**
+ * Gets the x-coordinate of this block
+ *
+ * @return x-coordinate
+ */
+ int getX();
+
+ /**
+ * Gets the y-coordinate of this block
+ *
+ * @return y-coordinate
+ */
+ int getY();
+
+ /**
+ * Gets the z-coordinate of this block
+ *
+ * @return z-coordinate
+ */
+ int getZ();
+
+ /**
+ * Gets the chunk which contains this block
+ *
+ * @return Containing Chunk
+ */
+ Chunk getChunk();
+
+ /**
+ * Sets the metadata for this block
+ *
+ * @param data New block specific metadata
+ */
+ void setData(final byte data);
+
+ /**
+ * Sets the type-ID of this block
+ *
+ * @param type Type-ID to change this block to
+ */
+ void setType(final int type);
+}
diff --git a/src/org/bukkit/BlockFace.java b/src/org/bukkit/BlockFace.java
new file mode 100644
index 00000000..eb7f29c6
--- /dev/null
+++ b/src/org/bukkit/BlockFace.java
@@ -0,0 +1,47 @@
+package org.bukkit;
+
+/**
+ * Represents the face of a block
+ */
+public enum BlockFace {
+ North(-1, 0, 0),
+ East(0, 0, -1),
+ South(1, 0, 0),
+ West(0, 0, 1),
+ Up(0, 1, 0),
+ Down(0, -1, 0);
+
+ private final int modX;
+ private final int modY;
+ private final int modZ;
+
+ private BlockFace(final int modX, final int modY, final int modZ) {
+ this.modX = modX;
+ this.modY = modY;
+ this.modZ = modZ;
+ }
+
+ /**
+ * Get the amount of X-coordinates to modify to get the represented block
+ * @return Amount of X-coordinates to modify
+ */
+ public int getModX() {
+ return modX;
+ }
+
+ /**
+ * Get the amount of Y-coordinates to modify to get the represented block
+ * @return Amount of Y-coordinates to modify
+ */
+ public int getModY() {
+ return modY;
+ }
+
+ /**
+ * Get the amount of Z-coordinates to modify to get the represented block
+ * @return Amount of Z-coordinates to modify
+ */
+ public int getModZ() {
+ return modZ;
+ }
+}
diff --git a/src/org/bukkit/Chunk.java b/src/org/bukkit/Chunk.java
new file mode 100644
index 00000000..4bb9431f
--- /dev/null
+++ b/src/org/bukkit/Chunk.java
@@ -0,0 +1,23 @@
+
+package org.bukkit;
+
+/**
+ * Represents a chunk of blocks
+ */
+public interface Chunk {
+
+ /**
+ * Gets the X-coordinate of this chunk
+ *
+ * @return X-coordinate
+ */
+ int getX();
+
+ /**
+ * Gets the Z-coordinate of this chunk
+ *
+ * @return Z-coordinate
+ */
+ int getZ();
+
+}
diff --git a/src/org/bukkit/World.java b/src/org/bukkit/World.java
new file mode 100644
index 00000000..1ff0d7b3
--- /dev/null
+++ b/src/org/bukkit/World.java
@@ -0,0 +1,18 @@
+
+package org.bukkit;
+
+/**
+ * Represents a world.
+ *
+ * Currently there is only one world in the default Minecraft spec, but this
+ * may change with the addition of a functional Nether world
+ */
+public interface World {
+ public Block getBlockAt(int x, int y, int z);
+
+ public Chunk getChunkAt(int x, int z);
+
+ public Chunk getChunkAt(Block block);
+
+ public boolean isChunkLoaded();
+}