diff --git a/.github/workflows/scripts/matrix.py b/.github/workflows/scripts/matrix.py index 7cdfa38..7cc77c2 100644 --- a/.github/workflows/scripts/matrix.py +++ b/.github/workflows/scripts/matrix.py @@ -32,7 +32,7 @@ def main(): matrix_entries = [] for subproject in subprojects: mod_brand = subproject.split('-')[-1] - assert mod_brand in ['fabric', 'forge'] + assert mod_brand in ['fabric', 'forge', 'neoforge'] matrix_entries.append({ 'subproject': subproject, 'mod_brand': mod_brand, diff --git a/build.gradle b/build.gradle index 4e297cd..11ea4d5 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,10 @@ preprocess { def mc119_forge = createNode('1.19.4-forge' , 1_19_04, '') def mc1204_forge = createNode('1.20.4-forge' , 1_20_04, '') // Architectury Loom does not support mc1.20.5+ forge at all + // see also: https://github.com/architectury/architectury-loom/pull/219 + + def mc1206_neoforge = createNode('1.20.6-neoforge', 1_20_06, '') + def mc121_neoforge = createNode('1.21-neoforge' , 1_21_00, '') mc114_fabric.link(mc115_fabric, null) mc115_fabric.link(mc116_fabric, null) @@ -45,6 +49,9 @@ preprocess { mc118_fabric.link(mc118_forge, null) mc119_fabric.link(mc119_forge, null) mc1204_fabric.link(mc1204_forge, null) + + mc1206_fabric.link(mc1206_neoforge, null) + mc121_fabric.link(mc121_neoforge, null) } tasks.register('buildAndGather') { diff --git a/common.gradle b/common.gradle index a310237..dc91ae7 100644 --- a/common.gradle +++ b/common.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.replaymod.preprocess' apply plugin: 'me.fallenbreath.yamlang' def mod_brand = (loom.platform.get() as String).toLowerCase() -assert mod_brand in ['fabric', 'forge'] +assert mod_brand in ['fabric', 'forge', 'neoforge'] assert project.name.endsWith('-' + mod_brand) // optional check int mcVersion = 1 @@ -16,6 +16,8 @@ preprocess { vars.put("MC", mcVersion) vars.put("FABRIC", mod_brand == 'fabric' ? 1 : 0) vars.put("FORGE", mod_brand == 'forge' ? 1 : 0) + vars.put("NEOFORGE", mod_brand == 'neoforge' ? 1 : 0) + vars.put("FORGE_LIKE", mod_brand in ['forge', 'neoforge'] ? 1 : 0) } repositories { @@ -25,6 +27,9 @@ repositories { maven { url 'https://maven.fallenbreath.me/releases' } + maven { + url 'https://maven.neoforged.net/releases' + } } // https://github.com/FabricMC/fabric-loader/issues/783 @@ -35,12 +40,22 @@ configurations { dependencies { // loom minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + if (mod_brand == 'fabric' || mod_brand == 'forge') { + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + } else { + // https://github.com/architectury/architectury-loom/issues/214 + mappings loom.layered { + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:${project.yarn_mappings_patch}") + } + } if (mod_brand == 'fabric') { modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" - } else { + } else if (mod_brand == 'forge') { forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" + } else if (mod_brand == 'neoforge') { + neoForge "net.neoforged:neoforge:${project.neoforge_version}" } // runtime mods @@ -100,10 +115,10 @@ String finalModVersion = project.mod_version + modVersionSuffix String fullProjectVersion, fullArtifactVersion // Example version values: -// project.mod_version 1.0.3 (the base mod version) -// finalModVersion 1.0.3+build.88 (the actual mod version to use) -// fullProjectVersion mc1.15.2-v1.0.3+build.88 (in build output jar name) -// fullArtifactVersion mc1.15.2-v1.0.3-SNAPSHOT (maven artifact version) +// project.mod_version 1.0.3 (the base mod version) +// finalModVersion 1.0.3+build.88 (the actual mod version to use) +// fullProjectVersion mc1.15.2-fabric-v1.0.3+build.88 (in build output jar name) +// fullArtifactVersion mc1.15.2-fabric-v1.0.3-SNAPSHOT (maven artifact version) group = project.maven_group if (System.getenv("JITPACK") == "true") { @@ -126,24 +141,32 @@ processResources { inputs.property "version", finalModVersion inputs.property "minecraft_dependency", project.minecraft_dependency + def good_files = [] as Set + def all_files = [] as Set [ 'fabric': ['fabric.mod.json'], 'forge': ['META-INF', 'META-INF/mods.toml', 'pack.mcmeta'], - ].forEach { brand, files -> - files.forEach { name -> - if (brand == mod_brand) { - filesMatching(name) { - def valueMap = [ - "id": project.mod_id, - "name": project.mod_name, - "version": finalModVersion, - "minecraft_dependency": project.minecraft_dependency, - ] - expand valueMap - } - } else { - exclude name + 'neoforge': ['META-INF', 'META-INF/neoforge.mods.toml', 'pack.mcmeta'], + ].forEach { brand, paths -> + all_files.addAll(paths) + if (brand == mod_brand) { + good_files.addAll(paths) + } + } + all_files.forEach { it2 -> + def path = it2 as String + if (good_files.contains(path)) { + filesMatching(path) { + def valueMap = [ + "id": project.mod_id, + "name": project.mod_name, + "version": finalModVersion, + "minecraft_dependency": project.minecraft_dependency, + ] + expand valueMap } + } else { + exclude path } } @@ -151,7 +174,7 @@ processResources { filter { s -> s.replace('{{COMPATIBILITY_LEVEL}}', "JAVA_${MIXIN_COMPATIBILITY_LEVEL.ordinal() + 1}") } } - if (mod_brand == 'forge') { + if (mod_brand == 'forge' || mod_brand == 'neoforge') { // forge requires the mod icon file to be at the resource root filesMatching(MOD_ICON_PATH) { f -> f.path = new File(f.path).getName() } } diff --git a/settings.json b/settings.json index 27d75a9..5fc1ae4 100644 --- a/settings.json +++ b/settings.json @@ -15,6 +15,9 @@ "1.17.1-forge", "1.18.2-forge", "1.19.4-forge", - "1.20.4-forge" + "1.20.4-forge", + + "1.20.6-neoforge", + "1.21-neoforge" ] } \ No newline at end of file diff --git a/src/main/java/me/fallenbreath/template_mod/TemplateMod.java b/src/main/java/me/fallenbreath/template_mod/TemplateMod.java index 4d674be..d7aa559 100644 --- a/src/main/java/me/fallenbreath/template_mod/TemplateMod.java +++ b/src/main/java/me/fallenbreath/template_mod/TemplateMod.java @@ -32,12 +32,17 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.metadata.ModMetadata; - //#elseif FORGE //$$ import net.minecraftforge.fml.ModList; //$$ import net.minecraftforge.fml.common.Mod; //$$ import net.minecraftforge.forgespi.language.IModInfo; -//$$ +//#elseif NEOFORGE +//$$ import net.neoforged.fml.ModList; +//$$ import net.neoforged.fml.common.Mod; +//$$ import net.neoforged.neoforgespi.language.IModInfo; +//#endif + +//#if FORGE_LIKE //$$ @Mod(TemplateMod.MOD_ID) //#endif public class TemplateMod @@ -66,13 +71,13 @@ public void onInitialize() LOGGER.info("Hello {} v{} from fabric!", MOD_NAME, MOD_VERSION); this.init(); } - //#elseif FORGE + //#elseif FORGE_LIKE //$$ public TemplateMod() //$$ { //$$ IModInfo modInfo = ModList.get().getModContainerById(MOD_ID).orElseThrow(RuntimeException::new).getModInfo(); //$$ MOD_NAME = modInfo.getDisplayName(); //$$ MOD_VERSION = modInfo.getVersion().toString(); - //$$ LOGGER.info("Hello {} v{} from forge!", MOD_NAME, MOD_VERSION); + //$$ LOGGER.info("Hello {} v{} from forge-like!", MOD_NAME, MOD_VERSION); //$$ this.init(); //$$ } //#endif diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 9926a50..c7e659c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,6 +1,7 @@ modLoader = "javafml" loaderVersion = "[31,)" license = "LGPLv3" +issueTrackerURL = "https://github.com/Fallen-Breath/fabric-mod-template/issues" [[mods]] modId = "${id}" diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..50aa778 --- /dev/null +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,25 @@ +modLoader="javafml" +loaderVersion="[1,)" +license = "LGPLv3" +issueTrackerURL = "https://github.com/Fallen-Breath/fabric-mod-template/issues" + +[[mods]] +modId = "${id}" +version = "${version}" +displayName = "${name}" +displayURL = "https://github.com/Fallen-Breath/fabric-mod-template" +authors = "Fallen_Breath" +description = ''' +Template for my fabric mods +''' +logoFile = "icon.png" + +[[mixins]] +config = "${id}.mixins.json" + +[[dependencies."${id}"]] +modId = "minecraft" +mandatory = true +versionRange = "${minecraft_dependency}" +ordering = "NONE" +side = "BOTH" diff --git a/versions/1.20.6-neoforge/gradle.properties b/versions/1.20.6-neoforge/gradle.properties new file mode 100644 index 0000000..0448ee1 --- /dev/null +++ b/versions/1.20.6-neoforge/gradle.properties @@ -0,0 +1,16 @@ +# Loom Properties + # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.20.6 + minecraft_version=1.20.6 + yarn_mappings=1.20.6+build.3 + loom.platform=neoforge + # https://maven.architectury.dev/dev/architectury/yarn-mappings-patch-neoforge/ + yarn_mappings_patch=1.20.6+build.4 + +# Mod Metadata + # https://projects.neoforged.net/neoforged/neoforge + neoforge_version=20.6.119 + minecraft_dependency=[1.20.6] + +# Build Information + # The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20.6 diff --git a/versions/1.21-neoforge/gradle.properties b/versions/1.21-neoforge/gradle.properties new file mode 100644 index 0000000..17fc1f1 --- /dev/null +++ b/versions/1.21-neoforge/gradle.properties @@ -0,0 +1,16 @@ +# Loom Properties + # check these on https://fallen-breath.github.io/fabric-versions/?&version=1.21 + minecraft_version=1.21 + yarn_mappings=1.21+build.2 + loom.platform=neoforge + # https://maven.architectury.dev/dev/architectury/yarn-mappings-patch-neoforge/ + yarn_mappings_patch=1.21+build.4 + +# Mod Metadata + # https://projects.neoforged.net/neoforged/neoforge + neoforge_version=21.0.43-beta + minecraft_dependency=[1.21] + +# Build Information + # The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.21