// Path: src/main/java/cn/liutils/util/mc/EntitySelectors.java
// public static class SelectorList implements Predicate<Entity> {
// 
//     List<Predicate> list = new ArrayList();
// 
//     public SelectorList(Predicate... sels) {
//         for (Predicate i : sels)
//             list.add(i);
//     }
// 
//     public SelectorList append(Predicate selector) {
//         list.add(selector);
//         return this;
//     }
// 
//     @Override
//     public boolean apply(Entity entity) {
// 
//         for (Predicate i : list)
//             if (!i.apply(entity))
//                 return false;
//         return true;
//     }
// 
// }


import cn.liutils.util.mc.EntitySelectors.SelectorList;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
                    for (IBlockFilter f : filter) {
                        if (!f.accepts(world, x, y, z, world.getBlockState(new BlockPos(x, y, z)).getBlock())) {
                            match = false;
                            break;
                        }
                    }
                    if (match) {
                        ret.add(new BlockPos(x, y, z));
                        if (ret.size() == max)
                            return ret;
                    }
                }
            }
        }

        return ret;
    }

    public static List<Entity> getEntities(TileEntity te, double range, Predicate filter) {
        return getEntities(te.getWorld(), te.getPos().getX() + 0.5, te.getPos().getY() + 0.5, te.getPos().getZ() + 0.5, range, filter);
    }

    public static List<Entity> getEntities(Entity ent, double range, Predicate filter) {
        return getEntities(ent.worldObj, ent.posX, ent.posY, ent.posZ, range, filter);
    }

    public static List<Entity> getEntities(World world, double x, double y, double z, double range, Predicate filter) {
        AxisAlignedBB box = new AxisAlignedBB(
                x - range, y - range, z - range,
                x + range, y + range, z + range);
// Path: src/main/java/cn/liutils/util/mc/EntitySelectors.java
// public static class SelectorList implements Predicate<Entity> {
// 
//     List<Predicate> list = new ArrayList();
// 
//     public SelectorList(Predicate... sels) {
//         for (Predicate i : sels)
//             list.add(i);
//     }
// 
//     public SelectorList append(Predicate selector) {
//         list.add(selector);
//         return this;
//     }
// 
//     @Override
//     public boolean apply(Entity entity) {
// 
//         for (Predicate i : list)
//             if (!i.apply(entity))
//                 return false;
//         return true;
//     }
// 
// }


// Path: src/main/java/cn/liutils/util/mc/WorldUtils.java
import cn.liutils.util.mc.EntitySelectors.SelectorList;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;

                    for (IBlockFilter f : filter) {
                        if (!f.accepts(world, x, y, z, world.getBlockState(new BlockPos(x, y, z)).getBlock())) {
                            match = false;
                            break;
                        }
                    }
                    if (match) {
                        ret.add(new BlockPos(x, y, z));
                        if (ret.size() == max)
                            return ret;
                    }
                }
            }
        }

        return ret;
    }

    public static List<Entity> getEntities(TileEntity te, double range, Predicate filter) {
        return getEntities(te.getWorld(), te.getPos().getX() + 0.5, te.getPos().getY() + 0.5, te.getPos().getZ() + 0.5, range, filter);
    }

    public static List<Entity> getEntities(Entity ent, double range, Predicate filter) {
        return getEntities(ent.worldObj, ent.posX, ent.posY, ent.posZ, range, filter);
    }

    public static List<Entity> getEntities(World world, double x, double y, double z, double range, Predicate filter) {
        AxisAlignedBB box = new AxisAlignedBB(
                x - range, y - range, z - range,
                x + range, y + range, z + range);
        SelectorList list = new SelectorList(filter, new EntitySelectors.RestrictRange(x, y, z, range));