Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21

- name: Cache gradle files
uses: actions/cache@v4
Expand Down
41 changes: 15 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ import com.diffplug.gradle.spotless.BaseKotlinExtension

plugins {
id("maven-publish")
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
// TODO: the preprocessor doesn't yet work with Kotlin 1.9
// https://github.com/ReplayMod/remap/pull/17
kotlin("jvm") version "1.8.22" apply false
id("dev.architectury.loom") version "1.13-SNAPSHOT" apply false
// Kotlin 2.1+ is still incompatible with the preprocessor/remap
kotlin("jvm") version "2.0.21" apply false

// https://github.com/ReplayMod/preprocessor
// https://github.com/Fallen-Breath/preprocessor
id("com.replaymod.preprocess") version "ce1aeb2b"
id("com.replaymod.preprocess") version "d452ef76"

// https://github.com/Fallen-Breath/yamlang
id("me.fallenbreath.yamlang") version "1.3.1" apply false
id("me.fallenbreath.yamlang") version "1.5.0" apply false

id("com.diffplug.spotless") version "6.25.0"
id("com.diffplug.spotless") version "8.0.0"
}

tasks.named("assemble").get().dependsOn("spotlessApply")
Expand All @@ -28,27 +27,17 @@ repositories {

@Suppress("LocalVariableName", "ktlint:standard:property-naming")
preprocess {
val mc12001_common = createNode("1.20.1-common", 1_20_01, "yarn")
val mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "yarn")
val mc12001_forge = createNode("1.20.1-forge", 1_20_01, "yarn")
// it doesn't seem to be possible to explicitly set the descriptor of a field,
// which we would need for strict mappings to work
strictExtraMappings = false

val mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "yarn")
val mc12002_neoforge = createNode("1.20.2-neoforge", 1_20_02, "yarn")
val mc12006_common = createNode("1.20.6-common", 1_20_06, "yarn")
val mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "yarn")
val mc12006_neoforge = createNode("1.20.6-neoforge", 1_20_06, "yarn")

val mc12004_common = createNode("1.20.4-common", 1_20_04, "yarn")
val mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "yarn")
val mc12004_neoforge = createNode("1.20.4-neoforge", 1_20_04, "yarn")

// 1.20.1
mc12002_fabric.link(mc12001_fabric, null)
mc12004_common.link(mc12001_common, null)
mc12001_common.link(mc12001_forge, file("versions/mappings-common-forge.txt"))
// 1.20.2
mc12004_fabric.link(mc12002_fabric, null)
mc12004_neoforge.link(mc12002_neoforge, null)
// 1.20.4
mc12004_common.link(mc12004_fabric, null)
mc12004_common.link(mc12004_neoforge, file("versions/mappings-common-neoforge.txt"))
// 1.20.6
mc12006_common.link(mc12006_fabric, null)
mc12006_common.link(mc12006_neoforge, file("versions/mappings-common-neoforge.txt"))
}

