feat: 迁移到26.1.2上
This commit is contained in:
parent
540c7237ef
commit
d6617bf3ce
71
.github/workflows/buildAndRelease.yml
vendored
71
.github/workflows/buildAndRelease.yml
vendored
|
|
@ -17,16 +17,16 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup JDK 21
|
||||
- name: Setup JDK 25
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Run Forge data generation
|
||||
- name: Run NeoForge data generation
|
||||
run: |
|
||||
echo "=== 运行 NeoForge 数据生成 ==="
|
||||
./gradlew runData --no-daemon
|
||||
|
|
@ -55,14 +55,6 @@ jobs:
|
|||
find fabric/build/libs -name "*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" ! -name "*-dev.jar" -exec cp {} release-files/ \;
|
||||
fi
|
||||
|
||||
echo "=== 收集 forge 模块构建产物 ==="
|
||||
if [ -d "forge/build/libs" ]; then
|
||||
cp forge/build/libs/*-sources.jar release-files/ 2>/dev/null || true
|
||||
cp forge/build/libs/*-javadoc.jar release-files/ 2>/dev/null || true
|
||||
# 只复制主jar(没有sources/javadoc classifier的jar)
|
||||
find forge/build/libs -name "*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" -exec cp {} release-files/ \;
|
||||
fi
|
||||
|
||||
echo "=== 收集 neoforge 模块构建产物 ==="
|
||||
if [ -d "neoforge/build/libs" ]; then
|
||||
cp neoforge/build/libs/*-sources.jar release-files/ 2>/dev/null || true
|
||||
|
|
@ -171,18 +163,12 @@ jobs:
|
|||
FABRIC_MODRINTH_DEPS=$(grep "^fabric_modrinth_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "fabric_modrinth_dependencies=$FABRIC_MODRINTH_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
FORGE_MODRINTH_DEPS=$(grep "^forge_modrinth_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "forge_modrinth_dependencies=$FORGE_MODRINTH_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
NEOFORGE_MODRINTH_DEPS=$(grep "^neoforge_modrinth_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "neoforge_modrinth_dependencies=$NEOFORGE_MODRINTH_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
FABRIC_CURSEFORGE_DEPS=$(grep "^fabric_curseforge_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "fabric_curseforge_dependencies=$FABRIC_CURSEFORGE_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
FORGE_CURSEFORGE_DEPS=$(grep "^forge_curseforge_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "forge_curseforge_dependencies=$FORGE_CURSEFORGE_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
NEOFORGE_CURSEFORGE_DEPS=$(grep "^neoforge_curseforge_dependencies=" gradle.properties | cut -d'=' -f2- || echo "")
|
||||
echo "neoforge_curseforge_dependencies=$NEOFORGE_CURSEFORGE_DEPS" >> $GITHUB_OUTPUT
|
||||
|
||||
|
|
@ -399,53 +385,6 @@ jobs:
|
|||
# 失败处理
|
||||
fail-mode: skip
|
||||
|
||||
# Forge 发布到 Modrinth 和 CurseForge
|
||||
- name: Publish Forge to Modrinth & CurseForge
|
||||
uses: Kir-Antipov/mc-publish@v3.3
|
||||
if: success() && (steps.version_info.outputs.publish_modrinth == 'true' || steps.version_info.outputs.publish_curseforge == 'true')
|
||||
continue-on-error: true
|
||||
with:
|
||||
# 文件匹配规则 - 只匹配 forge 的文件
|
||||
files: |
|
||||
dist/${{ steps.version_info.outputs.mod_id }}-forge-${{ steps.version_info.outputs.minecraft_version }}-${{ steps.version_info.outputs.version }}.jar
|
||||
dist/${{ steps.version_info.outputs.mod_id }}-forge-${{ steps.version_info.outputs.minecraft_version }}-${{ steps.version_info.outputs.version }}-javadoc.jar
|
||||
dist/${{ steps.version_info.outputs.mod_id }}-forge-${{ steps.version_info.outputs.minecraft_version }}-${{ steps.version_info.outputs.version }}-sources.jar
|
||||
|
||||
# 版本信息
|
||||
name: ${{ steps.version_info.outputs.mod_name }} ${{ steps.version_info.outputs.version }} (Forge/${{ steps.version_info.outputs.minecraft_version }})
|
||||
version: "${{ steps.version_info.outputs.minecraft_version }}-forge-${{ steps.version_info.outputs.version }}"
|
||||
|
||||
# 更新日志
|
||||
changelog: ${{ steps.generate_changelog.outputs.changelog }}
|
||||
|
||||
# 版本类型
|
||||
version-type: ${{ steps.version_type.outputs.type }}
|
||||
|
||||
# 只指定 Forge 加载器
|
||||
loaders: forge
|
||||
|
||||
# 游戏版本
|
||||
game-versions: |
|
||||
${{ steps.version_info.outputs.minecraft_version }}
|
||||
|
||||
# Java版本
|
||||
java: |
|
||||
${{ steps.version_info.outputs.java_versions }}
|
||||
|
||||
# Modrinth 配置
|
||||
modrinth-id: ${{ steps.version_info.outputs.modrinth_id }}
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
modrinth-featured: true
|
||||
modrinth-unfeature-mode: any
|
||||
modrinth-dependencies: ${{ steps.version_info.outputs.forge_modrinth_dependencies }}
|
||||
|
||||
# CurseForge 配置
|
||||
curseforge-id: ${{ steps.version_info.outputs.curseforge_id }}
|
||||
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
|
||||
curseforge-dependencies: ${{ steps.version_info.outputs.forge_curseforge_dependencies }}
|
||||
|
||||
# 失败处理
|
||||
fail-mode: skip
|
||||
|
||||
# NeoForge 发布到 Modrinth 和 CurseForge
|
||||
- name: Publish NeoForge to Modrinth & CurseForge
|
||||
|
|
@ -508,11 +447,9 @@ jobs:
|
|||
echo "### Modrinth" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- 项目ID: ${{ steps.version_info.outputs.modrinth_id }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Fabric版本: ${{ steps.version_info.outputs.version }}-fabric" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Forge版本: ${{ steps.version_info.outputs.version }}-forge" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- NeoForge版本: ${{ steps.version_info.outputs.version }}-neoforge" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### CurseForge" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- 项目ID: ${{ steps.version_info.outputs.curseforge_id }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Fabric版本: ${{ steps.version_info.outputs.version }}-fabric" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Forge版本: ${{ steps.version_info.outputs.version }}-forge" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- NeoForge版本: ${{ steps.version_info.outputs.version }}-neoforge" >> $GITHUB_STEP_SUMMARY
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
// see https://fabricmc.net/develop/ for new versions
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT' apply false
|
||||
id 'net.fabricmc.fabric-loom' version '1.15.5' apply false
|
||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||
id 'net.neoforged.moddev' version '2.0.49-beta' apply false
|
||||
id 'net.neoforged.moddev' version '2.0.141' apply false
|
||||
}
|
||||
|
|
@ -96,15 +96,22 @@ processResources {
|
|||
'description' : project.description,
|
||||
'neoforge_version' : neoforge_version,
|
||||
'neoforge_loader_version_range': neoforge_loader_version_range,
|
||||
"forge_version": forge_version,
|
||||
"forge_loader_version_range": forge_loader_version_range,
|
||||
'credits' : credits,
|
||||
'java_version' : java_version
|
||||
]
|
||||
|
||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
|
||||
var jsonExpandProps = expandProps.collectEntries {
|
||||
key, value -> [(key): value instanceof String ? value.replace("\n", "\\\\n") : value]
|
||||
}
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml']) {
|
||||
expand expandProps
|
||||
}
|
||||
|
||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', '*.mixins.json']) {
|
||||
expand jsonExpandProps
|
||||
}
|
||||
|
||||
inputs.properties(expandProps)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ configurations {
|
|||
|
||||
dependencies {
|
||||
compileOnly(project(':common')) {
|
||||
capabilities {
|
||||
requireCapability "$group:$mod_id"
|
||||
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'common')
|
||||
}
|
||||
}
|
||||
commonJava project(path: ':common', configuration: 'commonJava')
|
||||
|
|
@ -36,7 +37,7 @@ tasks.named('javadoc', Javadoc).configure {
|
|||
source(configurations.commonJava)
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.links("https://docs.oracle.com/en/java/javase/21/docs/api/")
|
||||
options.links("https://docs.oracle.com/en/java/javase/25/docs/api/")
|
||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
options.addBooleanOption('Xdoclint:none', true)
|
||||
options.addStringOption('doctitle', "${mod_id} ${minecraft_version} ${version} Javadoc")
|
||||
|
|
|
|||
|
|
@ -10,17 +10,13 @@ neoForge {
|
|||
if (at.exists()) {
|
||||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = parchment_minecraft
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||
// fabric and neoforge both bundle mixinextras, so it is safe to use it in common
|
||||
compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
|
||||
annotationProcessor group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
|
||||
compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'
|
||||
annotationProcessor group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
|
@ -43,3 +39,30 @@ clean {
|
|||
delete 'generated'
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
|
||||
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'common')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
sourceSets.configureEach {
|
||||
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'common')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@ plugins {
|
|||
}
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||
}
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
implementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
localRuntime 'net.covers1624:DevLogin:0.1.0.5'
|
||||
}
|
||||
|
||||
|
|
@ -23,9 +19,6 @@ loom {
|
|||
if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
|
||||
accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
|
||||
}
|
||||
mixin {
|
||||
defaultRefmapName.set("${mod_id}.refmap.json")
|
||||
}
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
|
|
@ -82,7 +75,7 @@ loom {
|
|||
classpath += project(':common').sourceSets.main.compileClasspath
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.links("https://docs.oracle.com/en/java/javase/21/docs/api/")
|
||||
options.links("https://docs.oracle.com/en/java/javase/25/docs/api/")
|
||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
options.addBooleanOption('Xdoclint:none', true)
|
||||
options.addStringOption('doctitle', "${mod_id} ${minecraft_version} ${version} Javadoc")
|
||||
|
|
@ -107,11 +100,11 @@ loom {
|
|||
artifactId = "${mod_id}-fabric-${minecraft_version}"
|
||||
artifacts.clear()
|
||||
// 手动添加需要的artifacts
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
artifact(jar) {
|
||||
builtBy jar
|
||||
}
|
||||
artifact(remapSourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
artifact(sourcesJar) {
|
||||
builtBy sourcesJar
|
||||
classifier = 'sources'
|
||||
}
|
||||
artifact(javadocJar) {
|
||||
|
|
@ -135,8 +128,36 @@ loom {
|
|||
}
|
||||
|
||||
tasks.named('generateMetadataFileForMavenJavaPublication') {
|
||||
dependsOn tasks.named('remapJar')
|
||||
dependsOn tasks.named('remapSourcesJar')
|
||||
dependsOn tasks.named('jar')
|
||||
dependsOn tasks.named('sourcesJar')
|
||||
dependsOn tasks.named('javadocJar')
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
|
||||
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements', 'includeInternal', 'modCompileClasspath'].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'fabric')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
sourceSets.configureEach {
|
||||
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'fabric')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.example.examplemod.mixin",
|
||||
"refmap": "${mod_id}.refmap.json",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [],
|
||||
"client": [
|
||||
|
|
|
|||
|
|
@ -1,177 +0,0 @@
|
|||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
|
||||
}
|
||||
base {
|
||||
archivesName = "${mod_name}-forge-${minecraft_version}"
|
||||
}
|
||||
mixin {
|
||||
config("${mod_id}.mixins.json")
|
||||
config("${mod_id}.forge.mixins.json")
|
||||
}
|
||||
jar {
|
||||
manifest {
|
||||
attributes["MixinConfigs"] = "${mod_id}.mixins.json,${mod_id}.forge.mixins.json"
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
def commonResources = project(':common').file('src/main/resources/').getAbsolutePath()
|
||||
def forgeResources = file('src/main/resources/').getAbsolutePath()
|
||||
def forgeBuildResources = file('build/resources/main/').getAbsolutePath()
|
||||
def commonBuildResources = project(':common').file('build/resources/main/').getAbsolutePath()
|
||||
def generatedOutput = project(':common').file('src/generated/resources/').getAbsolutePath()
|
||||
|
||||
mappings channel: 'official', version: minecraft_version
|
||||
|
||||
copyIdeResources = true //Calls processResources when in dev
|
||||
|
||||
reobf = false // Forge 1.20.6+ uses official mappings at runtime, so we shouldn't reobf from official to SRG
|
||||
|
||||
// Automatically enable forge AccessTransformers if the file exists
|
||||
// This location is hardcoded in Forge and can not be changed.
|
||||
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
|
||||
// Forge still uses SRG names during compile time, so we cannot use the common AT's
|
||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformers = ["src/main/resources/META-INF/accesstransformer.cfg"]
|
||||
}
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory file('runs/client')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Client'
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
args '--mod', project.mod_id,
|
||||
'--all',
|
||||
'--existing', forgeResources,
|
||||
'--existing', commonResources,
|
||||
'--existing', forgeBuildResources,
|
||||
'--existing', commonBuildResources
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory file('runs/server')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Server'
|
||||
mods {
|
||||
modServerRun {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
args '--mod', project.mod_id,
|
||||
'--all',
|
||||
'--existing', forgeResources,
|
||||
'--existing', commonResources,
|
||||
'--existing', forgeBuildResources,
|
||||
'--existing', commonBuildResources
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory file('runs/data')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
taskName 'Data'
|
||||
mods {
|
||||
modDataRun {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
args '--mod', mod_id,
|
||||
'--all',
|
||||
'--output', generatedOutput,
|
||||
'--existing', forgeResources,
|
||||
'--existing', commonResources,
|
||||
'--existing', forgeBuildResources,
|
||||
'--existing', commonBuildResources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources.srcDir project(':common').file('src/generated/resources')
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
|
||||
|
||||
// Forge's hack fix
|
||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||
}
|
||||
|
||||
// 配置sourceJar任务
|
||||
tasks.named('sourcesJar', Jar) {
|
||||
dependsOn classes
|
||||
dependsOn project(':common').tasks.named('sourcesJar') // 显式依赖common的source
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveClassifier.set('sources')
|
||||
from sourceSets.main.allSource
|
||||
from project(':common').sourceSets.main.allSource
|
||||
}
|
||||
|
||||
// 配置javadoc任务
|
||||
tasks.named('javadoc', Javadoc) {
|
||||
source project(':common').sourceSets.main.allJava
|
||||
source sourceSets.main.allJava
|
||||
classpath = configurations.compileClasspath
|
||||
classpath += project(':common').sourceSets.main.compileClasspath
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
|
||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
options.addBooleanOption('Xdoclint:none', true)
|
||||
options.addStringOption('doctitle', "${mod_id} ${minecraft_version} ${version} Javadoc")
|
||||
}
|
||||
|
||||
// 配置javadocJar任务
|
||||
tasks.named('javadocJar', Jar) {
|
||||
dependsOn javadoc
|
||||
dependsOn project(':common').tasks.named('javadoc') // 显式依赖common的javadoc
|
||||
|
||||
archiveClassifier.set('javadoc')
|
||||
from javadoc.destinationDir
|
||||
from project(':common').javadoc.destinationDir
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
// 确保build任务包含所有需要的jar
|
||||
tasks.named('build') {
|
||||
dependsOn tasks.named('sourcesJar')
|
||||
dependsOn tasks.named('javadocJar')
|
||||
}
|
||||
|
||||
|
||||
sourceSets.each {
|
||||
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||
it.output.resourcesDir = dir
|
||||
it.java.destinationDirectory = dir
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(':common').sourceSets.main.resources
|
||||
inputs.property "version", project.version
|
||||
inputs.property "minecraft_version", minecraft_version
|
||||
inputs.property "forge_version", forge_version
|
||||
inputs.property "mod_id", mod_id
|
||||
inputs.property "mod_name", mod_name
|
||||
inputs.property "description", description
|
||||
inputs.property "mod_author", mod_author
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand([
|
||||
version: project.version,
|
||||
minecraft_version: minecraft_version,
|
||||
forge_version: forge_version,
|
||||
mod_id: mod_id,
|
||||
mod_name: mod_name,
|
||||
description: description,
|
||||
mod_author: mod_author
|
||||
])
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.example.examplemod;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod(Constants.MOD_ID)
|
||||
public class ExampleMod {
|
||||
|
||||
public ExampleMod() {
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
// to load your mod. You can access Forge and Common code in this
|
||||
// project.
|
||||
|
||||
// Use Forge to bootstrap the Common mod.
|
||||
Constants.LOG.info("Hello Forge world!");
|
||||
CommonClass.init();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.example.examplemod.mixin;
|
||||
|
||||
import com.example.examplemod.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class MixinTitleScreen {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
|
||||
Constants.LOG.info("This line is printed by an example mod mixin from Forge!");
|
||||
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.example.examplemod.platform;
|
||||
|
||||
import com.example.examplemod.platform.services.IPlatformHelper;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
||||
public class ForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
|
||||
return "Forge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
modLoader = "javafml" #mandatory
|
||||
loaderVersion = "${forge_loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions.
|
||||
license = "${license}" # Review your options at https://choosealicense.com/.
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
#clientSideOnly=true #optional
|
||||
[[mods]] #mandatory
|
||||
modId = "${mod_id}" #mandatory
|
||||
version = "${version}" #mandatory
|
||||
displayName = "${mod_name}" #mandatory
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/)
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
|
||||
logoFile = "${mod_id}.png" #optional
|
||||
credits = "${credits}" #optional
|
||||
authors = "${mod_author}" #optional
|
||||
description = '''${description}''' #mandatory (Supports multiline text)
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
modId = "forge" #mandatory
|
||||
mandatory = true #mandatory
|
||||
versionRange = "[${forge_version},)" #mandatory
|
||||
ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory
|
||||
side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER'
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
|
@ -1 +0,0 @@
|
|||
com.example.examplemod.platform.ForgePlatformHelper
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.example.examplemod.mixin",
|
||||
"compatibilityLevel": "JAVA_18",
|
||||
"mixins": [],
|
||||
"client": [
|
||||
"MixinTitleScreen"
|
||||
],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
|
|
@ -4,34 +4,27 @@
|
|||
# Project
|
||||
version=1.0.0
|
||||
group=com.example.examplemod
|
||||
java_version=21
|
||||
java_version=25
|
||||
|
||||
# Common
|
||||
minecraft_version=1.21.1
|
||||
minecraft_version=26.1.2
|
||||
mod_name=ExampleMod
|
||||
mod_author=Jared
|
||||
mod_id=examplemod
|
||||
license=CC0-1.0
|
||||
credits=
|
||||
description=The description of your mod. \nAccepts multilines.
|
||||
minecraft_version_range=[1.21.1, 1.22)
|
||||
minecraft_version_range=[26.1.2, 26.2)
|
||||
## This is the version of minecraft that the 'common' project uses, you can find a list of all versions here
|
||||
## https://projects.neoforged.net/neoforged/neoform
|
||||
neo_form_version=1.21.1-20240808.144430
|
||||
# The version of ParchmentMC that is used, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
||||
parchment_minecraft=1.21
|
||||
parchment_version=2024.11.10
|
||||
neo_form_version=26.1.2-1
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.109.0+1.21.1
|
||||
fabric_loader_version=0.16.9
|
||||
|
||||
# Forge
|
||||
forge_version=52.0.28
|
||||
forge_loader_version_range=[52,)
|
||||
fabric_version=0.145.4+26.1.2
|
||||
fabric_loader_version=0.18.6
|
||||
|
||||
# NeoForge
|
||||
neoforge_version=21.1.80
|
||||
neoforge_version=26.1.2.7-beta
|
||||
neoforge_loader_version_range=[4,)
|
||||
|
||||
# Gradle
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@ neoForge {
|
|||
if (at.exists()) {
|
||||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
parchment {
|
||||
minecraftVersion = parchment_minecraft
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
runs {
|
||||
configureEach {
|
||||
systemProperty('neoforge.enabledGameTestNamespaces', mod_id)
|
||||
|
|
@ -86,7 +82,7 @@ tasks.named('javadoc', Javadoc) {
|
|||
classpath += project(':common').sourceSets.main.compileClasspath
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.links("https://docs.oracle.com/en/java/javase/21/docs/api/")
|
||||
options.links("https://docs.oracle.com/en/java/javase/25/docs/api/")
|
||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
options.addBooleanOption('Xdoclint:none', true)
|
||||
options.addStringOption('doctitle', "${mod_id} ${minecraft_version} ${version} Javadoc")
|
||||
|
|
@ -110,3 +106,32 @@ tasks.named('build') {
|
|||
}
|
||||
|
||||
sourceSets.main.resources.srcDir project(':common').file('src/generated/resources')
|
||||
|
||||
|
||||
afterEvaluate {
|
||||
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
|
||||
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'neoforge')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
sourceSets.configureEach {
|
||||
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName, it.getTaskName(null, 'jarJar')].each { variant ->
|
||||
try {
|
||||
configurations.named(variant) {
|
||||
if (!it.isLocked()) {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'neoforge')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,44 +10,18 @@ pluginManagement {
|
|||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup('net.fabricmc')
|
||||
includeGroup('fabric-loom')
|
||||
includeGroupAndSubgroups('net.fabricmc')
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Sponge'
|
||||
url = uri('https://repo.spongepowered.org/repository/maven-public')
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups("org.spongepowered")
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Forge'
|
||||
url = uri('https://maven.minecraftforge.net')
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('net.minecraftforge')
|
||||
}
|
||||
}
|
||||
maven { url = 'https://maven.neoforged.net/releases' }
|
||||
maven { url = 'https://maven.parchmentmc.org' } // Add this line
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
|
||||
}
|
||||
|
||||
// This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606)
|
||||
rootProject.name = 'MultiLoader-Template'
|
||||
include('common')
|
||||
include('fabric')
|
||||
include('neoforge')
|
||||
include('forge')
|
||||
include('neoforge')
|
||||
Loading…
Reference in New Issue
Block a user