diff options
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftChunk.java | 28 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 1 |
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); |