buildscript {
    repositories {
        // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
        maven { url = 'https://maven.minecraftforge.net' }
        mavenCentral()
        jcenter()
        maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
        classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT"
    }
}
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
plugins {
    id 'eclipse'
    id 'maven-publish'
    id 'com.matthewprenger.cursegradle' version '1.4.0'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
//mixin {
//  add sourceSets.main, "tfmg.refmap.json"
//}

version = '0.6.0-1.19.2'
group = 'com.drmangotea.tfmg' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'tfmg'

// 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'}"
minecraft {
    mappings channel: 'official', version: '1.19.2'

    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

    runs {
        client {
            workingDirectory project.file('run')
            arg '-mixin.config=tfmg.mixins.json'
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'
            property 'forge.enabledGameTestNamespaces', 'tfmg'
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
            mods {
                tfmg {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')
            arg '-mixin.config=tfmg.mixins.json'
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'
            property 'forge.enabledGameTestNamespaces', 'tfmg'
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
            mods {
                tfmg {
                    source sourceSets.main
                }
            }
        }

        gameTestServer {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'
            property 'forge.enabledGameTestNamespaces', 'tfmg'
            property 'mixin.env.remapRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
            mods {
                tfmg {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'
            args '--mod', 'tfmg', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
            mods {
                tfmg {
                    source sourceSets.main
                }
            }
        }
    }
}


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

repositories {


    maven {
        // location of the maven that hosts JEI files since January 2023
        // location of the maven for Vazkii's mods
        name = "Jared's maven"
        url = "https://maven.blamejared.com/"
    }

    maven {
        url "https://maven.tterrag.com/"
    }


}

dependencies {


    minecraft 'net.minecraftforge:forge:1.19.2-43.2.3'

    compileOnly fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}")
   implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")

   implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:all") { transitive = false }

    compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}")
   compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge-api:${jei_version}")
   runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge:${jei_version}")




    annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
    testAnnotationProcessor "org.spongepowered:mixin:0.8.5:processor"
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
    manifest {
        attributes([
                "Specification-Title"     : "tfmg",
                "Specification-Vendor"    : "tfmgsareus",
                "Specification-Version"   : "1", // We are version 1 of ourselves
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : project.jar.archiveVersion,
                "Implementation-Vendor"   : "tfmgsareus",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "MixinConfigs": "tfmg.mixins.json"
        ])
    }
}


jar.finalizedBy('reobfJar')


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

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