Directly access entity list

This replaces the very slow chunk dance that was being used.
Dieser Commit ist enthalten in:
Kenzie Togami 2015-01-13 22:32:02 -08:00 committet von wizjany
Ursprung 98a7257c47
Commit 372a520382
2 geänderte Dateien mit 8 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -87,17 +87,11 @@ public class BukkitWorld extends LocalWorld {
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
World world = getWorld();
List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>();
for (Vector2D pt : region.getChunks()) {
if (!world.isChunkLoaded(pt.getBlockX(), pt.getBlockZ())) {
continue;
}
final Entity[] ents = world.getChunkAt(pt.getBlockX(), pt.getBlockZ()).getEntities();
for (Entity ent : ents) {
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
entities.add(BukkitAdapter.adapt(ent));
}
for (Entity ent : ents) {
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
entities.add(BukkitAdapter.adapt(ent));
}
}
return entities;

Datei anzeigen

@ -373,18 +373,10 @@ public class ForgeWorld extends AbstractWorld {
public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<Entity>();
World world = getWorld();
for (Vector2D pt : region.getChunks()) {
if (!world.getChunkProvider().chunkExists(pt.getBlockX(), pt.getBlockZ())) {
continue;
}
Chunk chunk = world.getChunkProvider().provideChunk(pt.getBlockX(), pt.getBlockZ());
for (List<net.minecraft.entity.Entity> entitySubList : chunk.entityLists) {
for (net.minecraft.entity.Entity entity : entitySubList) {
if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) {
entities.add(new ForgeEntity(entity));
}
}
List<net.minecraft.entity.Entity> ents = world.loadedEntityList;
for (net.minecraft.entity.Entity entity : ents) {
if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) {
entities.add(new ForgeEntity(entity));
}
}
return entities;