plugins {
    id 'multiloader-loader'
    id 'net.neoforged.moddev'
}

neoForge {
    version = neoforge_version
    // Automatically enable neoforge AccessTransformers if the file exists
    def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
    if (at.exists()) {
        accessTransformers.from(at.absolutePath)
    }
    parchment {
        minecraftVersion = parchment_minecraft
        mappingsVersion = parchment_version
    }
    runs {
        configureEach {
            systemProperty('neoforge.enabledGameTestNamespaces', mod_id)
            ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
        }
        // Add a second client run that is authenticated
        clientAuth {
            client()
            devLogin = true
        }
        client {
            client()
        }
        data {
            data()
        }
        server {
            server()
        }
    }
    mods {
        "${mod_id}" {
            sourceSet sourceSets.main
        }
    }
}

sourceSets.main.resources.srcDir 'src/generated/resources'

repositories {
    maven {
        url = "https://maven.su5ed.dev/releases"
    }
}

dependencies {
    jarJar(api(additionalRuntimeClasspath("gg.moonflower:molang-compiler:$molang_compiler_version")))
    jarJar(api(additionalRuntimeClasspath("io.github.ocelot:glsl-processor:${glsl_processor_version}")))

    jarJar(api(additionalRuntimeClasspath("io.github.spair:imgui-java-binding:$imgui_version")))
    jarJar(api(additionalRuntimeClasspath("io.github.spair:imgui-java-lwjgl3:$imgui_version"))) {
        exclude group: 'org.lwjgl'
        exclude group: 'org.lwjgl.lwjgl'
    }

    jarJar(additionalRuntimeClasspath("io.github.spair:imgui-java-natives-linux:$imgui_version"))
    jarJar(additionalRuntimeClasspath("io.github.spair:imgui-java-natives-macos:$imgui_version"))
    jarJar(additionalRuntimeClasspath("io.github.spair:imgui-java-natives-windows:$imgui_version"))

    compileOnly "maven.modrinth:sodium:mc1.21.1-${sodium_version}-neoforge"
    compileOnly "maven.modrinth:iris:1.8.8+1.21.1-neoforge"
//    localRuntime "maven.modrinth:sodium:mc1.21.1-${sodium_version}-neoforge"
//    localRuntime "maven.modrinth:iris:1.8.8+1.21.1-neoforge"

    // Allows sodium compat to compile properly
    compileOnly "org.sinytra.forgified-fabric-api:forgified-fabric-api:0.104.0+2.0.19+1.21.1"
}
