diff --git a/.editorconfig b/.editorconfig index 3faee52..d5d6957 100644 --- a/.editorconfig +++ b/.editorconfig @@ -460,7 +460,7 @@ ij_xml_block_comment_at_first_column = true ij_xml_keep_indents_on_empty_lines = false ij_xml_line_comment_at_first_column = true -[{*.yml,*.yaml}] +[{*.yml,*.yaml,*.toml}] indent_size = 2 ij_yaml_keep_indents_on_empty_lines = false ij_yaml_keep_line_breaks = true diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index ec8ae35..4a4f98d 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -1,4 +1,4 @@ -# Builds the project on Linux and Windows as a partial defence against bad commits +# Builds the project on Linux and Windows as a partial defense against bad commits name: Check Build on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 585420e..2453a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,12 @@ -# Builds the project and publishes the artifacts to GitHub and Modrinth -# Requires GITHUB_TOKEN to have write permissions; if not, replace it with a custom token -# Requires a Modrinth PAT MODRINTH_TOKEN +# Builds the project and publishes the artifacts to GitHub, Modrinth and CurseForge +# Modrinth publishing requires a Modrinth PAT MODRINTH_TOKEN +# Will skip without error if not present +# CurseForge publishing requires a CurseForge API token CURSEFORGE_TOKEN +# Will skip without error if not present name: Release -on: [workflow_dispatch] +on: + workflow_dispatch: permissions: contents: write diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 471d028..7d3c291 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -1,4 +1,4 @@ -# Synchronizes the repo's labels with labels.yml +# Synchronizes the repo's labels with a centralized labels.yml # Requires GITHUB_TOKEN to have write permissions; if not, replace it with a custom token name: Sync Labels diff --git a/.gitignore b/.gitignore index 6f56452..4ecc163 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ run/ runs/ out/ classes/ +.eclipse/ # IDEA .idea/ diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..aa84df6 --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +Copyright ${year} ${owner_name} + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md index 8f56cc9..25c951c 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ Copy, insert and erase text from signs using a simple GUI. - - + +
diff --git a/assets/images/showcase/demo_01.png b/assets/images/demo_01.png similarity index 100% rename from assets/images/showcase/demo_01.png rename to assets/images/demo_01.png diff --git a/assets/images/showcase/demo_02.png b/assets/images/demo_02.png similarity index 100% rename from assets/images/showcase/demo_02.png rename to assets/images/demo_02.png diff --git a/build.gradle b/build.gradle index f7f4b13..4ecdfd6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,121 +1,40 @@ plugins { - id("java") - id("java-library") - id("idea") - id("maven-publish") - id("org.jetbrains.gradle.plugin.idea-ext") version("${ideaext_version}") // Required for NeoGradle + id("fabric-loom") version("${loom_version}") apply(false) + id("net.neoforged.moddev") version("${moddev_version}") apply(false) id("com.modrinth.minotaur") version("${minotaur_version}") id("net.darkhax.curseforgegradle") version("${curseforgegradle_version}") id("com.github.breadmoirai.github-release") version("${githubrelease_version}") id("org.ajoberstar.grgit.service") version("${grgitservice_version}") + id("org.cadixdev.licenser") version("${licenser_version}") } subprojects { version = mod_version group = mod_group - apply(plugin: "java") - apply(plugin: "java-library") - apply(plugin: "idea") - apply(plugin: "maven-publish") + // License headers + apply(plugin: "org.cadixdev.licenser") + license { + // This can be done in multiloader-common.gradle but only if the + // "matching" method is not used (throws a pile of weird errors). + // Also, NeoForge's update of the plugin can't handle matching at all. + include("**/*.java") // Java files only + header = rootProject.file("NOTICE") + properties { + project_name = mod_name + owner_name = mod_owner + year = java.time.LocalDate.now().getYear().toString() + } + } - if (project.name != "common") { + // Publishing + if (name != "common") { apply(plugin: "com.modrinth.minotaur") + apply(plugin: "net.darkhax.curseforgegradle") apply(plugin: "com.github.breadmoirai.github-release") apply(plugin: "org.ajoberstar.grgit.service") - } - - java.toolchain.languageVersion = JavaLanguageVersion.of(Integer.valueOf(java_version)) - - jar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_name}" } - } - manifest { - attributes([ - "Specification-Title" : mod_name, - "Specification-Vendor" : mod_owner, - "Specification-Version" : project.jar.archiveVersion, - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : mod_owner, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - "Timestamp" : System.currentTimeMillis(), - "Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", - "Built-On-Minecraft" : minecraft_version - ]) - } - } - java.withSourcesJar() - sourcesJar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_name}" } - } - } - - repositories { - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - } - maven { - name = "Shedaniel" - url = "https://maven.shedaniel.me/" - } - } - - tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.getRelease().set(Integer.valueOf(java_version)) - } - - processResources { - def expandProps = [ - "project_group": project.group, - "mod_version": mod_version, - "mod_group": mod_group, - "mod_id": mod_id, - "mod_name": mod_name, - "mod_description": mod_description, - "mod_icon": "assets/" + mod_id + "/icon.png", - "mod_owner": mod_owner, - "mod_authors_list": asJsonList(mod_authors), - "mod_contributors_list": asJsonList(mod_contributors), - "mod_authors_string": mod_authors.replace(",", ", "), - "mod_contributors_string": mod_contributors.replace(",", ", "), - "mod_license": mod_license, - "mod_environment": mod_environment, - "java_version": java_version, - "java_versions_fabric_list": asJsonList(java_versions_fabric), - "java_versions_neoforge": java_versions_neoforge, - "minecraft_version": minecraft_version, - "minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric), - "minecraft_versions_neoforge": minecraft_versions_neoforge, - "fabric_loader_version": fabric_loader_version, - "fabric_loader_versions_list": asJsonList(fabric_loader_versions), - "fabric_api_version": fabric_api_version, - "fabric_api_versions_list": asJsonList(fabric_api_versions), - "neoforge_loader_versions": neoforge_loader_versions, - "neoforge_version": neoforge_version, - "neoforge_versions": neoforge_versions, - "homepage_url": homepage_url, - "sources_url": sources_url, - "issues_url": issues_url, - "contact_url": contact_url - ] - - filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json", "assets/"+mod_id+"/lang/*.json"]) { - expand expandProps - } - inputs.properties(expandProps) - } - - tasks.withType(GenerateModuleMetadata).configureEach { - enabled = false - } - afterEvaluate { - if (name != "common") { + afterEvaluate { modrinth { token = System.getenv().MODRINTH_TOKEN ? System.getenv().MODRINTH_TOKEN : "empty" projectId = modrinth_id @@ -151,8 +70,7 @@ subprojects { tasks.modrinthSyncBody.onlyIf { System.getenv().MODRINTH_TOKEN } task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { - apiToken = System.getenv().CURSEFORGE_TOKEN ? System.getenv().CURSEFORGE_TOKEN : "" - if (apiToken.isBlank()) return + apiToken = System.getenv().CURSEFORGE_TOKEN ? System.getenv().CURSEFORGE_TOKEN : "empty" disableVersionDetection() String module = project.name @@ -161,7 +79,7 @@ subprojects { file.displayName = "v${mod_version}-${capsLoader(module)}-${minecraft_version}" file.releaseType = release_type file.changelog = rootProject.file("changelog.md").text - file.changelogType = 'markdown' + file.changelogType = "markdown" project.property("release_mod_loaders_${module}").split(",").each { String id -> file.addModLoader(id) } @@ -207,10 +125,6 @@ subprojects { } } -static asJsonList(String versions) { - return versions.split(",").collect { "\"$it\"" }.join(',') -} - static String capsLoader(String loader) { switch(loader) { case "fabric": return "Fabric" diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..fbd5c69 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,3 @@ +plugins { + id("groovy-gradle-plugin") +} diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle new file mode 100644 index 0000000..bc455c0 --- /dev/null +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -0,0 +1,139 @@ +plugins { + id("java-library") + id("maven-publish") +} + +base { + archivesName = "${mod_id}-${project.name}" +} + +java { + toolchain.languageVersion = JavaLanguageVersion.of(java_version) + withSourcesJar() +// withJavadocJar() // Also uncomment javadocElements in capabilities below +} + +repositories { + mavenCentral() + // https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository + exclusiveContent { + forRepository { + maven { + name = "Sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + } + filter { includeGroupAndSubgroups("org.spongepowered") } + } + exclusiveContent { + forRepositories( + maven { + name = "ParchmentMC" + url = "https://maven.parchmentmc.org" + }, + maven { + name = "NeoForge" + url = "https://maven.neoforged.net/releases" + } + ) + filter { includeGroup("org.parchmentmc.data") } + } +} + +// Declare capabilities on the outgoing configurations. +// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component +["apiElements", "runtimeElements", "sourcesElements", /*"javadocElements"*/].each { variant -> + configurations."$variant".outgoing { + capability("$group:${base.archivesName.get()}:$version") + capability("$group:$mod_id-${project.name}-${minecraft_version}:$version") + capability("$group:$mod_id:$version") + } + publishing.publications.configureEach { + suppressPomMetadataWarningsFor(variant) + } +} + +sourcesJar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } +} + +jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } + + manifest { + attributes([ + "Specification-Title" : mod_name, + "Specification-Vendor" : mod_owner, + "Specification-Version" : project.jar.archiveVersion, + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : mod_owner, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "Timestamp" : System.currentTimeMillis(), + "Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + "Built-On-Minecraft" : minecraft_version + ]) + } +} + +processResources { + def expandProps = [ + // Mod info + "mod_version": mod_version, + "mod_group": mod_group, + "mod_id": mod_id, + "mod_name": mod_name, + "mod_description": mod_description, + "mod_icon": "assets/" + mod_id + "/icon.png", + "mod_owner": mod_owner, + "mod_authors_list": asJsonList(mod_authors), + "mod_contributors_list": asJsonList(mod_contributors), + "mod_authors_string": mod_authors.replace(",", ", "), + "mod_contributors_string": mod_contributors.replace(",", ", "), + "mod_license": mod_license, + // Links + "homepage_url": homepage_url, + "sources_url": sources_url, + "issues_url": issues_url, + "contact_url": contact_url, + // Java + "java_version": java_version, + "java_versions_fabric_list": asJsonList(java_versions_fabric), + "java_versions_neoforge": java_versions_neoforge, + // Minecraft + "minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric), + "minecraft_versions_neoforge": minecraft_versions_neoforge, + // Fabric + "fabric_loader_versions_list": asJsonList(fabric_loader_versions), + "fabric_api_versions_list": asJsonList(fabric_api_versions), + // NeoForge + "neoforge_loader_versions": neoforge_loader_versions, + "neoforge_versions": neoforge_versions, + ] + filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json"]) { + expand expandProps + } + inputs.properties(expandProps) +} + +publishing { + publications { + register("mavenJava", MavenPublication) { + artifactId base.archivesName.get() + from components.java + } + } + repositories { + maven { + url System.getenv("local_maven_url") + } + } +} + +static asJsonList(String versions) { + return versions.split(",").collect { "\"$it\"" }.join(",") +} diff --git a/buildSrc/src/main/groovy/multiloader-loader.gradle b/buildSrc/src/main/groovy/multiloader-loader.gradle new file mode 100644 index 0000000..fab1110 --- /dev/null +++ b/buildSrc/src/main/groovy/multiloader-loader.gradle @@ -0,0 +1,44 @@ +plugins { + id("multiloader-common") +} + +configurations { + commonJava{ + canBeResolved = true + } + commonResources{ + canBeResolved = true + } +} + +dependencies { + compileOnly(project(":common")) { + capabilities { + requireCapability "$group:$mod_id" + } + } + commonJava project(path: ":common", configuration: "commonJava") + commonResources project(path: ":common", configuration: "commonResources") +} + +tasks.named("compileJava", JavaCompile) { + dependsOn(configurations.commonJava) + source(configurations.commonJava) +} + +processResources { + dependsOn(configurations.commonResources) + from(configurations.commonResources) +} + +tasks.named("javadoc", Javadoc).configure { + dependsOn(configurations.commonJava) + source(configurations.commonJava) +} + +tasks.named("sourcesJar", Jar) { + dependsOn(configurations.commonJava) + from(configurations.commonJava) + dependsOn(configurations.commonResources) + from(configurations.commonResources) +} diff --git a/common/build.gradle b/common/build.gradle index 7fc6bb2..033811b 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,21 +1,38 @@ plugins { - id("org.spongepowered.gradle.vanilla") version("${vanillagradle_version}") -} - -base { - archivesName = "${mod_name}-Common-${minecraft_version}" + id("multiloader-common") + id("net.neoforged.moddev") } dependencies { compileOnly("org.spongepowered:mixin:${mixin_version}") - compileOnly("io.github.llamalad7:mixinextras-common:${mixinextras_version}") annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}") } -minecraft { - version(minecraft_version) - if (file("src/main/resources/${mod_id}.accesswidener").exists()) { - accessWideners(file("src/main/resources/${mod_id}.accesswidener")) +neoForge { + version = neoforge_version // Shut up + neoFormVersion = neoform_version + // Automatically enable AccessTransformers if the file exists + def at = file("src/main/resources/META-INF/accesstransformer.cfg") + if (at.exists()) accessTransformers.from(at.absolutePath) + parchment { + minecraftVersion = parchment_minecraft_version + mappingsVersion = parchment_version } } + +configurations { + commonJava { + canBeResolved = false + canBeConsumed = true + } + commonResources { + canBeResolved = false + canBeConsumed = true + } +} + +artifacts { + commonJava sourceSets.main.java.sourceDirectories.singleFile + commonResources sourceSets.main.resources.sourceDirectories.singleFile +} diff --git a/common/src/main/java/dev/terminalmc/signcopy/SignCopy.java b/common/src/main/java/dev/terminalmc/signcopy/SignCopy.java index a413466..0913ffd 100644 --- a/common/src/main/java/dev/terminalmc/signcopy/SignCopy.java +++ b/common/src/main/java/dev/terminalmc/signcopy/SignCopy.java @@ -1,6 +1,17 @@ /* - * Copyright 2023, 2024 NotRyken - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dev.terminalmc.signcopy; diff --git a/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinAbstractSignEditScreen.java b/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinAbstractSignEditScreen.java index 48465eb..19c9a47 100644 --- a/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinAbstractSignEditScreen.java +++ b/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinAbstractSignEditScreen.java @@ -1,6 +1,17 @@ /* - * Copyright 2023, 2024 NotRyken - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dev.terminalmc.signcopy.mixin; diff --git a/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinSignBlock.java b/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinSignBlock.java index 52aece8..0e1eaeb 100644 --- a/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinSignBlock.java +++ b/common/src/main/java/dev/terminalmc/signcopy/mixin/MixinSignBlock.java @@ -1,6 +1,17 @@ /* - * Copyright 2023, 2024 NotRyken - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dev.terminalmc.signcopy.mixin; diff --git a/common/src/main/java/dev/terminalmc/signcopy/util/ModLogger.java b/common/src/main/java/dev/terminalmc/signcopy/util/ModLogger.java index 8dfbfa3..d3091cf 100644 --- a/common/src/main/java/dev/terminalmc/signcopy/util/ModLogger.java +++ b/common/src/main/java/dev/terminalmc/signcopy/util/ModLogger.java @@ -1,3 +1,19 @@ +/* + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package dev.terminalmc.signcopy.util; import org.apache.logging.log4j.Level; diff --git a/common/src/main/resources/META-INF/accesstransformer.cfg b/common/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..184db24 --- /dev/null +++ b/common/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1 @@ +# https://docs.neoforged.net/docs/advanced/accesstransformers diff --git a/common/src/main/resources/signcopy.accesswidener b/common/src/main/resources/signcopy.accesswidener index dfde67a..450cf96 100644 --- a/common/src/main/resources/signcopy.accesswidener +++ b/common/src/main/resources/signcopy.accesswidener @@ -1 +1,2 @@ -accessWidener v1 named \ No newline at end of file +accessWidener v2 named +# https://fabricmc.net/wiki/tutorial:accesswideners diff --git a/common/src/main/resources/signcopy.mixins.json b/common/src/main/resources/signcopy.mixins.json index 8e1b197..5c9746e 100644 --- a/common/src/main/resources/signcopy.mixins.json +++ b/common/src/main/resources/signcopy.mixins.json @@ -5,9 +5,9 @@ "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_${java_version}", "mixins": [ - "MixinSignBlock" ], "client": [ + "MixinSignBlock", "MixinAbstractSignEditScreen" ], "server": [ diff --git a/fabric/build.gradle b/fabric/build.gradle index c69495f..7d53e57 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,37 +1,37 @@ plugins { - id("fabric-loom") version("${loom_version}") -} - -base { - archivesName = "${mod_name}-Fabric-${minecraft_version}" + id("multiloader-loader") + id("fabric-loom") } dependencies { - compileOnly(project(":common")) minecraft("com.mojang:minecraft:${minecraft_version}") - mappings(loom.officialMojangMappings()) - - compileOnly("io.github.llamalad7:mixinextras-fabric:${mixinextras_version}") - annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixinextras_version}") + mappings loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-${parchment_minecraft_version}:${parchment_version}@zip") + } modImplementation("net.fabricmc:fabric-loader:${fabric_loader_version}") + modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") } loom { - if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) { - accessWidenerPath = project(":common").file("src/main/resources/${mod_id}.accesswidener") - } + def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener") + if (aw.exists()) accessWidenerPath.set(aw) mixin { - defaultRefmapName = "${mod_id}.refmap.json" + defaultRefmapName.set("${mod_id}.refmap.json") + } + runs { + client { + client() + setConfigName("Fabric Client") + ideConfigGenerated(true) + runDir("runs/client") + } + server { + server() + setConfigName("Fabric Server") + ideConfigGenerated(true) + runDir("runs/server") + } } -} - -tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.allSource) -} -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} -processResources { - from project(":common").sourceSets.main.resources } diff --git a/fabric/src/main/java/dev/terminalmc/signcopy/SignCopyFabric.java b/fabric/src/main/java/dev/terminalmc/signcopy/SignCopyFabric.java index 55c7fc9..b304148 100644 --- a/fabric/src/main/java/dev/terminalmc/signcopy/SignCopyFabric.java +++ b/fabric/src/main/java/dev/terminalmc/signcopy/SignCopyFabric.java @@ -1,6 +1,17 @@ /* - * Copyright 2023, 2024 NotRyken - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dev.terminalmc.signcopy; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index a7dda25..1708a0c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -9,14 +9,15 @@ "contributors": [$mod_contributors_list], "license": "${mod_license}", - "environment": "${mod_environment}", + "environment": "client", "provides": [], "entrypoints": { "main": [], "client": ["${mod_group}.${mod_id}.${mod_name}Fabric"], - "server": [] + "server": [], + "modmenu": ["${mod_group}.${mod_id}.gui.screen.ModMenuIntegration"] }, "mixins": [ @@ -29,7 +30,8 @@ "depends": { "java": [$java_versions_fabric_list], "minecraft": [$minecraft_versions_fabric_list], - "fabricloader": [$fabric_loader_versions_list] + "fabricloader": [$fabric_loader_versions_list], + "fabric-api": [$fabric_api_versions_list] }, "recommends": {}, diff --git a/gradle.properties b/gradle.properties index f7072b5..caa76d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ # Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html # Project -mod_version=2.0.0 +mod_version=2.0.1+1.21 mod_group=dev.terminalmc mod_id=signcopy mod_name=SignCopy @@ -12,8 +12,11 @@ mod_authors=NotRyken mod_contributors= mod_license=Apache-2.0 -# Environment -mod_environment=client +# Links +homepage_url=https://modrinth.com/mod/cK4nxndh +sources_url=https://github.com/TerminalMC/SignCopy +issues_url=https://github.com/TerminalMC/SignCopy/issues +contact_url=https://terminalmc.dev # Java java_version=21 @@ -25,22 +28,22 @@ minecraft_version=1.21 minecraft_versions_fabric=>1.20.6 <1.22 minecraft_versions_neoforge=(1.20.6, 1.22) -# Fabric https://fabricmc.net/develop/ -fabric_loader_version=0.15.11 +# Parchment https://parchmentmc.org/docs/getting-started#choose-a-version +parchment_minecraft_version=1.21 +parchment_version=2024.07.28 + +# Fabric https://fabricmc.net/develop +fabric_loader_version=0.16.5 fabric_loader_versions=>=0.15.0 -fabric_api_version=0.100.1+1.21 +fabric_api_version=0.102.0+1.21 fabric_api_versions=* # NeoForge https://projects.neoforged.net/neoforged/neoforge neoforge_loader_versions=[1,) -neoforge_version=21.0.0-beta -neoforge_versions=(20.6, 22) - -# Links -homepage_url=https://modrinth.com/mod/cK4nxndh -sources_url=https://github.com/TerminalMC/SignCopy -issues_url=https://github.com/TerminalMC/SignCopy/issues -contact_url=https://terminalmc.dev +neoforge_version=21.0.167 +neoforge_versions=[21.0.143, 22) +# NeoForm https://projects.neoforged.net/neoforged/neoform +neoform_version=1.21-20240613.152323 # GitHub, Modrinth, CurseForge releases # Plural properties expect CSV lists @@ -52,34 +55,32 @@ curseforge_id=1049884 release_type=release # Fabric release_mod_loaders_fabric=fabric,quilt -release_game_versions_fabric=1.21 +release_game_versions_fabric=1.21,1.21.1 # NeoForge release_mod_loaders_neoforge=neoforge -release_game_versions_neoforge=1.21 +release_game_versions_neoforge=1.21,1.21.1 # Mixin https://mvnrepository.com/artifact/org.spongepowered/mixin -mixin_version=0.8.5 +mixin_version=0.8.7 # MixinExtras https://github.com/LlamaLad7/MixinExtras/releases -mixinextras_version=0.3.5 +mixinextras_version=0.4.1 # Plugins -# idea-ext https://plugins.gradle.org/plugin/org.jetbrains.gradle.plugin.idea-ext -ideaext_version=1.1.8 +# Fabric Loom https://mvnrepository.com/artifact/net.fabricmc/fabric-loom +loom_version=1.7.4 +# ModDev https://plugins.gradle.org/plugin/net.neoforged.moddev +moddev_version=1.0.19 # Minotaur https://plugins.gradle.org/plugin/com.modrinth.minotaur minotaur_version=2.8.7 # CurseForgeGradle https://plugins.gradle.org/plugin/net.darkhax.curseforgegradle -curseforgegradle_version=1.1.24 +curseforgegradle_version=1.1.25 # github-release https://plugins.gradle.org/plugin/com.github.breadmoirai.github-release githubrelease_version=2.5.2 # grgit-service https://github.com/ajoberstar/grgit/releases grgitservice_version=5.2.2 -# VanillaGradle https://plugins.gradle.org/plugin/org.spongepowered.gradle.vanilla -vanillagradle_version=0.2.1-SNAPSHOT -# Fabric Loom https://mvnrepository.com/artifact/net.fabricmc/fabric-loom -loom_version=1.6.11 -# NeoGradle https://maven.neoforged.net/#/releases/net/neoforged/gradle/userdev -userdev_version=7.0.142 +# licenser https://plugins.gradle.org/plugin/org.cadixdev.licenser +licenser_version=0.6.1 # Gradle -org.gradle.jvmargs=-Xmx3G +org.gradle.jvmargs=-Xmx4G org.gradle.daemon=false diff --git a/neoforge/build.gradle b/neoforge/build.gradle index de17372..1b53dc2 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,36 +1,41 @@ plugins { - id("net.neoforged.gradle.userdev") version("${userdev_version}") -} - -base { - archivesName = "${mod_name}-NeoForge-${minecraft_version}" + id("multiloader-loader") + id("net.neoforged.moddev") } dependencies { - compileOnly(project(":common")) - implementation("net.neoforged:neoforge:${neoforge_version}") - - compileOnly("io.github.llamalad7:mixinextras-neoforge:${mixinextras_version}") - annotationProcessor("io.github.llamalad7:mixinextras-neoforge:${mixinextras_version}") -} - -// Temporary workaround for a NeoGradle bug -tasks.named("test").configure { - enabled = false } -if (file("src/main/resources/META-INF/accesstransformer.cfg").exists()) { - minecraft.accessTransformers.file(file("src/main/resources/META-INF/accesstransformer.cfg")) +neoForge { + version = neoforge_version + // Automatically enable neoforge AccessTransformers if the file exists + def at = project(":common").file("src/main/resources/META-INF/accesstransformer.cfg") + if (at.exists()) accessTransformers.from(at.absolutePath) + parchment { + minecraftVersion = parchment_minecraft_version + mappingsVersion = parchment_version + } + runs { + configureEach { + systemProperty("neoforge.enabledGameTestNamespaces", "${mod_id}") + // Unify the run config names with fabric + ideName = "NeoForge ${it.name.capitalize()} (${project.path})" + } + client { + client() + } + data { + data() + } + server { + server() + } + } + mods { + "${mod_id}" { + sourceSet sourceSets.main + } + } } -Spec notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec - -tasks.withType(JavaCompile).matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.allSource) -} -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} -tasks.withType(ProcessResources).matching(notNeoTask).configureEach { - from project(":common").sourceSets.main.resources -} +sourceSets.main.resources { srcDir "src/generated/resources" } diff --git a/neoforge/src/main/java/dev/terminalmc/signcopy/SignCopyNeoForge.java b/neoforge/src/main/java/dev/terminalmc/signcopy/SignCopyNeoForge.java index 1601870..1205484 100644 --- a/neoforge/src/main/java/dev/terminalmc/signcopy/SignCopyNeoForge.java +++ b/neoforge/src/main/java/dev/terminalmc/signcopy/SignCopyNeoForge.java @@ -1,6 +1,17 @@ /* - * Copyright 2023, 2024 NotRyken - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 TerminalMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package dev.terminalmc.signcopy; diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 47aa01e..c4960ae 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -7,38 +7,38 @@ license="${mod_license}" issueTrackerURL="${issues_url}" #optional:none [[mods]] -modId="${mod_id}" -version="${mod_version}" #optional:"1" -displayName="${mod_name}" #optional:modId -description='''${mod_description}''' #optional:'''MISSING DESCRIPTION''' -logoFile="${mod_icon}" #optional:none -#logoBlur=false #optional:true -#updateJSONURL="" #optional:none -features={java_version="${java_versions_neoforge}"} #optional:none -#modproperties={} #optional:none -credits="${mod_contributors_string}" #optional:none -authors="${mod_authors_string}" #optional:none -displayURL="${homepage_url}" #optional: none -#displayTest="" #optional:"MATCH_VERSION" + modId="${mod_id}" + version="${mod_version}" #optional:"1" + displayName="${mod_name}" #optional:modId + description='''${mod_description}''' #optional:'''MISSING DESCRIPTION''' + logoFile="${mod_icon}" #optional:none + #logoBlur=false #optional:true + #updateJSONURL="" #optional:none + features={java_version="${java_versions_neoforge}"} #optional:none + #modproperties={} #optional:none + credits="${mod_contributors_string}" #optional:none + authors="${mod_authors_string}" #optional:none + displayURL="${homepage_url}" #optional: none + #displayTest="" #optional:"MATCH_VERSION" [[mixins]] -config="${mod_id}.mixins.json" + config="${mod_id}.mixins.json" [[mixins]] -config="${mod_id}.neoforge.mixins.json" + config="${mod_id}.neoforge.mixins.json" [[dependencies."${mod_id}"]] -modId="minecraft" -#type="" #optional:"required" #options:"required","optional","incompatible","discouraged" -#reason="" #optional:none -versionRange="${minecraft_versions_neoforge}" #optional:any -#ordering="" #optional:"NONE" #options:"BEFORE","AFTER" -#side="" #optional:"BOTH" #options:"CLIENT","SERVER","BOTH" -#referralUrl="" #optional:none + modId="minecraft" + #type="" #optional:"required" #options:"required","optional","incompatible","discouraged" + #reason="" #optional:none + versionRange="${minecraft_versions_neoforge}" #optional:any + #ordering="" #optional:"NONE" #options:"BEFORE","AFTER" + #side="" #optional:"BOTH" #options:"CLIENT","SERVER","BOTH" + #referralUrl="" #optional:none [[dependencies."${mod_id}"]] -modId="neoforge" -versionRange="${neoforge_versions}" -side="CLIENT" + modId="neoforge" + versionRange="${neoforge_versions}" + side="CLIENT" # https://docs.neoforged.net/docs/gettingstarted/modfiles/#modstoml -# https://docs.neoforged.net/docs/misc/updatechecker/ +# https://docs.neoforged.net/docs/misc/updatechecker diff --git a/settings.gradle b/settings.gradle index 8b076be..4a6d94e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,19 +1,36 @@ pluginManagement { repositories { - mavenLocal() - mavenCentral() gradlePluginPortal() - maven { - name = "Fabric" - url = "https://maven.fabricmc.net/" + mavenCentral() + exclusiveContent { + forRepository { + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net") + } + } + filter { + includeGroup("net.fabricmc") + includeGroup("fabric-loom") + } } - maven { - name = "NeoForge" - url = "https://maven.neoforged.net/releases/" + exclusiveContent { + forRepository { + maven { + name = "Sponge" + url = uri("https://repo.spongepowered.org/repository/maven-public") + } + } + filter { includeGroupAndSubgroups("org.spongepowered") } } - maven { - name = "Sponge" - url = "https://repo.spongepowered.org/repository/maven-public/" + exclusiveContent { + forRepositories( + maven { + name = "NeoForge" + url = "https://maven.neoforged.net/releases" + } + ) + filter { includeGroupAndSubgroups("net.neoforged.licenser") } } } } @@ -23,7 +40,6 @@ plugins { id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0" } -// This should match the folder name of the project, else IDEA may complain (https://youtrack.jetbrains.com/issue/IDEA-317606) rootProject.name = "SignCopy" include("common") include("fabric")