Architectury build system & huge code cleanup

This commit is contained in:
Martin Prokoph
2024-07-17 14:26:17 +02:00
parent 9e3b2ae060
commit 27221b62cd
146 changed files with 1529 additions and 855 deletions

116
neoforge/build.gradle Normal file
View File

@@ -0,0 +1,116 @@
plugins {
id 'com.github.johnrengelman.shadow'
id "me.shedaniel.unified-publishing"
}
repositories {
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
}
architectury {
platformSetupLoomIde()
neoForge()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
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
}
archivesBaseName = rootProject.archives_base_name + "-neoforge"
}
dependencies {
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge")
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
}
processResources {
inputs.property 'version', project.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: project.version
}
}
shadowJar {
configurations = [project.configurations.shadowBundle]
archiveClassifier = 'dev-shadow'
}
remapJar {
input.set shadowJar.archiveFile
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
unifiedPublishing {
project {
displayName = "MidnightControls $project.version - NeoForge $project.minecraft_version"
releaseType = "$project.release_type"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["neoforge"]
mainPublication remapJar
relations {
includes {
curseforge = "midnightlib"
modrinth = "midnightlib"
}
includes {
curseforge = "obsidianui"
modrinth = "obsidianui"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version-$project.name"
gameVersions.addAll project.minecraft_version
}
}
}
}

View File

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

View File

@@ -0,0 +1,28 @@
package com.example.yourmod.neoforge;
import com.example.yourmod.YourMod;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.Mod;
import static com.example.yourmod.YourMod.MOD_ID;
@Mod(value = MOD_ID)
public class YourModNeoForge {
public YourModNeoForge() {
YourMod.init();
}
@Mod(value = MOD_ID, dist = Dist.CLIENT)
public static class YourModClientNeoforge {
public YourModClientNeoforge() {
YourMod.initClient();
}
}
@Mod(value = MOD_ID, dist = Dist.DEDICATED_SERVER)
public static class YourModServerNeoforge {
public YourModServerNeoforge() {
YourMod.initServer();
}
}
}

View File

@@ -0,0 +1,38 @@
modLoader = "javafml"
loaderVersion = "[2,)"
#issueTrackerURL = ""
license = "MIT License"
[[mods]]
modId = "yourmod"
version = "${version}"
displayName = "Your Mod"
logoFile = "icon.png"
authors = "You!"
description = '''
An example multiloader mod featuring MidnightLib!
'''
[[mixins]]
config = "yourmod.mixins.json"
[[dependencies.yourmod]]
modId = "neoforge"
mandatory = true
versionRange = "[21.0,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.yourmod]]
modId = "minecraft"
mandatory = true
versionRange = "[1.21,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.yourmod]]
modId = "midnightlib"
mandatory = true
versionRange = "[1.0,)"
ordering = "AFTER"
side = "BOTH"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB