plugins {
    id 'com.github.johnrengelman.shadow'
}

architectury {
    platformSetupLoomIde()
    neoForge()
}

loom {
    accessWidenerPath = project(":common").loom.accessWidenerPath

    neoForge {
        runs {
            all {}

            data {
                data()
                programArgs("--all", "--mod", "${project.mod_id}")
                programArgs("--existing", project(":common").file("src/main/resources").absolutePath)
                programArgs("--output", project(":common").file("src/main/generated/resources").absolutePath)
                all {}
            }
        }
    }
}

configurations {
    common {
        canBeResolved = true
        canBeConsumed = false
    }
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
    developmentNeoForge.extendsFrom common

    // Files in this configuration will be bundled into your mod using the Shadow plugin.
    // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
    shadowBundle {
        canBeResolved = true
        canBeConsumed = false
    }
}

dependencies {
    // Mappings
    mappings loom.layered {
        it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings_version:v2")
        it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
//        officialMojangMappings()
//        parchment("org.parchmentmc.data:parchment-${project.parchment_mappings_version}@zip")
    }

    // Neoforge
    neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"

    // Architectury
    modImplementation("dev.architectury:architectury-neoforge:${rootProject.architectury_version}") {
        transitive = false
    }

    // Cloth Config
    modRuntimeOnly("me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}")

    // Debug Utils
    modImplementation("io.github.flemmli97:debugutils:${project.debugutils_version}-neoforge") {
        transitive = false
    }

    // NBT Autocomplete
    modRuntimeOnly("maven.modrinth:nbt-autocomplete:${project.nbt_autocomplete_version}-neoforge,1.21.1")

    // Smart Brain Lib
    modImplementation("net.tslat.smartbrainlib:SmartBrainLib-neoforge-${project.minecraft_version}:${project.sbl_version}")

    // Suggestion Tweaker
    modRuntimeOnly("maven.modrinth:suggestion-tweaker:${project.suggestion_tweaker_version}+neoforge")

    // Yet Another Config Lib
    modImplementation("dev.isxander:yet-another-config-lib:${project.yacl_version}-neoforge")

    common(project(path: ':common', configuration: 'namedElements')) { transitive false }
    shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
}

shadowJar {
    exclude "fabric.mod.json"
    exclude "architectury.common.json"

    configurations = [project.configurations.shadowBundle]
    archiveClassifier.set("dev-shadow")
}

remapJar {
    inputFile.set shadowJar.archiveFile
    dependsOn shadowJar
    archiveClassifier.set(null)
    atAccessWideners.add("${mod_id}.accesswidener")
}

def generatedResources = file("src/generated")

sourceSets {
    main {
        resources.srcDir generatedResources
    }
}