plugins {
    id 'eclipse'
    id 'idea'
    id 'maven-publish'
     // This should be below the net.minecraftforge.gradle plugin
//    id 'org.parchmentmc.librarian.forgegradle' version '1.+'

    // Apply the plugin. You can find the latest version at https://projects.neoforged.net/neoforged/ModDevGradle
    id 'net.neoforged.moddev.legacyforge' version '2.0.78'
}

version = '1.0.10-1.20.1'
group = 'cn.mcmod.sakura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'Sakura'

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"


legacyForge {
    // Develop against MinecraftForge version 47.3.0 for 1.20.1 (the versions can be found at https://files.minecraftforge.net/)
    version = "1.20.1-47.3.0"

    // Validate AT files and raise errors when they have invalid targets
    // This option is false by default, but turning it on is recommended
    validateAccessTransformers = false

    parchment {
        // Get versions from https://parchmentmc.org/docs/getting-started
        // Omit the "v"-prefix in mappingsVersion
        minecraftVersion = "1.20.1"
        mappingsVersion = "2023.09.03"
    }

    runs {
        client {
            client()
        }
        data {
            data()
            programArguments.addAll '--mod', "sakura", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
        }
        server {
            server()
        }

        configureEach {
            systemProperty 'forge.logging.markers', 'REGISTRIES'

            logLevel = org.slf4j.event.Level.DEBUG
        }
    }

    mods {
        "sakura" {
            sourceSet sourceSets.main
        }
    }
}
tasks.withType(ProcessResources).configureEach {
    var replaceProperties = [
            mod_version            : version
    ]
    inputs.properties replaceProperties

    filesMatching(['META-INF/mods.toml']) {
        expand replaceProperties
    }
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
    // Put repositories for dependencies here
    // ForgeGradle automatically adds the Forge maven and Maven Central for you

    maven { url = "https://raw.github.com/0999312/MMMaven/main/repository" }
    maven {
        url = "https://maven.theillusivec4.top/"
    }

    // Patchouli
    maven { url = 'https://maven.blamejared.com' }

    maven {
        url = "https://api.modrinth.com/maven"
    }
}

dependencies {

    modCompileOnly ("cn.mcmod_mmf.mysterious_mountain_lib:MMLib:1.5.18-1.20.1")
    modRuntimeOnly ("cn.mcmod_mmf.mysterious_mountain_lib:MMLib:1.5.18-1.20.1")
    // Compile against only the API artifact
    modCompileOnly(("top.theillusivec4.curios:curios-forge:5.4.5+1.20.1:api"))
    // Use the full Curios API jar at runtime
    modRuntimeOnly(("top.theillusivec4.curios:curios-forge:5.4.5+1.20.1"))
    modCompileOnly ("vazkii.patchouli:Patchouli:1.20.1-83-FORGE")
    modRuntimeOnly ("vazkii.patchouli:Patchouli:1.20.1-83-FORGE")

    // compile against the JEI API but do not include it at runtime
    modCompileOnly(("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
    modCompileOnly(("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
    // at runtime, use the full JEI jar for Forge
    modRuntimeOnly(("mezz.jei:jei-${mc_version}-forge:${jei_version}"))

    //implementation ("maven.modrinth:epic-fight:20.9.2")
    modCompileOnly ("maven.modrinth:farmers-delight:1.20.1-1.2.7")
    modRuntimeOnly ("maven.modrinth:farmers-delight:1.20.1-1.2.7")
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
    manifest {
        attributes([
                "Specification-Title"     : "sakura",
                "Specification-Vendor"    : "tracen_minecraft_group",
                "Specification-Version"   : "0.0.2",
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : project.jar.archiveVersion,
                "Implementation-Vendor"   : "tracen_minecraft_group",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

jar.finalizedBy('reobfJar')

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file://${maven_loc}"
        }
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}
