Search in sources :

Example 1 with Pair

use of com.wasteofplastic.acidisland.util.Pair in project acidisland by tastybento.

the class SafeSpotTeleport method getChunksToScan.

/**
 * Gets a set of chunk coords that will be scanned.
 * @param entity
 * @param location
 * @return
 */
private List<Pair<Integer, Integer>> getChunksToScan() {
    List<Pair<Integer, Integer>> result = new ArrayList<>();
    // Get island if available
    Island island = plugin.getGrid().getIslandAt(location);
    int maxRadius = island == null ? Settings.islandProtectionRange / 2 : island.getProtectionSize() / 2;
    maxRadius = maxRadius > MAX_RADIUS ? MAX_RADIUS : maxRadius;
    int x = location.getBlockX();
    int z = location.getBlockZ();
    // Create ever increasing squares around the target location
    int radius = 0;
    do {
        for (int i = x - radius; i <= x + radius; i += 16) {
            for (int j = z - radius; j <= z + radius; j += 16) {
                addChunk(result, island, new Pair<>(i, j), new Pair<>(i / 16, j / 16));
            }
        }
        radius++;
    } while (radius < maxRadius);
    return result;
}
Also used : ArrayList(java.util.ArrayList) Island(com.wasteofplastic.acidisland.Island) Pair(com.wasteofplastic.acidisland.util.Pair)

Aggregations

Island (com.wasteofplastic.acidisland.Island)1 Pair (com.wasteofplastic.acidisland.util.Pair)1 ArrayList (java.util.ArrayList)1