plugins {
    id 'eclipse'
    id 'net.minecraftforge.gradle' version '[6.0,6.2)'
    id 'org.spongepowered.mixin' version '0.7.+'
    id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

def getGitCommitHash() {
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

version = '0.1.6-SNAPSHOT-' + getGitCommitHash()
group = 'com.Atsushio.superbwarfare'
archivesBaseName = 'superbwarfare'

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

minecraft {
    mappings channel: 'parchment', version: '2023.08.13-1.20.1'

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

    copyIdeResources = true
    runs {
        client {
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
        }

        server {
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
        }
        data {
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
        }
    }
}

repositories {
    maven {
        url = "https://maven.theillusivec4.top/"
    }
    maven {
        url = 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
    }
    maven {
        name = "Jared's maven"
        url = "https://maven.blamejared.com/"
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.20.1-47.2.0'
    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

    runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:5.4.2+1.20.1")
    compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:5.4.2+1.20.1:api")

    implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.20.1:4.4.6')

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

mixin {
    add sourceSets.main, 'mixins.superbwarfare.refmap.json'

    config 'mixins.superbwarfare.json'

    debug.verbose = true
    debug.export = true
    dumpTargetOnFailure = true

    quiet
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
