summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2011-03-07 13:48:35 -0500
committerTahg <tahgtahv@gmail.com>2011-03-10 13:06:59 -0500
commit39acc5817ef7433062172c541964c814cfdb76f2 (patch)
tree423c295c6e764e214eec8adff363a738d9d459b6 /src/main/java/org/bukkit
parentdf02c501a447af4c308ea3ca83c27d7cdefb313b (diff)
downloadcraftbukkit-39acc5817ef7433062172c541964c814cfdb76f2.tar
craftbukkit-39acc5817ef7433062172c541964c814cfdb76f2.tar.gz
craftbukkit-39acc5817ef7433062172c541964c814cfdb76f2.tar.lz
craftbukkit-39acc5817ef7433062172c541964c814cfdb76f2.tar.xz
craftbukkit-39acc5817ef7433062172c541964c814cfdb76f2.zip
Additional hooks for chunks
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftChunk.java28
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java1
2 files changed, 28 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index 24459f06..ba3fb9d4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -3,13 +3,16 @@ package org.bukkit.craftbukkit;
import java.lang.ref.WeakReference;
import java.util.HashMap;
+import net.minecraft.server.ChunkPosition;
import net.minecraft.server.WorldServer;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.entity.Entity;
import org.bukkit.craftbukkit.util.SoftMap;
public class CraftChunk implements Chunk {
@@ -61,5 +64,30 @@ public class CraftChunk implements Chunk {
}
return block;
}
+
+ public Entity[] getEntities() {
+ int count = 0, index = 0;
+ net.minecraft.server.Chunk chunk = getHandle();
+ for (int i = 0; i < 8; i++) {
+ count += chunk.m[i].size();
+ }
+ Entity[] entities = new Entity[count];
+ for (int i = 0; i < 8; i++) {
+ for (net.minecraft.server.Entity entity : (net.minecraft.server.Entity[])chunk.m[i].toArray()) {
+ entities[index++] = entity.getBukkitEntity();
+ }
+ }
+ return entities;
+ }
+
+ public BlockState[] getTileEntities() {
+ int index = 0;
+ net.minecraft.server.Chunk chunk = getHandle();
+ BlockState[] entities = new BlockState[chunk.l.size()];
+ for (ChunkPosition position : (ChunkPosition[])chunk.l.keySet().toArray()) {
+ entities[index++] = worldServer.getWorld().getBlockAt(position.a, position.b, position.c).getState();
+ }
+ return entities;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 18cbe19f..19487365 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -142,7 +142,6 @@ public class CraftWorld implements World {
}
provider.a.remove(x, z);
- provider.a.remove(x, z);
provider.e.remove(x, z);
provider.f.remove(chunk);