use of net.minecraft.world.chunk.ChunkManager in project roadrunner by MaxNeedsSnacks.
the class WorldHelper method getEntitiesOfClass.
/**
* [VanillaCopy] Method for getting entities by class but also exclude one entity
*/
public static List<Entity> getEntitiesOfClass(World world, Entity except, Class<? extends Entity> entityClass, Box box) {
world.getProfiler().visit("getEntities");
int minChunkX = MathHelper.floor((box.minX - 2.0D) / 16.0D);
int maxChunkX = MathHelper.ceil((box.maxX + 2.0D) / 16.0D);
int minChunkZ = MathHelper.floor((box.minZ - 2.0D) / 16.0D);
int maxChunkZ = MathHelper.ceil((box.maxZ + 2.0D) / 16.0D);
List<Entity> entities = Lists.newArrayList();
ChunkManager chunkManager = world.getChunkManager();
for (int chunkX = minChunkX; chunkX < maxChunkX; ++chunkX) {
for (int chunkZ = minChunkZ; chunkZ < maxChunkZ; ++chunkZ) {
WorldChunk chunk = chunkManager.getWorldChunk(chunkX, chunkZ, false);
if (chunk != null) {
WorldHelper.getEntitiesOfClass(chunk, except, entityClass, box, entities);
}
}
}
return entities;
}
Aggregations