package ca.recrown.islandsurvivalcraft.world;

import java.util.Random;

import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;

import ca.recrown.islandsurvivalcraft.world.generation.IslandBiomeGenerator;
import ca.recrown.islandsurvivalcraft.world.generation.IslandWorldGenerator;

public class IslandSurvivalCraftChunkGenerator extends ChunkGenerator {
    private final IslandWorldGeneratorAlternator alternator;
    
    public IslandSurvivalCraftChunkGenerator(IslandBiomeGenerator biomeGenerator) {
        alternator = new IslandWorldGeneratorAlternator(biomeGenerator);
    }

    @Override
    public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
        IslandWorldGenerator worldGenerator = alternator.getIslandChunkGeneratorSystemForWorld(world, random);
        ChunkData chunk = createChunkData(world);

        for (int localX = 0; localX < 16; localX++) {
            for (int localZ = 0; localZ < 16; localZ++) {
                worldGenerator.GenerateChunk(chunkX, chunkZ, localX, localZ, chunk, biome);
            }
        }
        return chunk;
    }
}