Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 08:02:50 +02:00
Directly access entity list
This replaces the very slow chunk dance that was being used.
Dieser Commit ist enthalten in:
Ursprung
98a7257c47
Commit
372a520382
@ -87,19 +87,13 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
|
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
|
||||||
|
List<Entity> ents = world.getEntities();
|
||||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>();
|
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) {
|
for (Entity ent : ents) {
|
||||||
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
|
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
|
||||||
entities.add(BukkitAdapter.adapt(ent));
|
entities.add(BukkitAdapter.adapt(ent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,20 +373,12 @@ public class ForgeWorld extends AbstractWorld {
|
|||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
List<Entity> entities = new ArrayList<Entity>();
|
List<Entity> entities = new ArrayList<Entity>();
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
for (Vector2D pt : region.getChunks()) {
|
List<net.minecraft.entity.Entity> ents = world.loadedEntityList;
|
||||||
if (!world.getChunkProvider().chunkExists(pt.getBlockX(), pt.getBlockZ())) {
|
for (net.minecraft.entity.Entity entity : ents) {
|
||||||
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))) {
|
if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) {
|
||||||
entities.add(new ForgeEntity(entity));
|
entities.add(new ForgeEntity(entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren