Additional hooks for chunks

By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2011-03-07 13:48:35 -05:00
parent fcf7b1039e
commit b79442a3fb
2 changed files with 28 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -141,7 +141,6 @@ public class CraftWorld implements World {
provider.a(chunk);
}
provider.a.remove(x, z);
provider.a.remove(x, z);
provider.e.remove(x, z);
provider.f.remove(chunk);