From 40cdc9f23d061dd9576d7f2f26a745a26de9b5d5 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:20:39 +0100 Subject: [PATCH] feat: Restructure and add NeoForge --- .github/workflows/build.yml | 2 +- .github/workflows/create-release.yml | 2 +- .github/workflows/prepare-changelog.yml | 8 - .github/workflows/publish.yml | 2 +- .github/workflows/update-versions.yml | 24 --- .gitignore | 1 + build.gradle | 88 ++++++--- fabric/build.gradle | 73 +++----- fabric/dependencies.gradle | 1 + .../{ => fabric}/FabricPrettyBeaches.java | 3 +- .../client/FabricPrettyBeachesClient.java | 2 +- fabric/src/main/resources/fabric.mod.json | 32 ++-- .../prettybeaches.fabric.mixins.json | 5 +- forge/build.gradle | 168 +++++------------- forge/src/main/resources/META-INF/mods.toml | 56 +++--- .../resources/prettybeaches.forge.mixins.json | 14 ++ gradle.properties | 31 ++-- modrinth.md => modpage.md | 0 neoforge/build.gradle | 139 +++++++++++++++ neoforge/dependencies.gradle | 2 + .../prettybeaches/NeoForgePrettyBeaches.java | 13 ++ .../src/main/resources/META-INF/mods.toml | 35 ++++ .../prettybeaches.neoforge.mixins.json | 13 ++ settings.gradle | 17 +- shared/build.gradle | 34 +--- shared/src/main/resources/pack.mcmeta | 6 +- .../main/resources/prettybeaches.mixins.json | 1 + ...ettybeaches-icon.png => prettybeaches.png} | Bin 28 files changed, 455 insertions(+), 317 deletions(-) delete mode 100644 .github/workflows/prepare-changelog.yml delete mode 100644 .github/workflows/update-versions.yml rename fabric/src/main/java/net/blay09/mods/prettybeaches/{ => fabric}/FabricPrettyBeaches.java (73%) rename fabric/src/main/java/net/blay09/mods/prettybeaches/{ => fabric}/client/FabricPrettyBeachesClient.java (77%) rename forge/src/main/resources/prettybeaches.mixins.json => fabric/src/main/resources/prettybeaches.fabric.mixins.json (59%) create mode 100644 forge/src/main/resources/prettybeaches.forge.mixins.json rename modrinth.md => modpage.md (100%) create mode 100644 neoforge/build.gradle create mode 100644 neoforge/dependencies.gradle create mode 100644 neoforge/src/main/java/net/blay09/mods/prettybeaches/NeoForgePrettyBeaches.java create mode 100644 neoforge/src/main/resources/META-INF/mods.toml create mode 100644 neoforge/src/main/resources/prettybeaches.neoforge.mixins.json rename {fabric => shared}/src/main/resources/prettybeaches.mixins.json (86%) rename shared/src/main/resources/{prettybeaches-icon.png => prettybeaches.png} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b07d9fd..f6f963f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,5 +6,5 @@ on: jobs: build: - uses: TwelveIterationMods/Workflows/.github/workflows/build.yml@main + uses: TwelveIterationMods/Workflows/.github/workflows/build.yml@v2 secrets: inherit diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index dc64030..b445c02 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -14,7 +14,7 @@ on: jobs: create-release: - uses: TwelveIterationMods/Workflows/.github/workflows/create-release.yml@main + uses: TwelveIterationMods/Workflows/.github/workflows/create-release.yml@v2 with: bump: ${{ github.event.inputs.bump }} secrets: inherit diff --git a/.github/workflows/prepare-changelog.yml b/.github/workflows/prepare-changelog.yml deleted file mode 100644 index 5429192..0000000 --- a/.github/workflows/prepare-changelog.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: prepare-changelog -on: - workflow_dispatch: - -jobs: - build: - uses: TwelveIterationMods/Workflows/.github/workflows/prepare-changelog.yml@main - secrets: inherit diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6cc84cc..b4794e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,5 +6,5 @@ on: jobs: publish: - uses: TwelveIterationMods/Workflows/.github/workflows/publish-release.yml@main + uses: TwelveIterationMods/Workflows/.github/workflows/publish-release.yml@v2 secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-versions.yml b/.github/workflows/update-versions.yml deleted file mode 100644 index 86649a6..0000000 --- a/.github/workflows/update-versions.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: update-versions -on: - workflow_dispatch: - inputs: - minecraftVersion: - description: 'The Minecraft version to update to' - required: true - type: string - channel: - description: 'The release channel to update to, either latest or recommended' - required: false - default: 'latest' - type: choice - options: - - latest - - recommended - -jobs: - update-versions: - uses: TwelveIterationMods/Workflows/.github/workflows/update-versions.yml@main - with: - minecraftVersion: ${{ github.event.inputs.minecraftVersion }} - channel: ${{ github.event.inputs.channel }} - secrets: inherit \ No newline at end of file diff --git a/.gitignore b/.gitignore index a7d3d9e..f11fac4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ build # other eclipse run +runs logs diff --git a/build.gradle b/build.gradle index 53e48fb..7ba390e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,12 @@ +plugins { + id 'fabric-loom' version '1.2-SNAPSHOT' apply(false) + // id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false) // this causes ForgeGradle to fail in reobf + id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" // this is required for VanillaGradle and NeoForge to exist in harmony + id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply(false) + id 'net.darkhax.curseforgegradle' version '1.1.16' apply(false) + id "com.modrinth.minotaur" version "2.+" apply(false) +} + subprojects { apply plugin: 'java' @@ -5,32 +14,25 @@ subprojects { java.withSourcesJar() java.withJavadocJar() - tasks.withType(GenerateModuleMetadata).tap { - configureEach { - enabled = false // Do not publish dependencies in pom - } - } - - configurations { - testImplementation.extendsFrom compileOnly - } - jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_id}" } + } manifest { attributes([ "Specification-Title" : mod_id, "Specification-Vendor" : "BlayTheNinth", - "Specification-Version" : "1", + "Specification-Version" : project.jar.archiveVersion, "Implementation-Title" : project.name, "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "BlayTheNinth", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Implementation-Vendor" : "BlayTheNinth" ]) - if (forge_mixins.toBoolean()) { - attributes([ - "MixinConfigs": mod_id + ".mixins.json" - ]) - } + } + } + + sourcesJar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_id}" } } } @@ -55,22 +57,56 @@ subprojects { // For WTHIT maven { url "https://maven.bai.lol" } + + // For ModMenu + maven { url "https://maven.terraformersmc.com/releases/" } } tasks.withType(JavaCompile).configureEach { it.options.encoding = 'UTF-8' - it.options.release = java_version as int + it.options.getRelease().set(java_version.toInteger()) } - tasks.withType(Javadoc).tap { - configureEach { - failOnError false - } + tasks.withType(Javadoc).configureEach { + failOnError false } - if (balm_version.endsWith("SNAPSHOT")) { - configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor 10, 'minutes' + processResources { + def expandProps = [ + "version": version, + "group": project.group, //Else we target the task's group. + "minecraft_version": minecraft_version, + "forge_version": forge_version, + "forge_loader_version_range": forge_loader_version_range, + "forge_version_range": forge_version_range, + "minecraft_version_range": minecraft_version_range, + "fabric_version": fabric_version, + "fabric_loader_version": fabric_loader_version, + "mod_name": mod_name, + "mod_main": mod_main, + "mod_id": mod_id, + "homepage": homepage, + "issues": issues, + "sources": sources, + "license": license, + "description": project.description, + "neoforge_version": neoforge_version, + "neoforge_version_range": neoforge_version_range, + "neoforge_loader_version_range": neoforge_loader_version_range, + "balm_version_range": balm_version_range, + "pack_format_number": pack_format_number + ] + + filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) { + expand expandProps } + inputs.properties(expandProps) + } + + // Disables Gradle's custom module metadata from being published to maven. The + // metadata includes mapped dependencies which are not reasonably consumable by + // other mod developers. + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false } } \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index a2029e0..4257680 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,14 +1,14 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' id 'maven-publish' id 'idea' - id 'net.darkhax.curseforgegradle' version '1.0.14' - id "com.modrinth.minotaur" version "2.+" + id 'net.darkhax.curseforgegradle' + id "com.modrinth.minotaur" } -group = mod_group -archivesBaseName = "${mod_id}-fabric-${minecraft_version}" -version = mod_version +base { + archivesName = "${mod_id}-fabric-${minecraft_version}" +} dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" @@ -16,34 +16,28 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" - implementation project(":shared") modImplementation("net.blay09.mods:balm-fabric:${balm_version}") { transitive = false changing = balm_version.endsWith("SNAPSHOT") } - compileOnly "org.jetbrains:annotations:22.0.0" + implementation project(":shared") + compileOnly "org.jetbrains:annotations:22.0.0" +} - modCompileOnly "curse.maven:modmenu-308702:$modmenu_version" +apply from: 'dependencies.gradle' - modCompileOnly "mezz.jei:jei-$jei_minecraft_version-fabric-api:$jei_version" - if (jei_minecraft_version == minecraft_version) { - modRuntimeOnly "mezz.jei:jei-$jei_minecraft_version-fabric:$jei_version" +loom { + if (project(":shared").file("src/main/resources/${mod_id}.accesswidener").exists()) { + accessWidenerPath.set(project(":shared").file("src/main/resources/${mod_id}.accesswidener")) } - modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$rei_version") { - transitive = false + mixin { + defaultRefmapName.set("${mod_id}.refmap.json") } - modCompileOnly "curse.maven:jade-324717:$jade_forge_version" - modCompileOnly "mcp.mobius.waila:wthit-api:mojmap-$wthit_version" -} - -apply from: 'dependencies.gradle' - -loom { runs { client { client() @@ -70,31 +64,20 @@ loom { } } -sourceSets { - main { - resources { - srcDirs 'src/generated/resources' - } - } -} - -processResources { - from project(":shared").sourceSets.main.resources - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} +sourceSets.main.resources.srcDir('src/generated/resources') -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { source(project(":shared").sourceSets.main.allSource) } +tasks.withType(Javadoc).configureEach { + source(project(":shared").sourceSets.main.allJava) +} +tasks.named("sourcesJar", Jar) { + from(project(":shared").sourceSets.main.allSource) +} -jar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_id}" } - } +processResources { + from project(":shared").sourceSets.main.resources } publishing { @@ -127,6 +110,7 @@ task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { def mainFile = upload(curseforge_fabric_project_id, file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) mainFile.changelog = rootProject.file('CHANGELOG.md').text + mainFile.addRequirement("fabric-api") mainFile.addRequirement("balm-fabric") project.minecraft_versions.split(',').toList().each { mainFile.addGameVersion(it) } mainFile.releaseType = "release" @@ -134,15 +118,16 @@ task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { modrinth { token = project.findProperty("modrinth.token") ?: System.getenv("MODRINTH_TOKEN") ?: "none" - projectId = project.modrinth_fabric_project_id + projectId = project.modrinth_project_id versionType = project.modrinth_release_type versionNumber = project.version + "+fabric-" + project.minecraft_version uploadFile = remapJar changelog = rootProject.file("CHANGELOG.md").text gameVersions = project.minecraft_versions.split(',').toList() - syncBodyFrom = rootProject.file("modrinth.md").text + syncBodyFrom = rootProject.file("modpage.md").text loaders = ['fabric'] dependencies { + required.project "fabric-api" required.project "balm" } } \ No newline at end of file diff --git a/fabric/dependencies.gradle b/fabric/dependencies.gradle index 571b417..2e40f12 100644 --- a/fabric/dependencies.gradle +++ b/fabric/dependencies.gradle @@ -1,2 +1,3 @@ dependencies { + modCompileOnly "com.terraformersmc:modmenu:$modmenu_version" } \ No newline at end of file diff --git a/fabric/src/main/java/net/blay09/mods/prettybeaches/FabricPrettyBeaches.java b/fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/FabricPrettyBeaches.java similarity index 73% rename from fabric/src/main/java/net/blay09/mods/prettybeaches/FabricPrettyBeaches.java rename to fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/FabricPrettyBeaches.java index 505696e..e500dad 100644 --- a/fabric/src/main/java/net/blay09/mods/prettybeaches/FabricPrettyBeaches.java +++ b/fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/FabricPrettyBeaches.java @@ -1,6 +1,7 @@ -package net.blay09.mods.prettybeaches; +package net.blay09.mods.prettybeaches.fabric; import net.blay09.mods.balm.api.Balm; +import net.blay09.mods.prettybeaches.PrettyBeaches; import net.fabricmc.api.ModInitializer; public class FabricPrettyBeaches implements ModInitializer { diff --git a/fabric/src/main/java/net/blay09/mods/prettybeaches/client/FabricPrettyBeachesClient.java b/fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/client/FabricPrettyBeachesClient.java similarity index 77% rename from fabric/src/main/java/net/blay09/mods/prettybeaches/client/FabricPrettyBeachesClient.java rename to fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/client/FabricPrettyBeachesClient.java index 2005e79..3a92c0a 100644 --- a/fabric/src/main/java/net/blay09/mods/prettybeaches/client/FabricPrettyBeachesClient.java +++ b/fabric/src/main/java/net/blay09/mods/prettybeaches/fabric/client/FabricPrettyBeachesClient.java @@ -1,4 +1,4 @@ -package net.blay09.mods.prettybeaches.client; +package net.blay09.mods.prettybeaches.fabric.client; import net.fabricmc.api.ClientModInitializer; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index e845743..39364da 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,41 +1,43 @@ { "schemaVersion": 1, - "id": "prettybeaches", + "id": "${mod_id}", "version": "${version}", - "name": "Pretty Beaches", - "description": "Adjusts water physics when digging sand near water to prevent ugly.", + "name": "${mod_name}", + "description": "${description}", "authors": [ "BlayTheNinth" ], "contact": { - "homepage": "https://mods.twelveiterations.com/mc/prettybeaches", - "sources": "https://github.com/TwelveIterationMods/PrettyBeaches", - "issues": "https://github.com/TwelveIterationMods/PrettyBeaches/issues" + "homepage": "${homepage}", + "sources": "${sources}", + "issues": "${issues}" }, - "license": "All Rights Reserved", - "icon": "prettybeaches-icon.png", + "license": "${license}", + "icon": "${mod_id}.png", "environment": "*", "entrypoints": { "main": [ - "net.blay09.mods.prettybeaches.FabricPrettyBeaches" + "net.blay09.mods.${mod_id}.fabric.Fabric${mod_main}" ], "client": [ - "net.blay09.mods.prettybeaches.client.FabricPrettyBeachesClient" + "net.blay09.mods.${mod_id}.fabric.client.Fabric${mod_main}Client" ], "modmenu": [ - "net.blay09.mods.prettybeaches.compat.ModMenuIntegration" + "net.blay09.mods.${mod_id}.fabric.compat.ModMenuIntegration" ] }, "mixins": [ - "prettybeaches.mixins.json" + "${mod_id}.mixins.json", + "${mod_id}.fabric.mixins.json" ], + "depends": { - "balm-fabric": ">=8.0.0", - "fabricloader": ">=0.14.22", - "fabric": "*", + "fabricloader": ">=0.14", + "fabric-api": "*", + "balm-fabric": "*", "minecraft": ">=1.20.2", "java": ">=17" }, diff --git a/forge/src/main/resources/prettybeaches.mixins.json b/fabric/src/main/resources/prettybeaches.fabric.mixins.json similarity index 59% rename from forge/src/main/resources/prettybeaches.mixins.json rename to fabric/src/main/resources/prettybeaches.fabric.mixins.json index 873d334..f4eef07 100644 --- a/forge/src/main/resources/prettybeaches.mixins.json +++ b/fabric/src/main/resources/prettybeaches.fabric.mixins.json @@ -1,11 +1,10 @@ { "required": true, "minVersion": "0.8", - "package": "net.blay09.mods.prettybeaches.mixin", + "package": "net.blay09.mods.prettybeaches.fabric.mixin", "compatibilityLevel": "JAVA_17", - "refmap": "prettybeaches.refmap.json", + "refmap": "${mod_id}.refmap.json", "mixins": [ - "ItemAccessor" ], "client": [ ], diff --git a/forge/build.gradle b/forge/build.gradle index 01fa9a6..55e1be9 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,56 +1,48 @@ -buildscript { - repositories { - maven { url = "https://repo.spongepowered.org/maven" } - mavenCentral() - } - dependencies { - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - } -} - plugins { - id 'net.minecraftforge.gradle' version '[6.0,6.2)' - id 'maven-publish' id 'idea' - id 'net.darkhax.curseforgegradle' version '1.0.14' - id "com.modrinth.minotaur" version "2.+" + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' + id 'org.spongepowered.mixin' + id 'net.darkhax.curseforgegradle' + id "com.modrinth.minotaur" +} + +base { + archivesName = "${mod_id}-forge-${minecraft_version}" } -apply plugin: "org.spongepowered.mixin" +mixin { + add(sourceSets.main, "${mod_id}.refmap.json") -group = mod_group -archivesBaseName = "${mod_id}-forge-${minecraft_version}" -version = mod_version + config("${mod_id}.mixins.json") + config("${mod_id}.forge.mixins.json") +} minecraft { mappings channel: 'official', version: minecraft_version copyIdeResources = true + // 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 + if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + } + runs { client { workingDirectory project.file('run') ideaModule "${rootProject.name}.${project.name}.main" taskName "Client" - if (forge_mixins.toBoolean()) { - arg "-mixin.config=${mod_id}.mixins.json" - } - - property "mixin.env.disableRefMap", "true" - property "mixin.debug.export", "true" - property "mixin.debug.export.decompile", "false" - property "mixin.debug.verbose", "true" - property "mixin.debug.dumpTargetOnFailure", "true" - property "mixin.checks", "true" - property "mixin.hotSwap", "true" - - property 'forge.logging.console.level', 'debug' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" property 'forge.enabledGameTestNamespaces', mod_id mods { - "${mod_id}" { + modClientRun { source sourceSets.main source project(":shared").sourceSets.main } @@ -62,24 +54,13 @@ minecraft { ideaModule "${rootProject.name}.${project.name}.main" taskName "Server" - if (forge_mixins.toBoolean()) { - arg "-mixin.config=${mod_id}.mixins.json" - } - - property "mixin.env.disableRefMap", "true" - property "mixin.debug.export", "true" - property "mixin.debug.export.decompile", "false" - property "mixin.debug.verbose", "true" - property "mixin.debug.dumpTargetOnFailure", "true" - property "mixin.checks", "true" - property "mixin.hotSwap", "true" - - property 'forge.logging.console.level', 'debug' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" property 'forge.enabledGameTestNamespaces', mod_id mods { - "${mod_id}" { + modServerRun { source sourceSets.main source project(":shared").sourceSets.main } @@ -91,24 +72,13 @@ minecraft { ideaModule "${rootProject.name}.${project.name}.main" taskName "GameTest" - if (forge_mixins.toBoolean()) { - arg "-mixin.config=${mod_id}.mixins.json" - } - - property "mixin.env.disableRefMap", "true" - property "mixin.debug.export", "true" - property "mixin.debug.export.decompile", "false" - property "mixin.debug.verbose", "true" - property "mixin.debug.dumpTargetOnFailure", "true" - property "mixin.checks", "true" - property "mixin.hotSwap", "true" - - property 'forge.logging.console.level', 'debug' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" property 'forge.enabledGameTestNamespaces', mod_id mods { - "${mod_id}" { + modGameTestRun { source sourceSets.main source project(":shared").sourceSets.main } @@ -118,26 +88,14 @@ minecraft { data { workingDirectory project.file('run') ideaModule "${rootProject.name}.${project.name}.main" + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') taskName "Data" - property 'forge.logging.console.level', 'debug' - - if (forge_mixins.toBoolean()) { - arg "-mixin.config=${mod_id}.mixins.json" - } - - property "mixin.env.disableRefMap", "true" - property "mixin.debug.export", "true" - property "mixin.debug.export.decompile", "false" - property "mixin.debug.verbose", "true" - property "mixin.debug.dumpTargetOnFailure", "true" - property "mixin.checks", "true" - property "mixin.hotSwap", "true" - - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" mods { - "${mod_id}" { + modDataRun { source sourceSets.main source project(":shared").sourceSets.main } @@ -146,64 +104,35 @@ minecraft { } } -sourceSets { - main { - resources { - srcDirs 'src/generated/resources' - } - ext.refMap = "${mod_id}.refmap.json" - } -} +sourceSets.main.resources.srcDir 'src/generated/resources' dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - annotationProcessor 'org.spongepowered:mixin:0.8.4:processor' - compileOnly project(":shared") + annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor" implementation fg.deobf("net.blay09.mods:balm-forge:${balm_version}") { changing = balm_version.endsWith("SNAPSHOT") } - compileOnly "org.jetbrains:annotations:22.0.0" - - compileOnly fg.deobf("mezz.jei:jei-$jei_minecraft_version-common-api:$jei_version") - if (jei_minecraft_version == minecraft_version) { - runtimeOnly fg.deobf("mezz.jei:jei-$jei_minecraft_version-forge:$jei_version") - } + compileOnly project(":shared") - compileOnly fg.deobf("curse.maven:jade-324717:$jade_forge_version") - compileOnly fg.deobf("mcp.mobius.waila:wthit-api:forge-$wthit_version") - compileOnly fg.deobf("curse.maven:the-one-probe-245211:$theoneprobe_version") + compileOnly "org.jetbrains:annotations:22.0.0" } apply from: 'dependencies.gradle' -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { source(project(":shared").sourceSets.main.allSource) } +tasks.withType(Javadoc).configureEach { + source(project(":shared").sourceSets.main.allJava) +} +tasks.named("sourcesJar", Jar) { + from(project(":shared").sourceSets.main.allSource) +} -def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] -def replaceProperties = [ - minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, - forge_version: forge_version, forge_version_range: forge_version_range, - forge_loader_version_range: forge_loader_version_range, - mod_id: mod_id, mod_version: mod_version, balm_version_range: balm_version_range, -] processResources { from project(":shared").sourceSets.main.resources - - inputs.properties replaceProperties - replaceProperties.put 'project', project - - filesMatching(resourceTargets) { - expand replaceProperties - } -} - -jar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_id}" } - } } jar.finalizedBy('reobfJar') @@ -214,7 +143,8 @@ publishing { artifactId = mod_id + "-forge" version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "") - artifact jar + from components.java + fg.component(it) } } @@ -245,13 +175,13 @@ task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { modrinth { token = project.findProperty("modrinth.token") ?: System.getenv("MODRINTH_TOKEN") ?: "none" - projectId = project.modrinth_forge_project_id + projectId = project.modrinth_project_id versionType = project.modrinth_release_type versionNumber = project.version + "+forge-" + project.minecraft_version uploadFile = jar changelog = rootProject.file("CHANGELOG.md").text gameVersions = project.minecraft_versions.split(',').toList() - syncBodyFrom = rootProject.file("modrinth.md").text + syncBodyFrom = rootProject.file("modpage.md").text loaders = ['forge'] dependencies { required.project "balm" diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 271d450..cfeb7b4 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,35 +1,31 @@ modLoader="javafml" loaderVersion="${forge_loader_version_range}" -license="All rights reserved" -issueTrackerURL="https://github.com/TwelveIterationMods/PrettyBeaches/issues" - +license="${license}" +issueTrackerURL="${issues}" [[mods]] -modId="prettybeaches" -version="${mod_version}" -displayName="Pretty Beaches" -displayURL="https://mods.twelveiterations.com/mc/prettybeaches" -logoFile="prettybeaches-icon.png" +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${homepage}" +logoFile="${mod_id}.png" credits="BlayTheNinth" authors="BlayTheNinth" -description=''' -Adjusts water physics when digging sand near water to prevent ugly. -''' - -[[dependencies.prettybeaches]] - modId="forge" - mandatory=true - versionRange="${forge_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.prettybeaches]] - modId="minecraft" - mandatory=true - versionRange="${minecraft_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.prettybeaches]] - modId="balm" - mandatory=true - versionRange="${balm_version_range}" - ordering="NONE" - side="BOTH" +description='''${description}''' +[[dependencies.${mod_id}]] +modId="forge" +mandatory=true +versionRange="${forge_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="minecraft" +mandatory=true +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="balm" +mandatory=true +versionRange="${balm_version_range}" +ordering="NONE" +side="BOTH" diff --git a/forge/src/main/resources/prettybeaches.forge.mixins.json b/forge/src/main/resources/prettybeaches.forge.mixins.json new file mode 100644 index 0000000..de8ed6a --- /dev/null +++ b/forge/src/main/resources/prettybeaches.forge.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.blay09.mods.prettybeaches.forge.mixin", + "compatibilityLevel": "JAVA_17", + "refmap": "${mod_id}.refmap.json", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/gradle.properties b/gradle.properties index a163752..1ce6a75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,27 @@ # Mod -mod_version = 12.0.0 mod_id = prettybeaches -mod_group = net.blay09.mods +mod_name = Pretty Beaches +mod_main=PrettyBeaches +description=Adjusts water physics when digging sand near water to prevent ugly. +version = 12.0.0 +group = net.blay09.mods +homepage=https://mods.twelveiterations.com/mc/pretty-beaches +sources=https://github.com/TwelveIterationMods/PrettyBeaches +issues=https://github.com/TwelveIterationMods/PrettyBeaches/issues +license=All Rights Reserved # Publishing curseforge_release_type = release curseforge_forge_project_id = 290659 curseforge_fabric_project_id = 547700 modrinth_release_type = release -modrinth_forge_project_id = IAJe5m4X -modrinth_fabric_project_id = IAJe5m4X +modrinth_project_id = IAJe5m4X # Minecraft minecraft_version = 1.20.2 minecraft_versions = 1.20.2 minecraft_version_range=[1.20.2,1.21) +pack_format_number=18 java_version = 17 # Balm @@ -25,23 +32,19 @@ balm_version_range = [8.0.0,) forge_version = 48.0.1 forge_version_range=[48.0.0,) forge_loader_version_range=[48,) -forge_mixins=true + +# NeoForge +neoforge_version = 20.2.86 +neoforge_version_range=[20.2,) +neoforge_loader_version_range=[1,) # Fabric fabric_version = 0.89.0+1.20.2 fabric_loader_version = 0.14.22 # Dependencies -jei_minecraft_version=1.19.2 -jei_version=11.4.0.288 -rei_version=10.0.581 -wthit_version=6.1.1 -jade_fabric_version=4160727 -jade_forge_version=4159759 mixin_version=0.8.5 -modmenu_version=4159524 -theoneprobe_version=4159743 -cloth_config_version=9.0.94 +modmenu_version=8.0.0 # Gradle org.gradle.jvmargs=-Xmx3G diff --git a/modrinth.md b/modpage.md similarity index 100% rename from modrinth.md rename to modpage.md diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..79a43f8 --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,139 @@ +plugins { + id 'java-library' + id 'idea' + id 'maven-publish' + id 'net.neoforged.gradle.userdev' version '7.0.41' + id 'net.darkhax.curseforgegradle' + id "com.modrinth.minotaur" +} + +base { + archivesName = "${mod_id}-neoforge-${minecraft_version}" +} + +if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg') +} +runs { + configureEach { + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + systemProperty 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + systemProperty 'forge.logging.console.level', 'debug' + + modSource project.sourceSets.main + } + + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } + + server { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } + + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } + + data { + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it + // workingDirectory project.file('run-data') + + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } +} + +sourceSets.main.resources { srcDir 'src/generated/resources' } + +dependencies { + implementation "net.neoforged:neoforge:${neoforge_version}" + + implementation("net.blay09.mods:balm-neoforge:${balm_version}") { + changing = balm_version.endsWith("SNAPSHOT") + } + + compileOnly project(":shared") + + compileOnly "org.jetbrains:annotations:22.0.0" +} + +apply from: 'dependencies.gradle' + +// NeoGradle compiles the game, but we don't want to add our common code to the game's code +Spec notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec + +tasks.withType(JavaCompile).matching(notNeoTask).configureEach { + source(project(":shared").sourceSets.main.allSource) +} + +tasks.withType(Javadoc).matching(notNeoTask).configureEach { + source(project(":shared").sourceSets.main.allJava) +} + +tasks.named("sourcesJar", Jar) { + from(project(":shared").sourceSets.main.allSource) +} + +tasks.withType(ProcessResources).matching(notNeoTask).configureEach { + from project(":shared").sourceSets.main.resources +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId = mod_id + "-neoforge" + version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "") + + from components.java + } + } + + repositories { + maven { + var releasesRepoUrl = "https://maven.twelveiterations.com/repository/maven-releases/" + var snapshotsRepoUrl = "https://maven.twelveiterations.com/repository/maven-snapshots/" + url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl) + name = "twelveIterationsNexus" + credentials(PasswordCredentials) + } + } +} + +task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { + dependsOn('build') + description = 'Publishes the NeoForge build to CurseForge.' + group = 'publishing' + + apiToken = project.findProperty("curseforge.api_key") ?: System.getenv("CURSEFORGE_TOKEN") ?: "none" + + def mainFile = upload(curseforge_forge_project_id, file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) + mainFile.changelog = rootProject.file('CHANGELOG.md').text + project.minecraft_versions.split(',').toList().each { mainFile.addGameVersion(it) } + mainFile.releaseType = "release" +} + +modrinth { + token = project.findProperty("modrinth.token") ?: System.getenv("MODRINTH_TOKEN") ?: "none" + projectId = project.modrinth_project_id + versionType = project.modrinth_release_type + versionNumber = project.version + "+neoforge-" + project.minecraft_version + uploadFile = jar + changelog = rootProject.file("CHANGELOG.md").text + gameVersions = project.minecraft_versions.split(',').toList() + syncBodyFrom = rootProject.file("modpage.md").text + loaders = ['neoforge'] +} \ No newline at end of file diff --git a/neoforge/dependencies.gradle b/neoforge/dependencies.gradle new file mode 100644 index 0000000..571b417 --- /dev/null +++ b/neoforge/dependencies.gradle @@ -0,0 +1,2 @@ +dependencies { +} \ No newline at end of file diff --git a/neoforge/src/main/java/net/blay09/mods/prettybeaches/NeoForgePrettyBeaches.java b/neoforge/src/main/java/net/blay09/mods/prettybeaches/NeoForgePrettyBeaches.java new file mode 100644 index 0000000..417be19 --- /dev/null +++ b/neoforge/src/main/java/net/blay09/mods/prettybeaches/NeoForgePrettyBeaches.java @@ -0,0 +1,13 @@ +package net.blay09.mods.prettybeaches; + +import net.blay09.mods.balm.api.Balm; +import net.neoforged.fml.common.Mod; + +@Mod(PrettyBeaches.MOD_ID) +public class NeoForgePrettyBeaches { + + public NeoForgePrettyBeaches() { + Balm.initialize(PrettyBeaches.MOD_ID, PrettyBeaches::initialize); + } + +} diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..7f33361 --- /dev/null +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,35 @@ +modLoader="javafml" +loaderVersion="${neoforge_loader_version_range}" +license="${license}" +issueTrackerURL="${issues}" +[[mods]] +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${homepage}" +logoFile="${mod_id}.png" +credits="BlayTheNinth" +authors="BlayTheNinth" +description='''${description}''' +[[mixins]] +config = "${mod_id}.mixins.json" +[[mixins]] +config = "${mod_id}.neoforge.mixins.json" +[[dependencies.${mod_id}]] +modId="neoforge" +mandatory=true +versionRange="${neoforge_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="minecraft" +mandatory=true +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" +[[dependencies.${mod_id}]] +modId="balm" +mandatory=true +versionRange="${balm_version_range}" +ordering="NONE" +side="BOTH" diff --git a/neoforge/src/main/resources/prettybeaches.neoforge.mixins.json b/neoforge/src/main/resources/prettybeaches.neoforge.mixins.json new file mode 100644 index 0000000..2c61471 --- /dev/null +++ b/neoforge/src/main/resources/prettybeaches.neoforge.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.blay09.mods.prettybeaches.neoforge.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/settings.gradle b/settings.gradle index 8e372af..1ea574d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,6 +5,14 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { + name = 'NeoForge' + url = 'https://maven.neoforged.net/releases/' + } + maven { + name = 'Forge' + url = 'https://maven.minecraftforge.net/' + } maven { name = 'Sponge Snapshots' url = 'https://repo.spongepowered.org/repository/maven-public/' @@ -12,4 +20,11 @@ pluginManagement { } } -include("shared", "fabric", "forge") \ No newline at end of file +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' +} + +include("shared") +include("fabric") +include("forge") +include("neoforge") \ No newline at end of file diff --git a/shared/build.gradle b/shared/build.gradle index 826999c..44b70b9 100644 --- a/shared/build.gradle +++ b/shared/build.gradle @@ -1,15 +1,19 @@ plugins { - id('java') - id('org.spongepowered.gradle.vanilla') version '0.2.1-SNAPSHOT' + id 'idea' + id 'java' id 'maven-publish' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' } -group = mod_group -version = mod_version -archivesBaseName = "${mod_id}-common-${minecraft_version}" +base { + archivesName = "${mod_id}-common-${minecraft_version}" +} minecraft { version(minecraft_version) + if(file("src/main/resources/${mod_id}.accesswidener").exists()){ + accessWideners(file("src/main/resources/${mod_id}.accesswidener")) + } } dependencies { @@ -19,30 +23,10 @@ dependencies { exclude(group: "net.blay09.mods", module: "shared-bridge") changing = balm_version.endsWith("SNAPSHOT") } - - compileOnly("me.shedaniel.cloth:cloth-config-fabric:$cloth_config_version") { - transitive = false - } - - compileOnly "mezz.jei:jei-$jei_minecraft_version-common-api:$jei_version" - - compileOnly "mcp.mobius.waila:wthit-api:mojmap-$wthit_version" } apply from: 'dependencies.gradle' -jar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_id}" } - } -} - -sourcesJar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_id}" } - } -} - publishing { publications { mavenJava(MavenPublication) { diff --git a/shared/src/main/resources/pack.mcmeta b/shared/src/main/resources/pack.mcmeta index 8ace3b2..a57bcee 100644 --- a/shared/src/main/resources/pack.mcmeta +++ b/shared/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "description": "Pretty Beaches resources", - "pack_format": 15 - } + "description": "${mod_name}", + "pack_format": ${pack_format_number} } +} \ No newline at end of file diff --git a/fabric/src/main/resources/prettybeaches.mixins.json b/shared/src/main/resources/prettybeaches.mixins.json similarity index 86% rename from fabric/src/main/resources/prettybeaches.mixins.json rename to shared/src/main/resources/prettybeaches.mixins.json index d1e1ed9..ccdce40 100644 --- a/fabric/src/main/resources/prettybeaches.mixins.json +++ b/shared/src/main/resources/prettybeaches.mixins.json @@ -2,6 +2,7 @@ "required": true, "minVersion": "0.8", "package": "net.blay09.mods.prettybeaches.mixin", + "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ "ItemAccessor" diff --git a/shared/src/main/resources/prettybeaches-icon.png b/shared/src/main/resources/prettybeaches.png similarity index 100% rename from shared/src/main/resources/prettybeaches-icon.png rename to shared/src/main/resources/prettybeaches.png