Switch to neoforge and neogradle

This commit is contained in:
DBotThePony 2024-07-04 17:47:24 +07:00
parent 91835905a3
commit 9b7e424fc5
Signed by: DBot
GPG Key ID: DCC23B5715498507
4 changed files with 69 additions and 75 deletions

View File

@ -4,6 +4,7 @@ import java.util.Date
import java.text.SimpleDateFormat
import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
val mod_version: String by project
val mc_version: String by project
@ -16,9 +17,10 @@ val handleDeps = handle_deps.toBoolean()
plugins {
java
kotlin
idea
`maven-publish`
id("net.minecraftforge.gradle")
id("org.spongepowered.mixin")
id("net.neoforged.gradle.userdev")
id("net.neoforged.gradle.mixin")
}
data class GitInfo(val version: String, val tag: String, val buildNumber: String) {
@ -94,9 +96,9 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
println("Targeting Java ${java.toolchain.languageVersion.get()}")
tasks.withType(KotlinCompile::class.java) {
kotlinOptions {
compilerOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
jvmTarget = java.toolchain.languageVersion.get().toString()
jvmTarget.set(JvmTarget.JVM_21)
}
}
@ -132,7 +134,7 @@ dependencies {
val mixin_version: String by project
val kommons_version: String by project
minecraft("net.minecraftforge:forge:$mc_version-$forge_version")
implementation("net.neoforged:neoforge:$forge_version")
testImplementation("org.junit.jupiter:junit-jupiter:${jupiter_version}")
implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version")
@ -157,33 +159,33 @@ dependencies {
val ad_astra_id: String by project
val worldedit_id: String by project
compileOnly(("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}"))
compileOnly(("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id"))
compileOnly("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}")
compileOnly("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")
compileOnly(("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}"))
compileOnly(("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}"))
runtimeOnly(("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}"))
compileOnly("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")
compileOnly("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")
runtimeOnly("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")
// runtimeOnly(("ru.dbotthepony:particle-collider:0.4.5"))
// runtimeOnly("ru.dbotthepony:particle-collider:0.4.5")
implementation(("curse.maven:jade-324717:${jade_id}"))
//runtimeOnly(("curse.maven:configured-457570:${configured_id}"))
implementation("curse.maven:jade-324717:${jade_id}")
//runtimeOnly("curse.maven:configured-457570:${configured_id}")
compileOnly(("curse.maven:resourceful-lib-570073:${resourceful_lib_id}"))
compileOnly(("curse.maven:resourceful-config-714059:${resourceful_config_id}"))
compileOnly(("curse.maven:botarium-704113:${botarium_id}"))
compileOnly(("curse.maven:ad-astra-635042:${ad_astra_id}"))
runtimeOnly(("curse.maven:worldedit-225608:${worldedit_id}"))
compileOnly("curse.maven:resourceful-lib-570073:${resourceful_lib_id}")
compileOnly("curse.maven:resourceful-config-714059:${resourceful_config_id}")
compileOnly("curse.maven:botarium-704113:${botarium_id}")
compileOnly("curse.maven:ad-astra-635042:${ad_astra_id}")
runtimeOnly("curse.maven:worldedit-225608:${worldedit_id}")
// runtimeOnly(("curse.maven:worldedit-225608:${worldedit_fileid}"))
// runtimeOnly(("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}"))
// runtimeOnly("curse.maven:worldedit-225608:${worldedit_fileid}")
// runtimeOnly("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")
// runtimeOnly(("curse.maven:cyclops-core-232758:4392602"))
// runtimeOnly(("curse.maven:integrated-dynamics-236307:4391535"))
// runtimeOnly(("curse.maven:integrated-crafting-287357:4391487"))
// runtimeOnly(("curse.maven:integrated-terminals-295910:4400924"))
// runtimeOnly(("curse.maven:common-capabilities-247007:4391468"))
// runtimeOnly(("curse.maven:integrated-tunnels-251389:4344632"))
// runtimeOnly("curse.maven:cyclops-core-232758:4392602")
// runtimeOnly("curse.maven:integrated-dynamics-236307:4391535")
// runtimeOnly("curse.maven:integrated-crafting-287357:4391487")
// runtimeOnly("curse.maven:integrated-terminals-295910:4400924")
// runtimeOnly("curse.maven:common-capabilities-247007:4391468")
// runtimeOnly("curse.maven:integrated-tunnels-251389:4344632")
}
}
@ -192,32 +194,20 @@ configurations {
}
minecraft {
mappings("official", mc_version)
copyIdeResources.set(true)
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
//accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
configureEach {
workingDirectory = project.file("run").absolutePath
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property("forge.logging.markers", "REGISTRIES")
systemProperty("forge.logging.markers", "REGISTRIES")
// Log4j console level
property("forge.logging.console.level", "debug")
systemProperty("forge.logging.console.level", "debug")
}
create("client") {
mods {
create(mod_id) {
source(sourceSets["main"])
}
}
getByName("client") {
val usernameStream = FastByteArrayOutputStream()
val gotUsername = exec {
@ -230,39 +220,28 @@ minecraft {
val originalUsername = usernameStream.array.copyOfRange(0, usernameStream.length).toString(Charsets.UTF_8).trim()
if (originalUsername.isNotEmpty()) {
args("--username", originalUsername)
programArguments.addAll("--username", originalUsername)
} else {
args("--username", "Dev_${System.getProperty("user.name")}")
programArguments.addAll("--username", "Dev_${System.getProperty("user.name")}")
}
} else {
args("--username", "Dev_${System.getProperty("user.name")}")
programArguments.addAll("--username", "Dev_${System.getProperty("user.name")}")
}
}
create("server") {
mods {
create(mod_id) {
source(sourceSets["main"])
}
}
args("nogui")
getByName("server") {
programArguments.addAll("nogui")
}
create("data") {
args("--mod", mod_id, "--all", "--output", file("src/data/resources/"), "--existing", file("src/main/resources/"))
getByName("data") {
programArguments.addAll("--mod", mod_id, "--all", "--output", file("src/data/resources/").absolutePath, "--existing", file("src/main/resources/").absolutePath)
mods {
create(mod_id) {
sources(sourceSets["main"], sourceSets["data"])
}
}
modSources(sourceSets["main"], sourceSets["data"])
}
}
}
mixin {
add(sourceSets.main.get(), "$mod_id.refmap.json")
config("$mod_id.mixins.json")
config("$mod_id.ad_astra.mixins.json")
}
@ -287,6 +266,15 @@ repositories {
}
}
maven(url = "https://maven.neoforged.net/releases") {
name = "Neoforge"
content {
includeGroup("net.neoforged.gradle")
includeGroup("net.neoforged")
}
}
maven {
name = "Kotlin for Forge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
@ -332,10 +320,7 @@ fun org.gradle.jvm.tasks.Jar.attachManifest() {
}
}
// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
tasks.jar.configure {
finalizedBy("reobfJar")
attachManifest()
archiveClassifier.set("slim")
archiveVersion.set(gitVersion.jarName)
@ -412,3 +397,10 @@ if (project.hasProperty("mavenUser") && project.hasProperty("mavenPassword") &&
}
}
}
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}

View File

@ -14,8 +14,8 @@ mc_version=1.21
jei_mc_version=1.21
curios_mc_version=1.20.2
forge_gradle_version=[6.0.14,6.2)
forge_version=51.0.18
forge_gradle_version=[7.0.145,)
forge_version=21.0.54-beta
mixingradle_version=0.7.33
mixin_version=0.8.5

View File

@ -4,6 +4,7 @@ println("Running with Java ${System.getProperty("java.version")} on JVM: ${Syste
pluginManagement {
repositories {
gradlePluginPortal()
maven(url = "https://maven.neoforged.net/releases")
}
}
@ -14,12 +15,12 @@ plugins {
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") {
name = "Minecraft Forge"
maven(url = "https://maven.neoforged.net/releases") {
name = "Neoforge"
content {
includeGroup("net.minecraftforge.gradle")
includeGroup("net.minecraftforge")
includeGroup("net.neoforged.gradle")
includeGroup("net.neoforged")
}
}
@ -39,7 +40,8 @@ buildscript {
val forge_gradle_version: String by settings
val mixingradle_version: String by settings
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version)
classpath(group = "net.neoforged.gradle", name = "userdev", version = forge_gradle_version)
classpath(group = "net.neoforged.gradle", name = "mixin", version = forge_gradle_version)
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
classpath("org.spongepowered:mixingradle:${mixingradle_version}")

View File

@ -6,7 +6,7 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[47,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[21,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="2 Clause BSD"
@ -41,7 +41,7 @@ Matter. Energy. Combined.
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[48.0.0,)" #mandatory
versionRange="[51.0.0,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
@ -50,7 +50,7 @@ Matter. Energy. Combined.
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.20.2,1.21)"
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.21,1.21.1)"
ordering="NONE"
side="BOTH"