spotless {
Expand Down
91 changes: 25 additions & 66 deletions common.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.jvmErasure
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("maven-publish")
Expand All @@ -12,25 +11,21 @@ plugins {
}

val loaderName = if (project.name.endsWith("-common")) "common" else loom.platform.get().name.lowercase()
assert(loaderName in listOf("common", "fabric", "forge", "neoforge"))
assert(loaderName in listOf("common", "fabric", "neoforge"))
assert(project.name.endsWith("-$loaderName"))
enum class Loader {
COMMON,
FABRIC,
FORGE,
NEOFORGE,
;

val isCommon get() = this == COMMON
val isFabric get() = this == FABRIC
val isForge get() = this == FORGE
val isNeoForge get() = this == NEOFORGE
val isForgeLike get() = this == FORGE || this == NEOFORGE
}
val loader = when (loaderName) {
"common" -> Loader.COMMON
"fabric" -> Loader.FABRIC
"forge" -> Loader.FORGE
"neoforge" -> Loader.NEOFORGE
else -> throw AssertionError("invalid loader '$loaderName'")
}
Expand All @@ -42,9 +37,7 @@ val mcVersion: Int by project.extra
preprocess {
vars.put("MC", mcVersion)
vars.put("FABRIC", loader.isFabric.toInt())
vars.put("FORGE", loader.isForge.toInt())
vars.put("NEOFORGE", loader.isNeoForge.toInt())
vars.put("FORGELIKE", loader.isForgeLike.toInt())
}

@Suppress("PropertyName")
Expand Down Expand Up @@ -77,20 +70,18 @@ class Props {
val issues_url: String by prop

val fabric_kotlin_version: String by prop
val forge_kotlin_version: String by prop
val mixinextras_version: String by prop
val neoforge_kotlin_version: String by prop
val conditional_mixin_version: String by prop

val run_with_compat_mods: Boolean by prop

//// Version Specific Properties ////
val minecraft_version: String by prop
val yarn_mappings: String by prop
val yarn_mappings_patch: String by prop

val minecraft_version_range_fabric: String by prop
val minecraft_version_range_forge: String by prop
val forge_version: String by prop
val forge_version_range: String by prop
val neoforge_version: String by prop
val neoforge_version_range: String by prop

Expand All @@ -101,7 +92,6 @@ class Props {
val fabric_api_version: String by prop
val modmenu_version: String by prop
val trinkets_version: String by prop
val cca_version: String by prop

val curios_version: String by prop
}
Expand All @@ -115,18 +105,6 @@ loom {
vmArg("-Dmixin.debug.export=true")
}

if (loader.isForge) {
forge.mixinConfigs = listOf(
"${props.mod_id}.mixins.json",
"${props.mod_id}-forge.mixins.json",
)
// workaround for https://github.com/SpongePowered/Mixin/issues/560
// TODO: remove this when Mixin 0.8.6 is out or you find another proper fix
forge.useCustomMixin = false
@Suppress("UnstableApiUsage")
mixin.useLegacyMixinAp = false
}

rootDir.resolve("src/main/resources/${props.mod_id}.accesswidener").let {
if (it.exists()) {
accessWidenerPath = it
Expand All @@ -147,10 +125,6 @@ repositories {
// NeoForge
maven("https://maven.neoforged.net/releases")
}
Loader.FORGE -> {
// MixinExtras
mavenCentral()
}
}
if (!loader.isFabric) {
// Kotlin for Forge
Expand All @@ -172,10 +146,17 @@ repositories {

dependencies {
minecraft("com.mojang:minecraft:${props.minecraft_version}")
mappings("net.fabricmc:yarn:${props.yarn_mappings}:v2")
mappings(
loom.layered {
mappings("net.fabricmc:yarn:${props.yarn_mappings}:v2")
if (loader == Loader.NEOFORGE) {
mappings("dev.architectury:yarn-mappings-patch-neoforge:${props.yarn_mappings_patch}")
}
},
)

// outside the fabric specific projects this should only be used for the @Environment annotation
modImplementation("net.fabricmc:fabric-loader:${props.fabric_loader_version}")
modCompileOnly("net.fabricmc:fabric-loader:${props.fabric_loader_version}")

fun modCompat(dependencyNotation: String, dependencyConfiguration: ExternalModuleDependency.() -> Unit = {}) =
if (props.run_with_compat_mods) {
Expand All @@ -194,6 +175,7 @@ dependencies {
Loader.FABRIC -> {
modLocalRuntime("maven.modrinth:early-loading-screen:${props.early_loading_screen_version}")

modImplementation("net.fabricmc:fabric-loader:${props.fabric_loader_version}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${props.fabric_api_version}")

include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${props.conditional_mixin_version}")!!)
Expand All @@ -207,33 +189,16 @@ dependencies {
// other mods we do integration with
// - Trinkets
modCompat("dev.emi:trinkets:${props.trinkets_version}")
// before 3.8.1 these weren't included as modApi but as modImplementation in Trinkets, so we must add them ourselves
if (mcVersion < 12004) {
modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${props.cca_version}")
modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${props.cca_version}")
}
}
Loader.FORGE -> {
"forge"("net.minecraftforge:forge:${props.forge_version}")

include(modImplementation("me.fallenbreath:conditional-mixin-forge:${props.conditional_mixin_version}")!!)

implementation("thedarkcolour:kotlinforforge:${props.forge_kotlin_version}")
modImplementation("me.shedaniel.cloth:cloth-config-forge:${props.cloth_version}")

compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1")!!)
implementation(include("io.github.llamalad7:mixinextras-forge:0.4.1")!!)

// other mods we do integration with
// - Curios API
modCompat("top.theillusivec4.curios:curios-forge:${props.curios_version}")
}
Loader.NEOFORGE -> {
"neoForge"("net.neoforged:neoforge:${props.neoforge_version}")

include(modImplementation("me.fallenbreath:conditional-mixin-neoforge:${props.conditional_mixin_version}")!!)

implementation("thedarkcolour:kotlinforforge-neoforge:${props.forge_kotlin_version}")
implementation("thedarkcolour:kotlinforforge-neoforge:${props.neoforge_kotlin_version}") {
// TODO: remove after kff 5.8
exclude(group = "net.neoforged.fancymodloader", module = "loader")
}
modImplementation("me.shedaniel.cloth:cloth-config-neoforge:${props.cloth_version}")

// other mods we do integration with
Expand All @@ -260,21 +225,18 @@ tasks.named<ProcessResources>("processResources") {

val authors = props.mod_authors.joinToString(if (loader.isFabric) "\",\"" else ", ")

val versionsMap = mapOf(
11904 to 13,
12001 to 15,
12002 to 18,
12004 to 22,
// See https://minecraft.wiki/w/Pack_format#List_of_resource_pack_formats
val resourcePackVersions = mapOf(
12006 to 32,
)

val replaceProperties = mapOf(
"minecraft_version_range_fabric" to props.minecraft_version_range_fabric,
"minecraft_version_range_forge" to props.minecraft_version_range_forge,
"fabric_loader_version" to props.fabric_loader_version,
"forge_version_range" to props.forge_version_range,
"neoforge_version_range" to props.neoforge_version_range,
"fabric_kotlin_version" to props.fabric_kotlin_version,
"forge_kotlin_version" to props.forge_kotlin_version,
"neoforge_kotlin_version" to props.neoforge_kotlin_version,
"description" to props.mod_description,
"homepage_url" to props.homepage_url,
"sources_url" to props.sources_url,
Expand All @@ -284,11 +246,11 @@ tasks.named<ProcessResources>("processResources") {
"version" to fullModVersion,
"license" to props.license,
"authors" to authors,
"pack_format_number" to versionsMap[mcVersion],
"pack_format_number" to resourcePackVersions[mcVersion],
)
inputs.properties(replaceProperties)

filesMatching(listOf("fabric.mod.json", "META-INF/mods.toml", "pack.mcmeta")) {
filesMatching(listOf("fabric.mod.json", "META-INF/neoforge.mods.toml", "pack.mcmeta")) {
expand(replaceProperties + mapOf("project" to project))
}

Expand All @@ -313,14 +275,11 @@ version = "v$fullModVersion"
group = props.maven_group

tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=all")
kotlin {
jvmToolchain(21)
}

java {
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

# Minecraft Properties
# https://fabricmc.net/develop/
fabric_loader_version=0.15.7
fabric_loader_version=0.17.3

# Mod Properties
mod_id=inventorio
mod_name=Inventorio
mod_authors=RubixDev,LizardOfOz,Favorlock
mod_version=1.10.4
mod_authors=RubixDev,LizardOfOz
mod_version=1.11.0
mod_description=My vision of the Inventory Update. Includes Deep Pockets Enchantment, Tool Belt, Utility Belt and more.
maven_group=de.rubixdev.inventorio
archives_base_name=inventorio
Expand All @@ -21,11 +21,10 @@

# Global Dependencies
# https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/
fabric_kotlin_version=1.9.6+kotlin.1.8.22
fabric_kotlin_version=1.12.3+kotlin.2.0.21
# https://github.com/thedarkcolour/KotlinForForge/blob/site/thedarkcolour/kotlinforforge/maven-metadata.xml
forge_kotlin_version=4.10.0
# https://mvnrepository.com/artifact/io.github.llamalad7/mixinextras-common
mixinextras_version=0.3.5
# https://docs.google.com/spreadsheets/d/1v8K90PBa5qPFrlHBA8PSqlBTYCcp078o5E2XQbt5BUs/edit?usp=sharing
neoforge_kotlin_version=5.6.0
# https://github.com/Fallen-Breath/conditional-mixin/tags
conditional_mixin_version=0.6.4

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jdk:
- openjdk17
- openjdk21
before_install:
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source install-jdk.sh --feature 17
- source install-jdk.sh --feature 21
- jshell --version
11 changes: 3 additions & 8 deletions settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"versions": [
"1.20.1-common",
"1.20.1-fabric",
"1.20.1-forge",
"1.20.2-fabric",
"1.20.2-neoforge",
"1.20.4-common",
"1.20.4-fabric",
"1.20.4-neoforge"
"1.20.6-common",
"1.20.6-fabric",
"1.20.6-neoforge"
]
}
Loading