Search in sources :

Example 1 with BlockChalice

use of hellfirepvp.astralsorcery.common.block.tile.BlockChalice in project AstralSorcery by HellFirePvP.

the class ChaliceHelper method findNearbyChalices.

@Nonnull
public static List<BlockPos> findNearbyChalices(World world, BlockPos origin, int distance) {
    Vector3 thisVector = new Vector3(origin).add(0.5, 1.5, 0.5);
    List<BlockPos> foundChalices = BlockDiscoverer.searchForBlocksAround(world, origin, MathHelper.clamp(distance, 0, 16), (w, pos, state) -> !pos.equals(origin) && state.getBlock() instanceof BlockChalice && !w.isBlockPowered(pos) && !(w.getBlockState(pos.down()).getBlock() instanceof BlockFountain));
    foundChalices.removeIf(pos -> {
        Vector3 chaliceVector = new Vector3(pos).add(0.5, 1.5, 0.5);
        RaytraceAssist assist = new RaytraceAssist(thisVector, chaliceVector);
        return !assist.isClear(world);
    });
    return foundChalices;
}
Also used : BlockFountain(hellfirepvp.astralsorcery.common.block.tile.BlockFountain) BlockChalice(hellfirepvp.astralsorcery.common.block.tile.BlockChalice) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) BlockPos(net.minecraft.util.math.BlockPos) RaytraceAssist(hellfirepvp.astralsorcery.common.util.RaytraceAssist) Nonnull(javax.annotation.Nonnull)

Aggregations

BlockChalice (hellfirepvp.astralsorcery.common.block.tile.BlockChalice)1 BlockFountain (hellfirepvp.astralsorcery.common.block.tile.BlockFountain)1 RaytraceAssist (hellfirepvp.astralsorcery.common.util.RaytraceAssist)1 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)1 Nonnull (javax.annotation.Nonnull)1 BlockPos (net.minecraft.util.math.BlockPos)1