@@ -0,0 +1,3409 @@
+package net.wayward_realms.waywardlib.util.lineofsight;%0A%0Aimport org.bukkit.Material;%0Aimport org.bukkit.block.Block;%0Aimport org.bukkit.entity.LivingEntity;%0Aimport org.bukkit.util.BlockIterator;%0A%0Aimport java.util.*;%0A%0A/**%0A * Utility class for finding the line of sight of living entities%0A */%0Apublic class LineOfSightUtils %7B%0A%0A    private static List%3CBlock%3E getLineOfSight(LivingEntity entity, Collection%3CMaterial%3E transparent, int maxDistance, int maxLength) %7B%0A        if (maxDistance %3E 120) %7B%0A            maxDistance = 120;%0A        %7D%0A        ArrayList%3CBlock%3E blocks = new ArrayList%3C%3E();%0A        Iterator%3CBlock%3E itr = new BlockIterator(entity, maxDistance);%0A        while (itr.hasNext()) %7B%0A            Block block = itr.next();%0A            blocks.add(block);%0A            if (maxLength != 0 && blocks.size() %3E maxLength) %7B%0A                blocks.remove(0);%0A            %7D%0A            Material material = block.getType();%0A            if (transparent == null) %7B%0A                if (material != Material.AIR) %7B%0A                    break;%0A                %7D%0A            %7D else %7B%0A                if (!transparent.contains(material)) %7B%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        return blocks;%0A    %7D%0A%0A    /**%0A     * Gets all blocks along the living entity's line of sight.%0A     * %3Cp%3E%0A     * This list contains all blocks from the living entity's eye position%0A     * to target inclusive.%0A     *%0A     * @param entity the entity to get the line of sight of%0A     * @param transparent HashSet containing all transparent block materials (set to null for only air)%0A     * @param maxDistance this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)%0A     * @return list containing all blocks along the living entity's line of sight%0A     */%0A    public static List%3CBlock%3E getLineOfSight(LivingEntity entity, Collection%3CMaterial%3E transparent, int maxDistance) %7B%0A        return getLineOfSight(entity, transparent, maxDistance, 0);%0A    %7D%0A%0A    /**%0A     * Gets the block that the living entity has targeted.%0A     *%0A     * @param entity the entity to get the target block of%0A     * @param transparent HashSet containing all transparent block materials (set to null for only air)%0A     * @param maxDistance this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)%0A     * @return block that the living entity has targeted%0A     */%0A    public static Block getTargetBlock(LivingEntity entity, HashSet%3CMaterial%3E transparent, int maxDistance) %7B%0A        List%3CBlock%3E blocks = getLineOfSight(entity, transparent, maxDistance, 1);%0A        return blocks.get(0);%0A    %7D%0A%0A    /**%0A     * Gets the last two blocks along the living entity's line of sight.%0A     * %3Cp%3E%0A     * The target block will be the last block in the list.%0A     *%0A     * @param entity the entity to get the last two target blocks of%0A     * @param transparent HashSet containing all transparent block materials (set to null for only air)%0A     * @param maxDistance this is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks%0A     * @return list containing the last 2 blocks along the living entity's line of sight%0A     */%0A    public static List%3CBlock%3E getLastTwoTargetBlocks(LivingEntity entity, HashSet%3CMaterial%3E transparent, int maxDistance) %7B%0A        return getLineOfSight(entity, transparent, maxDistance, 2);%0A    %7D%0A%0A%7D%0A

Add line of sight utils, closes #158