buildscript {
    repositories {
        maven { url = 'https://maven.minecraftforge.net' }
        maven { url = 'https://repo.spongepowered.org/maven' }
        maven { url = "https://api.modrinth.com/maven" }
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
        classpath 'org.spongepowered:mixingradle:0.7.+'
    }
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

compileJava.options.encoding("UTF-8")
compileTestJava.options.encoding("UTF-8")

mixin {
    add sourceSets.main, 'parcool.refmap.json'
    config 'parcool.mixins.json'
}

//Version Format (MajorMOD.MajorAPI.Minor.Patch)
var version_code = "${major_mod}.${major_api}.${minor}.${patch}"
version = "${mc_version}-${version_code}"
group = 'com.alrex'
archivesBaseName = 'ParCool'

java.toolchain.languageVersion = JavaLanguageVersion.of(8)

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
    mappings channel: 'official', version: mc_version

    accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    runs {
        client {
            workingDirectory project.file('run')
            property 'forge.logging.console.level', 'debug'
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            mods {
                parcool {
                    source sourceSets.main
                }
            }
        }
        server {
            workingDirectory project.file('run')
            property 'forge.logging.console.level', 'debug'
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            mods {
                parcool {
                    source sourceSets.main
                }
            }
        }
        data {
            workingDirectory project.file('run')
            property 'forge.logging.console.level', 'debug'
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
            args '--mod', 'parcool', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
            mods {
                parcool {
                    source sourceSets.main
                }
            }
        }
    }
}

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

repositories {
    maven { url = 'https://maven.blamejared.com' }
    maven { url = 'https://www.cursemaven.com' }
}
dependencies {
    // Specify the version of Minecraft to use.
    minecraft "net.minecraftforge:forge:${forge_version}"
    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
    runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
    //compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
    compileOnly fg.deobf("curse.maven:BetterThirdPerson-435044:4177083")
    compileOnly fg.deobf("curse.maven:ShoulderSurfing-243190:6387959")

    runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
    runtimeOnly fg.deobf("curse.maven:pehkui-319596:4461971")
    runtimeOnly fg.deobf("curse.maven:invmove-581854:4346449")
    runtimeOnly fg.deobf("curse.maven:clothconfig-348521:4633366")
    //runtimeOnly fg.deobf("curse.maven:emotecraft-403422:3955902")
    //runtimeOnly fg.deobf("curse.maven:BetterThirdPerson-435044:4177083")
    runtimeOnly fg.deobf("curse.maven:ShoulderSurfing-243190:6387959")
}

jar {
    manifest {
        attributes([
                "Specification-Title"     : "ParCool!",
                "Specification-Vendor"    : "alRex",
                "Specification-Version" : "${version_code}",
                "Implementation-Title"    : project.name,
                "Implementation-Version": "${version_code}",
                "Implementation-Vendor"   : "alRex",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "TweakClass"              : "org.spongepowered.asm.launch.MixinTweaker",
                "MixinConfigs"            : "parcool.mixins.json"
        ])
    }
}

jar.finalizedBy('reobfJar')

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file:///${project.projectDir}/mcmodsrepo"
        }
    }
}