Control flow improvements.

This commit is contained in:
TomyLobo 2013-08-24 10:43:51 +02:00
parent eacd147694
commit 878c26a8f0

View File

@ -1297,15 +1297,17 @@ public void simulateBlockMine(Vector pt) {
public LocalEntity[] getEntities(Region region) {
List<BukkitEntity> entities = new ArrayList<BukkitEntity>();
for (Vector2D pt : region.getChunks()) {
if (world.isChunkLoaded(pt.getBlockX(), pt.getBlockZ())) {
Entity[] ents = world.getChunkAt(pt.getBlockX(), pt.getBlockZ()).getEntities();
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(BukkitUtil.toLocalEntity(ent));
}
}
}
}
return entities.toArray(new BukkitEntity[entities.size()]);
}