ext.mappingGeneratorVersion = "0.1.2"

// FIXME seems to be broken with newer script
//apply from: 'https://raw.githubusercontent.com/LegacyModdingMC/MappingGenerator/master/extras/auto-patch-examplemod.gradle'

if(Boolean.valueOf(project.properties["rfg.profiling"] ?: "false")) {
    minecraft.extraRunJvmArguments = minecraft.extraRunJvmArguments.get().findAll { !it.startsWith("-Dmixin.debug") }
    minecraft.extraRunJvmArguments.add("-XX:+UnlockDiagnosticVMOptions")
    minecraft.extraRunJvmArguments.add("-XX:+DebugNonSafepoints")
}

if(Boolean.valueOf(project.properties["extraMappings.dev"] ?: "false")) {
    mappingGenerator.sources = mappingGenerator.sources.get().each { entry ->
        if(entry[1] == "https://raw.githubusercontent.com/LegacyModdingMC/ExtraMappings/master/params.csv") {
            entry[1] = entry[1].replaceAll("master", "dev")
        }
    }
}

if(Boolean.valueOf(project.properties["unimixins.hotSwap"] ?: "false")) {
    afterEvaluate {
        File uni = configurations.compileClasspath.findAll { it.name.contains("unimixins-all-") || it.name.contains("unimixins-mixin-") || it.name.contains("unimixins-0.") }.first()
        runClient {
            extraJvmArgs.add(
                    '-javaagent:' + uni.getPath()
            )
        }
    }
}
