diff --git a/build.gradle b/build.gradle index 2076cdf..2dc6a04 100644 --- a/build.gradle +++ b/build.gradle @@ -1,40 +1,28 @@ plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false + id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false + id 'architectury-plugin' version '3.4-SNAPSHOT' + id 'com.github.johnrengelman.shadow' version '8.1.1' apply false } architectury { - minecraft = rootProject.minecraft_version -} - -subprojects { - apply plugin: "dev.architectury.loom" - - loom { - silentMojangMappingsLicense() - } - - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - // The following line declares the mojmap mappings, you may use other mappings as well - mappings loom.officialMojangMappings() - // The following line declares the yarn mappings you may select this one as well. - // mappings "net.fabricmc:yarn:1.20.1+build.10:v2" - } + minecraft = project.minecraft_version } allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" + group = rootProject.maven_group + version = rootProject.mod_version +} + +subprojects { + apply plugin: 'dev.architectury.loom' + apply plugin: 'architectury-plugin' + apply plugin: 'maven-publish' base { - archivesName = rootProject.archives_base_name + // Set up a suffixed format for the mod jar names, e.g. `example-fabric`. + archivesName = "$rootProject.archives_name-$project.name" } - version = rootProject.mod_version - group = rootProject.maven_group - repositories { // Add repositories to retrieve artifacts from in here. // You should only use this when depending on other mods because @@ -43,12 +31,40 @@ allprojects { // for more information about repositories. } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release = 17 + dependencies { + minecraft "net.minecraft:minecraft:$rootProject.minecraft_version" + mappings loom.officialMojangMappings() } java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } -} + + tasks.withType(JavaCompile).configureEach { + it.options.release = 17 + } + + // Configure Maven publishing. + publishing { + publications { + mavenJava(MavenPublication) { + artifactId = base.archivesName.get() + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } + } +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index 7cd3d39..5f4c73f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -2,10 +2,6 @@ architectury { common(rootProject.enabled_platforms.split(",")) } -loom { - accessWidenerPath = file("src/main/resources/optionsprofiles.accesswidener") -} - repositories { exclusiveContent { forRepository { @@ -21,27 +17,12 @@ repositories { } dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - // Remove the next line if you don't want to depend on the API - // modApi "dev.architectury:architectury:${rootProject.architectury_version}" + // We depend on Fabric Loader here to use the Fabric @Environment annotations, + // which get remapped to the correct annotations on each platform. + // Do NOT use other classes from Fabric Loader. + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" - // To add support for these mods + // Mod implementations modImplementation "maven.modrinth:sodium:mc1.20.4-0.5.8" modImplementation "maven.modrinth:sodium-extra:mc1.20.4-0.5.4" -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} +} \ No newline at end of file diff --git a/common/src/main/resources/optionsprofiles.mixins.json b/common/src/main/resources/optionsprofiles.mixins.json new file mode 100644 index 0000000..dc1f6b2 --- /dev/null +++ b/common/src/main/resources/optionsprofiles.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.axolotlmaid.optionsprofiles.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "client": [ + "MixinOptionsScreen" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 77a03d1..33b06d8 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id 'com.github.johnrengelman.shadow' } architectury { @@ -7,71 +7,46 @@ architectury { fabric() } -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" - // Remove the next line if you don't want to depend on the API - // modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" + + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionFabric') } processResources { - inputs.property "version", project.version + inputs.property 'version', project.version - filesMatching("fabric.mod.json") { - expand "version": project.version + filesMatching('fabric.mod.json') { + expand version: project.version } } shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier = "dev-shadow" + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' } remapJar { - injectAccessWidener = true input.set shadowJar.archiveFile - dependsOn shadowJar -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} +} \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index dff0d90..ed3cf10 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -21,11 +21,12 @@ ] }, "mixins": [ - "optionsprofiles.mixins.json", - "optionsprofiles-common.mixins.json" + "optionsprofiles.mixins.json" ], "depends": { - "fabric": "*", - "minecraft": ">=1.20.4" + "fabricloader": ">=0.15.11", + "minecraft": "~1.20.4", + "java": ">=17", + "fabric-api": "*" } } \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index 3993a4d..1f5738b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,5 +1,11 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id 'com.github.johnrengelman.shadow' +} + +loom { + forge { + mixinConfig "optionsprofiles.mixins.json" + } } architectury { @@ -7,84 +13,43 @@ architectury { forge() } -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath - - forge { - convertAccessWideners = true - extraAccessWideners.add loom.accessWidenerPath.get().asFile.name - - mixinConfig "optionsprofiles-common.mixins.json" - mixinConfig "optionsprofiles.mixins.json" - } - - mods { - register("forge") { - sourceSet("main", project(":forge")) - } - } -} - configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentForge.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } dependencies { - forge "net.minecraftforge:forge:${rootProject.forge_version}" - // Remove the next line if you don't want to depend on the API - // modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" + forge "net.minecraftforge:forge:$rootProject.forge_version" - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionForge') } processResources { - inputs.property "version", project.version + inputs.property 'version', project.version - filesMatching("META-INF/mods.toml") { - expand "version": project.version + filesMatching('META-INF/mods.toml') { + expand version: project.version } } shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier = "dev-shadow" + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' } remapJar { input.set shadowJar.archiveFile - dependsOn shadowJar -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} +} \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta index 4efb538..874b010 100644 --- a/forge/src/main/resources/pack.mcmeta +++ b/forge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Options Profiles", - "pack_format": 15 + "pack_format": 22 } } diff --git a/gradle.properties b/gradle.properties index bfb508f..dfad00f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,16 @@ org.gradle.jvmargs=-Xmx6G +org.gradle.parallel=true -minecraft_version=1.20.4 -enabled_platforms=fabric,forge - -archives_base_name=optionsprofiles mod_version=1.2.1 maven_group=com.axolotlmaid.optionsprofiles +archives_name=optionsprofiles +enabled_platforms=fabric,forge,neoforge -architectury_version=11.0.10 +minecraft_version=1.20.4 -fabric_loader_version=0.15.3 -fabric_api_version=0.92.1+1.20.4 +fabric_loader_version = 0.15.11 +fabric_api_version = 0.97.1+1.20.4 -forge_version=1.20.4-49.0.14 \ No newline at end of file +forge_version = 1.20.4-49.0.50 + +neoforge_version = 20.4.234 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 744c64d..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..3aff94d --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,56 @@ +plugins { + id 'com.github.johnrengelman.shadow' +} + +architectury { + platformSetupLoomIde() + neoForge() +} + +configurations { + common { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } +} + +repositories { + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } +} + +dependencies { + neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" + + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') +} + +processResources { + inputs.property 'version', project.version + + filesMatching('META-INF/mods.toml') { + expand version: project.version + } +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + input.set shadowJar.archiveFile +} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties new file mode 100644 index 0000000..2e6ed76 --- /dev/null +++ b/neoforge/gradle.properties @@ -0,0 +1 @@ +loom.platform = neoforge diff --git a/neoforge/src/main/java/com/axolotlmaid/optionsprofiles/neoforge/OptionsProfilesModNeoForge.java b/neoforge/src/main/java/com/axolotlmaid/optionsprofiles/neoforge/OptionsProfilesModNeoForge.java new file mode 100644 index 0000000..e4250ee --- /dev/null +++ b/neoforge/src/main/java/com/axolotlmaid/optionsprofiles/neoforge/OptionsProfilesModNeoForge.java @@ -0,0 +1,12 @@ +package com.axolotlmaid.optionsprofiles.neoforge; + +import net.neoforged.fml.common.Mod; + +import com.axolotlmaid.optionsprofiles.OptionsProfilesMod; + +@Mod(OptionsProfilesMod.MOD_ID) +public final class OptionsProfilesModNeoForge { + public OptionsProfilesModNeoForge() { + OptionsProfilesMod.init(); + } +} diff --git a/settings.gradle b/settings.gradle index 6ede68f..6f471e6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,7 +2,7 @@ pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } - maven { url "https://maven.minecraftforge.net/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } } @@ -10,5 +10,6 @@ pluginManagement { include("common") include("fabric") include("forge") +include("neoforge") rootProject.name = "optionsprofiles-v1.2.1-1.20.4"