diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4edd5eb..f6f963f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,5 +6,5 @@ on: jobs: build: - uses: TwelveIterationMods/Workflows/.github/workflows/publish-snapshot.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 f8733b2..b445c02 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -11,11 +11,10 @@ on: - major - minor - patch - - none 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/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/src/main/resources/craftingtweaks.fabric.mixins.json b/fabric/src/main/resources/craftingtweaks.fabric.mixins.json new file mode 100644 index 0000000..d99c3d1 --- /dev/null +++ b/fabric/src/main/resources/craftingtweaks.fabric.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.blay09.mods.craftingtweaks.fabric.mixin", + "refmap": "${mod_id}.refmap.json", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index c3cbd58..39364da 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,40 +1,43 @@ { "schemaVersion": 1, - "id": "craftingtweaks", + "id": "${mod_id}", "version": "${version}", - "name": "Crafting Tweaks", - "description": "Allows you to rotate, balance or clear the crafting matrix by the press of a button, in any (supported) crafting window.", + "name": "${mod_name}", + "description": "${description}", "authors": [ "BlayTheNinth" ], "contact": { - "homepage": "https://mods.twelveiterations.com/mc/craftingtweaks", - "sources": "https://github.com/TwelveIterationMods/CraftingTweaks", - "issues": "https://github.com/TwelveIterationMods/CraftingTweaks/issues" + "homepage": "${homepage}", + "sources": "${sources}", + "issues": "${issues}" }, - "license": "All Rights Reserved", - "icon": "craftingtweaks-icon.png", + "license": "${license}", + "icon": "${mod_id}.png", "environment": "*", "entrypoints": { "main": [ - "net.blay09.mods.craftingtweaks.FabricCraftingTweaks" + "net.blay09.mods.${mod_id}.fabric.Fabric${mod_main}" ], "client": [ - "net.blay09.mods.craftingtweaks.client.FabricCraftingTweaksClient" + "net.blay09.mods.${mod_id}.fabric.client.Fabric${mod_main}Client" ], "modmenu": [ - "net.blay09.mods.craftingtweaks.compat.ModMenuIntegration" + "net.blay09.mods.${mod_id}.fabric.compat.ModMenuIntegration" ] }, "mixins": [ + "${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/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 c9d77c3..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/CraftingTweaks/issues" - +license="${license}" +issueTrackerURL="${issues}" [[mods]] -modId="craftingtweaks" -version="${mod_version}" -displayName="CraftingTweaks" -displayURL="https://mods.twelveiterations.com/mc/craftingtweaks" -logoFile="craftingtweaks-icon.png" +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${homepage}" +logoFile="${mod_id}.png" credits="BlayTheNinth" authors="BlayTheNinth" -description=''' -Allows you to rotate, balance or clear the crafting matrix by the press of a button, in any (supported) crafting window. -''' - -[[dependencies.craftingtweaks]] - modId="forge" - mandatory=true - versionRange="${forge_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.craftingtweaks]] - modId="minecraft" - mandatory=true - versionRange="${minecraft_version_range}" - ordering="NONE" - side="BOTH" -[[dependencies.craftingtweaks]] - modId="balm" - mandatory=true - versionRange="${balm_version_range}" - ordering="NONE" - side="BOTH" \ No newline at end of file +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/fabric/src/main/resources/craftingtweaks.mixins.json b/forge/src/main/resources/craftingtweaks.forge.mixins.json similarity index 73% rename from fabric/src/main/resources/craftingtweaks.mixins.json rename to forge/src/main/resources/craftingtweaks.forge.mixins.json index 90132d2..062a3f7 100644 --- a/fabric/src/main/resources/craftingtweaks.mixins.json +++ b/forge/src/main/resources/craftingtweaks.forge.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "net.blay09.mods.craftingtweaks.mixin", + "package": "net.blay09.mods.craftingtweaks.forge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index 9adc2e2..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "CraftingTweaks resources", - "pack_format": 15 - } -} diff --git a/gradle.properties b/gradle.properties index d87ec1c..eeb5502 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,27 @@ # Mod -mod_version = 19.0.1 mod_id = craftingtweaks -mod_group = net.blay09.mods +mod_name = Crafting Tweaks +mod_main=CraftingTweaks +description=Allows you to rotate, balance or clear the crafting matrix by the press of a button, in any (supported) crafting window. +version = 19.0.1 +group = net.blay09.mods +homepage=https://mods.twelveiterations.com/mc/craftingtweaks +sources=https://github.com/TwelveIterationMods/CraftingTweaks +issues=https://github.com/TwelveIterationMods/CraftingTweaks/issues +license=All Rights Reserved # Publishing curseforge_release_type = release curseforge_forge_project_id = 233071 curseforge_fabric_project_id = 502516 modrinth_release_type = release -modrinth_forge_project_id = DMu0oBKf -modrinth_fabric_project_id = DMu0oBKf +modrinth_project_id = DMu0oBKf # 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 @@ -27,6 +34,11 @@ 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 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/craftingtweaks/IMCHandler.java b/neoforge/src/main/java/net/blay09/mods/craftingtweaks/IMCHandler.java new file mode 100644 index 0000000..a938baa --- /dev/null +++ b/neoforge/src/main/java/net/blay09/mods/craftingtweaks/IMCHandler.java @@ -0,0 +1,89 @@ +package net.blay09.mods.craftingtweaks; + +import net.blay09.mods.craftingtweaks.api.CraftingGridProvider; +import net.blay09.mods.craftingtweaks.api.CraftingTweaksAPI; +import net.blay09.mods.craftingtweaks.registry.CraftingTweaksRegistrationData; +import net.blay09.mods.craftingtweaks.registry.DataDrivenGridFactory; +import net.minecraft.nbt.CompoundTag; +import net.neoforged.fml.event.lifecycle.InterModProcessEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IMCHandler { + + private static final Logger logger = LoggerFactory.getLogger(IMCHandler.class); + + public static void processInterMod(InterModProcessEvent event) { + event.getIMCStream(it -> it.equals("RegisterProvider") || it.equals("RegisterProviderV2") || it.equals("RegisterProviderV3")).forEach(message -> { + CompoundTag tagCompound = (CompoundTag) message.messageSupplier().get(); + var data = new CraftingTweaksRegistrationData(); + data.setModId(message.senderModId()); + data.setContainerClass(tagCompound.getString("ContainerClass")); + data.setContainerCallbackClass(tagCompound.getString("ContainerCallback")); + data.setValidContainerPredicateClass(tagCompound.getString("ValidContainerPredicate")); + data.setGetGridStartFunctionClass(tagCompound.getString("GetGridStartFunction")); + data.setGridSlotNumber(getIntOr(tagCompound, "GridSlotNumber", 1)); + data.setGridSize(getIntOr(tagCompound, "GridSize", 9)); + if (tagCompound.contains("ButtonOffsetX")) { + data.setButtonOffsetX(tagCompound.getInt("ButtonOffsetX")); + } + if (tagCompound.contains("ButtonOffsetY")) { + data.setButtonOffsetY(tagCompound.getInt("ButtonOffsetY")); + } + data.setAlignToGrid(tagCompound.getString("AlignToGrid")); + data.setButtonStyle(tagCompound.getString("ButtonStyle")); + data.setHideButtons(tagCompound.getBoolean("HideButtons")); + data.setPhantomItems(tagCompound.getBoolean("PhantomItems")); + + CompoundTag rotateCompound = tagCompound.getCompound("TweakRotate"); + var rotateTweak = new CraftingTweaksRegistrationData.TweakData(); + rotateTweak.setEnabled(getBoolOr(rotateCompound, "Enabled", true)); + rotateTweak.setShowButton(getBoolOr(rotateCompound, "ShowButton", true)); + if (rotateCompound.contains("ButtonX")) { + rotateTweak.setButtonX(rotateCompound.getInt("ButtonX")); + } + if (rotateCompound.contains("ButtonY")) { + rotateTweak.setButtonY(rotateCompound.getInt("ButtonY")); + } + data.setTweakRotate(rotateTweak); + + CompoundTag balanceCompound = tagCompound.getCompound("TweakBalance"); + var balanceTweak = new CraftingTweaksRegistrationData.TweakData(); + balanceTweak.setEnabled(getBoolOr(balanceCompound, "Enabled", true)); + balanceTweak.setShowButton(getBoolOr(balanceCompound, "ShowButton", true)); + if (balanceCompound.contains("ButtonX")) { + balanceTweak.setButtonX(balanceCompound.getInt("ButtonX")); + } + if (balanceCompound.contains("ButtonY")) { + balanceTweak.setButtonY(balanceCompound.getInt("ButtonY")); + } + data.setTweakBalance(balanceTweak); + + CompoundTag clearCompound = tagCompound.getCompound("TweakClear"); + var clearTweak = new CraftingTweaksRegistrationData.TweakData(); + clearTweak.setEnabled(getBoolOr(clearCompound, "Enabled", true)); + clearTweak.setShowButton(getBoolOr(clearCompound, "ShowButton", true)); + if (clearCompound.contains("ButtonX")) { + clearTweak.setButtonX(clearCompound.getInt("ButtonX")); + } + if (clearCompound.contains("ButtonY")) { + clearTweak.setButtonY(clearCompound.getInt("ButtonY")); + } + data.setTweakClear(clearTweak); + + CraftingGridProvider gridProvider = DataDrivenGridFactory.createGridProvider(data); + if (gridProvider != null) { + CraftingTweaksAPI.registerCraftingGridProvider(gridProvider); + logger.info("{} has registered {} for CraftingTweaks via IMC", data.getModId(), data.getContainerClass()); + } + }); + } + + private static int getIntOr(CompoundTag tagCompound, String key, int defaultVal) { + return (tagCompound.contains(key) ? tagCompound.getInt(key) : defaultVal); + } + + private static boolean getBoolOr(CompoundTag tagCompound, String key, boolean defaultVal) { + return (tagCompound.contains(key) ? tagCompound.getBoolean(key) : defaultVal); + } +} diff --git a/neoforge/src/main/java/net/blay09/mods/craftingtweaks/NeoForgeCraftingTweaks.java b/neoforge/src/main/java/net/blay09/mods/craftingtweaks/NeoForgeCraftingTweaks.java new file mode 100644 index 0000000..5c5219d --- /dev/null +++ b/neoforge/src/main/java/net/blay09/mods/craftingtweaks/NeoForgeCraftingTweaks.java @@ -0,0 +1,23 @@ +package net.blay09.mods.craftingtweaks; + +import net.blay09.mods.balm.api.Balm; +import net.blay09.mods.balm.api.client.BalmClient; +import net.blay09.mods.craftingtweaks.client.CraftingTweaksClient; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.DistExecutor; +import net.neoforged.fml.IExtensionPoint; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(CraftingTweaks.MOD_ID) +public class NeoForgeCraftingTweaks { + public NeoForgeCraftingTweaks() { + Balm.initialize(CraftingTweaks.MOD_ID, CraftingTweaks::initialize); + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> BalmClient.initialize(CraftingTweaks.MOD_ID, CraftingTweaksClient::initialize)); + + FMLJavaModLoadingContext.get().getModEventBus().addListener(IMCHandler::processInterMod); + ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true)); + } + +} 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/forge/src/main/resources/craftingtweaks.mixins.json b/neoforge/src/main/resources/craftingtweaks.neoforge.mixins.json similarity index 72% rename from forge/src/main/resources/craftingtweaks.mixins.json rename to neoforge/src/main/resources/craftingtweaks.neoforge.mixins.json index 90132d2..3872742 100644 --- a/forge/src/main/resources/craftingtweaks.mixins.json +++ b/neoforge/src/main/resources/craftingtweaks.neoforge.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "net.blay09.mods.craftingtweaks.mixin", + "package": "net.blay09.mods.craftingtweaks.neoforge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], 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/craftingtweaks.mixins.json b/shared/src/main/resources/craftingtweaks.mixins.json new file mode 100644 index 0000000..a18e522 --- /dev/null +++ b/shared/src/main/resources/craftingtweaks.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.blay09.mods.craftingtweaks.mixin", + "refmap": "${mod_id}.refmap.json", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + ], + "server": [ + ], + "injectors": { + "defaultRequire": 1 + } + } \ No newline at end of file diff --git a/shared/src/main/resources/craftingtweaks-icon.png b/shared/src/main/resources/craftingtweaks.png similarity index 100% rename from shared/src/main/resources/craftingtweaks-icon.png rename to shared/src/main/resources/craftingtweaks.png diff --git a/shared/src/main/resources/pack.mcmeta b/shared/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..ad94494 --- /dev/null +++ b/shared/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "${mod_name}", + "pack_format": ${pack_format_number} + } +} \ No newline at end of file