import { Block } from "@minecraft/server"
import { Piki } from "./typingConstants"

export class CommandHelper {

    /**
     * 
     * @param {string} structureFile 
     * @param {import("@minecraft/server").Vector3} location 
     * @returns 
     */
    static generateStructureCommand(structureFile, location) {
        const {x, y, z} = location
        return `structure load "${Piki.structureNamespace}${structureFile}" ${x} ${y} ${z}`
    }

    static generateClearCommand(itemTypeId, maxCount = 1, target = "@s", data = 0) {
        return `clear ${target} ${itemTypeId} ${data} ${maxCount}`
    }

    /**
     * @todo: Handle different parameters
     */
    static generateReplaceItemCommand(itemTypeId, equipmentSlot, amount = 1, target = "@s") {
        return `replaceitem entity ${target} ${equipmentSlot} 0 ${itemTypeId} ${amount}`
    }

    static generatePlaysoundCommand(sound, location, volume = 1, pitch = 1, minimumVolume = 1, target = "@s") {
        const {x, y, z} = location
        return `playsound ${sound} ${target} ${x} ${y} ${z} ${volume} ${pitch} ${minimumVolume}`
    }

    /**
     * 
     * @param {import("@minecraft/server").Vector3} location 
     * @param {string} setAs 
     * @param {string} breakMethod 
     * @returns 
     */
    static generateSetBlockCommand(location, setAs, breakMethod) {
        const {x, y, z} = location
        return `setblock ${x} ${y} ${z} ${setAs} ${breakMethod}`
    }


    /**
     * 
     * @param {import("@minecraft/server").Vector3} location 
     * @param {string} lootFile 
     * @returns 
     */
    static generateSpawnLootCommand(location, lootFile) {
        const {x, y, z} = location
        return `loot spawn ${x} ${y} ${z} loot "${lootFile}"`
    }
}