Add NeoForge

This commit is contained in:
axolotlmaid 2024-06-03 00:46:49 +01:00
parent 586db38dff
commit d031876914
13 changed files with 205 additions and 181 deletions

View file

@ -1,40 +1,28 @@
plugins { plugins {
id "architectury-plugin" version "3.4-SNAPSHOT" id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false id 'architectury-plugin' version '3.4-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
} }
architectury { architectury {
minecraft = rootProject.minecraft_version minecraft = project.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"
}
} }
allprojects { allprojects {
apply plugin: "java" group = rootProject.maven_group
apply plugin: "architectury-plugin" version = rootProject.mod_version
apply plugin: "maven-publish" }
subprojects {
apply plugin: 'dev.architectury.loom'
apply plugin: 'architectury-plugin'
apply plugin: 'maven-publish'
base { 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 { repositories {
// Add repositories to retrieve artifacts from in here. // Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because // You should only use this when depending on other mods because
@ -43,12 +31,40 @@ allprojects {
// for more information about repositories. // for more information about repositories.
} }
tasks.withType(JavaCompile) { dependencies {
options.encoding = "UTF-8" minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
options.release = 17 mappings loom.officialMojangMappings()
} }
java { 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() 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.
}
} }
} }

View file

@ -2,10 +2,6 @@ architectury {
common(rootProject.enabled_platforms.split(",")) common(rootProject.enabled_platforms.split(","))
} }
loom {
accessWidenerPath = file("src/main/resources/optionsprofiles.accesswidener")
}
repositories { repositories {
exclusiveContent { exclusiveContent {
forRepository { forRepository {
@ -21,27 +17,12 @@ repositories {
} }
dependencies { dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // We depend on Fabric Loader here to use the Fabric @Environment annotations,
// Do NOT use other classes from fabric loader // which get remapped to the correct annotations on each platform.
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" // Do NOT use other classes from Fabric Loader.
// Remove the next line if you don't want to depend on the API modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
// modApi "dev.architectury:architectury:${rootProject.architectury_version}"
// To add support for these mods // Mod implementations
modImplementation "maven.modrinth:sodium:mc1.20.4-0.5.8" modImplementation "maven.modrinth:sodium:mc1.20.4-0.5.8"
modImplementation "maven.modrinth:sodium-extra:mc1.20.4-0.5.4" 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.
}
}

View file

@ -0,0 +1,14 @@
{
"required": true,
"package": "com.axolotlmaid.optionsprofiles.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"MixinOptionsScreen"
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -1,5 +1,5 @@
plugins { plugins {
id "com.github.johnrengelman.shadow" version "7.1.2" id 'com.github.johnrengelman.shadow'
} }
architectury { architectury {
@ -7,71 +7,46 @@ architectury {
fabric() fabric()
} }
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
configurations { configurations {
common common {
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. canBeResolved = true
canBeConsumed = false
}
compileClasspath.extendsFrom common compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common runtimeClasspath.extendsFrom common
developmentFabric.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 { dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" 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}"
common(project(path: ":common", configuration: "namedElements")) { transitive false } // Fabric API. This is technically optional, but you probably want it anyway.
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } 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 { processResources {
inputs.property "version", project.version inputs.property 'version', project.version
filesMatching("fabric.mod.json") { filesMatching('fabric.mod.json') {
expand "version": project.version expand version: project.version
} }
} }
shadowJar { shadowJar {
exclude "architectury.common.json" configurations = [project.configurations.shadowBundle]
archiveClassifier = 'dev-shadow'
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
} }
remapJar { remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile 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.
}
} }

View file

@ -21,11 +21,12 @@
] ]
}, },
"mixins": [ "mixins": [
"optionsprofiles.mixins.json", "optionsprofiles.mixins.json"
"optionsprofiles-common.mixins.json"
], ],
"depends": { "depends": {
"fabric": "*", "fabricloader": ">=0.15.11",
"minecraft": ">=1.20.4" "minecraft": "~1.20.4",
"java": ">=17",
"fabric-api": "*"
} }
} }

View file

@ -1,5 +1,11 @@
plugins { plugins {
id "com.github.johnrengelman.shadow" version "7.1.2" id 'com.github.johnrengelman.shadow'
}
loom {
forge {
mixinConfig "optionsprofiles.mixins.json"
}
} }
architectury { architectury {
@ -7,84 +13,43 @@ architectury {
forge() 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 { configurations {
common common {
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. canBeResolved = true
canBeConsumed = false
}
compileClasspath.extendsFrom common compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common runtimeClasspath.extendsFrom common
developmentForge.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 { dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}" 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}"
common(project(path: ":common", configuration: "namedElements")) { transitive false } common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } shadowBundle project(path: ':common', configuration: 'transformProductionForge')
} }
processResources { processResources {
inputs.property "version", project.version inputs.property 'version', project.version
filesMatching("META-INF/mods.toml") { filesMatching('META-INF/mods.toml') {
expand "version": project.version expand version: project.version
} }
} }
shadowJar { shadowJar {
exclude "fabric.mod.json" configurations = [project.configurations.shadowBundle]
exclude "architectury.common.json" archiveClassifier = 'dev-shadow'
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
} }
remapJar { remapJar {
input.set shadowJar.archiveFile 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.
}
} }

View file

@ -1,6 +1,6 @@
{ {
"pack": { "pack": {
"description": "Options Profiles", "description": "Options Profiles",
"pack_format": 15 "pack_format": 22
} }
} }

View file

@ -1,15 +1,16 @@
org.gradle.jvmargs=-Xmx6G 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 mod_version=1.2.1
maven_group=com.axolotlmaid.optionsprofiles 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_loader_version = 0.15.11
fabric_api_version=0.92.1+1.20.4 fabric_api_version = 0.97.1+1.20.4
forge_version=1.20.4-49.0.14 forge_version = 1.20.4-49.0.50
neoforge_version = 20.4.234

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

56
neoforge/build.gradle Normal file
View file

@ -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
}

View file

@ -0,0 +1 @@
loom.platform = neoforge

View file

@ -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();
}
}

View file

@ -2,7 +2,7 @@ pluginManagement {
repositories { repositories {
maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" } maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.minecraftforge.net/" } maven { url "https://files.minecraftforge.net/maven/" }
gradlePluginPortal() gradlePluginPortal()
} }
} }
@ -10,5 +10,6 @@ pluginManagement {
include("common") include("common")
include("fabric") include("fabric")
include("forge") include("forge")
include("neoforge")
rootProject.name = "optionsprofiles-v1.2.1-1.20.4" rootProject.name = "optionsprofiles-v1.2.1-1.20.4"