import { BlockPermutation, world } from "@minecraft/server";
import { SettingsHandler } from "./settings";
export function lavaSpongePlace(player, block) {
    // Check if lava sponge is enabled
    if (!SettingsHandler.isSpongeEnabled("lavaSponge")) {
        world.getDimension(block.dimension.id).runCommand(`setblock ${block.location.x} ${block.location.y} ${block.location.z} air destroy`);
        player.sendMessage("§cLava Sponge is disabled in settings!");
        return;
    }
    let lavaCount = 0;
    const position = block.location;
    for (let x = -3; x <= 3; x++) {
        for (let y = -3; y <= 3; y++) {
            for (let z = -3; z <= 3; z++) {
                const selectedBlock = world.getDimension(block.dimension.id).getBlock({ x: position.x + x, y: position.y + y, z: position.z + z });
                if (selectedBlock == undefined)
                    continue;
                if (selectedBlock.typeId != "minecraft:lava")
                    continue;
                lavaCount++;
                selectedBlock.setPermutation(BlockPermutation.resolve("minecraft:air"));
            }
        }
    }
    if (lavaCount > 0) {
        world.getDimension(block.dimension.id).spawnParticle("wildphire_spg:lava_sponge_particle", { x: position.x + 0.5, y: position.y, z: position.z + 0.5 });
        world.getDimension(block.dimension.id).playSound("bucket.fill_lava", position);
        world.getDimension(block.dimension.id).playSound("extinguish.candle", position);
        block.setPermutation(BlockPermutation.resolve("wildphire_spg:lava_sponge_full"));
    }
}
