From 463c94e3c4ea55149e15adb90870e711970acc8d Mon Sep 17 00:00:00 2001 From: celeste Date: Wed, 11 Sep 2024 12:40:52 -0600 Subject: [PATCH] migrate to stonecutter, relicense under zlib --- .gitattributes | 9 ++ .github/workflows/build.yml | 11 +- CHANGELOG.md | 7 + LICENSE | 136 ++---------------- README.md | 25 ++-- build.gradle | 78 ---------- build.gradle.kts | 102 +++++++++++++ gradle.properties | 34 +++-- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 20 +-- settings.gradle | 10 -- settings.gradle.kts | 27 ++++ .../toggletogglesprint/Config.java | 12 +- .../mixins/KeyBindingMixin.java | 10 +- .../toggle-toggle-sprint/lang/en_us.json | 13 +- src/main/resources/fabric.mod.json | 7 +- stonecutter.gradle.kts | 24 ++++ versions/1.19.4/gradle.properties | 10 ++ versions/1.20.2/gradle.properties | 7 + 19 files changed, 266 insertions(+), 278 deletions(-) create mode 100644 .gitattributes delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts create mode 100644 stonecutter.gradle.kts create mode 100644 versions/1.19.4/gradle.properties create mode 100644 versions/1.20.2/gradle.properties diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..097f9f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5adf394..68f71a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,7 @@ jobs: strategy: matrix: # Use these Java versions - java: [ - 17, # Current Java LTS & minimum supported by Minecraft - 21, # Current Java LTS - ] + java: [21] # and run on both Linux and Windows os: [ubuntu-22.04, windows-2022] runs-on: ${{ matrix.os }} @@ -22,7 +19,7 @@ jobs: - name: checkout repository uses: actions/checkout@v4 - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: setup jdk ${{ matrix.java }} uses: actions/setup-java@v4 with: @@ -32,10 +29,10 @@ jobs: if: ${{ runner.os != 'Windows' }} run: chmod +x ./gradlew - name: build - run: ./gradlew build + run: ./gradlew chiseledBuild - name: capture build artifacts if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bcdd1f1..6f1bfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Changed + +- Changed the mod's build process making supporting multiple versions much easier +- Relicensed under the [zlib license](LICENSE) + ## 1.1 - 2024-02-01 ### Added diff --git a/LICENSE b/LICENSE index 1625c17..480c61e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,121 +1,15 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. \ No newline at end of file +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/README.md b/README.md index 81eb232..88067d2 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,22 @@ [![Requires Fabric API](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/requires/fabric-api_vector.svg)](https://modrinth.com/mod/fabric-api) [![Available on Modrinth](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/modrinth_vector.svg)](https://modrinth.com/mod/toggle-toggle-sprint) -This is a Fabric mod for Minecraft adding toggle-sprint/sneak keybinds, making use of the existing Toggle options -in the Controls menu, ensuring it also remains as anti-cheat friendly as possible. +This is a Fabric mod adding Toggle Sprint and Toggle Sneak keybinds in modern versions of Minecraft, making use of the +existing Toggle options in the Controls menu, ensuring it also remains as anti-cheat friendly as possible. -This also includes a fix for preventing the game from resetting your toggle sprint upon death. +This also includes a fix for preventing the game from resetting your toggle sprint upon death (only applicable for 1.20.1+). If both [Mod Menu] and [YACL] are installed, this mod also contains a few configuration options that can be modified in-game. ## How is this any different from other mods? -This is primarily designed as a toggle-sprint mod designed for modern versions of Minecraft, using the relevant features -already present in the base game. +I originally designed this to replace [Toggle Sneak & Sprint], which instead of doing the sensible thing of making the +game think that you're holding the Sprint key, it instead simply forces you to *always* sprint *(even when it'd normally +be impossible to do so!)*, making it trivially easy to be flagged (and subsequently banned) by a server's anti-cheat. -Namely, I designed this to replace [Toggle Sneak & Sprint], as instead of simply telling the game that you're -holding the sprint key, it instead simply forces you to always be sprinting *(even when it'd normally be impossible -to do so in vanilla!)*, making it trivially easy to be flagged (and subsequently banned) by a server's anti-cheat. - -Instead, as this mod simply reuses the existing Toggle option in the Controls menu, this ensures that it remains -as close to the vanilla sprinting behavior as possible, avoiding anti-cheats getting angry in the process. - -## Modpacks? - -Go for it. I'd prefer that the download remains within the Modrinth ecosystem, but as this mod is licensed under the -[CC-0], you're free to redistribute it however you see fit (but I'd still appreciate credit where possible). +Instead, this mod simply re-uses the existing Toggle control logic, ensuring that it remains as anti-cheat friendly as +possible by simply deferring the actual sprinting logic to the base game. [YACL]: https://modrinth.com/mod/yacl [Mod Menu]: https://modrinth.com/mod/modmenu [Toggle Sneak & Sprint]: https://modrinth.com/mod/toggle-sneak-sprint -[CC-0]: https://github.com/celestialfault/toggle-toggle-sprint/blob/main/LICENSE diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 5b3aac5..0000000 --- a/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -plugins { - id 'fabric-loom' version '1.4-SNAPSHOT' - id 'maven-publish' -} - -version = "${project.mod_version}+${project.minecraft_version}" -group = project.maven_group - -base { - archivesName = project.archives_base_name -} - -repositories { - maven { url = 'https://maven.isxander.dev/releases'} - maven { url = 'https://maven.terraformersmc.com/' } -} - -dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - modImplementation fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version) - modImplementation fabricApi.module("fabric-key-binding-api-v1", project.fabric_version) - modRuntimeOnly fabricApi.module("fabric-resource-loader-v0", project.fabric_version) - - modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" - modImplementation("dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}") { - // yacl 3.2.1 for 1.20.2 has dependencies that gradle can't resolve, causing the build to fail, - // and I don't really want to depend on a beta version just to fix this; these don't matter for our use - // case either way, so we can safely tell gradle to just ignore them. - // see https://github.com/isXander/YetAnotherConfigLib/issues/111 - exclude(group: "org.quiltmc.parsers") - exclude(group: "com.twelvemonkeys.common") - exclude(group: "com.twelvemonkeys.imageio") - } -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} - -tasks.withType(JavaCompile).configureEach { - it.options.release = 17 -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -jar { - from("LICENSE") { - rename { "${it}_${project.base.archivesName.get()}"} - } -} - -// configure the maven publication -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..f82a8cf --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,102 @@ +plugins { + id("fabric-loom") +} + +class ModData { + val id = property("mod.id").toString() + val name = property("mod.name").toString() + val version = property("mod.version").toString() + val group = property("mod.group").toString() +} + +class ModDependencies { + operator fun get(name: String) = property("deps.$name").toString() +} + +val mod = ModData() +val deps = ModDependencies() +val mcVersion = stonecutter.current.version +val mcDep = property("mod.mc_dep").toString() +val loaderDep = property("mod.loader_dep").toString() + +version = "${mod.version}+$mcVersion" +group = mod.group +base { archivesName.set(mod.id) } + +repositories { + maven("https://maven.isxander.dev/releases") + maven("https://maven.terraformersmc.com/") +} + +dependencies { + fun fapi(module: String) = fabricApi.module(module, deps["fabric_api"]) + + minecraft("com.mojang:minecraft:${mcVersion}") + mappings("net.fabricmc:yarn:${mcVersion}+build.${deps["yarn_build"]}:v2") + modImplementation("net.fabricmc:fabric-loader:${deps["fabric_loader"]}") + + modImplementation(fapi("fabric-lifecycle-events-v1")) + modImplementation(fapi("fabric-key-binding-api-v1")) + modRuntimeOnly(fapi("fabric-resource-loader-v0")) + vineflowerDecompilerClasspath("org.vineflower:vineflower:1.10.1") + + modImplementation("com.terraformersmc:modmenu:${deps["modmenu"]}") + + // note: the name for this was changed post-1.20.2; this doesn't matter to us yet though, as the 1.20.2 builds + // works fine on newer versions (as of the time of writing, at least). + modImplementation("dev.isxander.yacl:yet-another-config-lib-fabric:${deps["yacl"]}+${mcVersion}") { + // work around dependency issues with yacl 3.2.1 on 1.20.2 by simply telling gradle + // to ignore dependencies that cause it to explode during dependency resolution; we don't use + // any features that these dependencies are used for, so we can safely just blanket exclude these + // across all versions. + // see https://github.com/isXander/YetAnotherConfigLib/issues/111 + exclude(group = "org.quiltmc.parsers") + exclude(group = "com.twelvemonkeys.common") + exclude(group = "com.twelvemonkeys.imageio") + } +} + +loom { + decompilers { + get("vineflower").apply { // Adds names to lambdas - useful for mixins + options.put("mark-corresponding-synthetics", "1") + } + } + + runConfigs.all { + ideConfigGenerated(stonecutter.current.isActive) + vmArgs("-Dmixin.debug.export=true") + runDir = "../../run" + } +} + +java { + withSourcesJar() + val java = if (stonecutter.compare(mcVersion, "1.20.6") >= 0) JavaVersion.VERSION_21 else JavaVersion.VERSION_17 + targetCompatibility = java + sourceCompatibility = java +} + +tasks.processResources { + inputs.property("id", mod.id) + inputs.property("name", mod.name) + inputs.property("version", mod.version) + inputs.property("mcdep", mcDep) + + val map = mapOf( + "id" to mod.id, + "name" to mod.name, + "version" to mod.version, + "mcdep" to mcDep, + "loaderdep" to loaderDep + ) + + filesMatching("fabric.mod.json") { expand(map) } +} + +tasks.register("buildAndCollect") { + group = "build" + from(tasks.remapJar.get().archiveFile) + into(rootProject.layout.buildDirectory.file("libs/${mod.version}")) + dependsOn("build") +} diff --git a/gradle.properties b/gradle.properties index 5e9fb4c..5b09310 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,26 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true -# Fabric Properties -# check these on https://fabricmc.net/develop -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 -loader_version=0.15.3 +# Mod properties +mod.version=1.1.1 +mod.group=me.celestialfault +mod.id=toggle-toggle-sprint +mod.name=Toggle Toggle Sprint -# Mod Properties -mod_version=1.1 -maven_group=me.celestialfault.toggletogglesprint -archives_base_name=toggle-toggle-sprint +# for fabric.mod.json +mod.mc_dep=[VERSIONED] +mod.loader_dep=>=0.15.7 +# for release title +mod.mc_title=[VERSIONED] -# Dependencies -fabric_version=0.91.2+1.20.2 -yacl_version=3.2.1+1.20.2 -modmenu_version=8.0.0 +# Global dependencies +deps.fabric_loader=0.16.3 + +# Versioned dependencies +deps.yarn_build=[VERSIONED] +deps.fabric_api=[VERSIONED] +deps.yacl=[VERSIONED] +deps.modmenu=[VERSIONED] + +# Publishing +publish.modrinth=... diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 75c4d72..0000000 --- a/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -pluginManagement { - repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() - gradlePluginPortal() - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..dbca367 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,27 @@ +import dev.kikugie.stonecutter.StonecutterSettings + +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + maven("https://maven.fabricmc.net/") + maven("https://maven.kikugie.dev/releases") + } +} + +plugins { + id("dev.kikugie.stonecutter") version "0.4" +} + +extensions.configure { + kotlinController = true + centralScript = "build.gradle.kts" + + shared { + versions("1.19.4", "1.20.2") + vcsVersion = "1.20.2" + } + create(rootProject) +} + +rootProject.name = "toggle-toggle-sprint" diff --git a/src/main/java/me/celestialfault/toggletogglesprint/Config.java b/src/main/java/me/celestialfault/toggletogglesprint/Config.java index 8f1ecda..80fdbff 100644 --- a/src/main/java/me/celestialfault/toggletogglesprint/Config.java +++ b/src/main/java/me/celestialfault/toggletogglesprint/Config.java @@ -94,7 +94,9 @@ public Screen getConfigScreen(Screen parent) { .title(Text.translatable("toggle-toggle-sprint.name")) .category(ConfigCategory.createBuilder() .name(Text.translatable("toggle-toggle-sprint.config")) + //? if >=1.20.1 { .group(buildGeneral()) + //? } .group(buildSprint()) .group(buildSneak()) .build()) @@ -103,6 +105,7 @@ public Screen getConfigScreen(Screen parent) { .generateScreen(parent); } + //? if >=1.20.1 { private OptionGroup buildGeneral() { return OptionGroup.createBuilder() .name(Text.translatable("toggle-toggle-sprint.general")) @@ -111,14 +114,13 @@ private OptionGroup buildGeneral() { .description(OptionDescription.of( Text.translatable("toggle-toggle-sprint.sprintOnDeath.description.line1") .append("\n\n") - .append(Text.translatable("toggle-toggle-sprint.sprintOnDeath.description.line2")) - .append("\n\n") - .append(Text.translatable("toggle-toggle-sprint.sprintOnDeath.description.line3")))) + .append(Text.translatable("toggle-toggle-sprint.sprintOnDeath.description.line2")))) .binding(true, () -> keepSprintingOnDeath, value -> this.keepSprintingOnDeath = value) .controller(TickBoxControllerBuilderImpl::new) .build()) .build(); } + //? } private OptionGroup buildSprint() { //noinspection UnstableApiUsage @@ -138,7 +140,7 @@ private OptionGroup buildSprint() { .binding(ToggleState.UNCHANGED, () -> defaultSprintState, value -> this.defaultSprintState = value) .customController(option -> EnumControllerBuilder.create(option) .enumClass(ToggleState.class) - .formatValue(key -> Text.translatable("toggle-toggle-sprint.state." + key.toString().toLowerCase())) + ./*?if yacl: >3.2.1*/formatValue/*? else*//*valueFormatter*/(key -> Text.translatable("toggle-toggle-sprint.state." + key.toString().toLowerCase())) .build()) .build()) .option(Option.createBuilder() @@ -171,7 +173,7 @@ private OptionGroup buildSneak() { .binding(ToggleState.UNCHANGED, () -> defaultSneakState, value -> this.defaultSneakState = value) .customController(option -> EnumControllerBuilder.create(option) .enumClass(ToggleState.class) - .formatValue(key -> Text.translatable("toggle-toggle-sprint.state." + key.toString().toLowerCase())) + ./*?if yacl: >3.2.1*/formatValue/*? else*//*valueFormatter*/(key -> Text.translatable("toggle-toggle-sprint.state." + key.toString().toLowerCase())) .build()) .build()) .option(Option.createBuilder() diff --git a/src/main/java/me/celestialfault/toggletogglesprint/mixins/KeyBindingMixin.java b/src/main/java/me/celestialfault/toggletogglesprint/mixins/KeyBindingMixin.java index b4cdd27..765c13c 100644 --- a/src/main/java/me/celestialfault/toggletogglesprint/mixins/KeyBindingMixin.java +++ b/src/main/java/me/celestialfault/toggletogglesprint/mixins/KeyBindingMixin.java @@ -1,6 +1,6 @@ package me.celestialfault.toggletogglesprint.mixins; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import me.celestialfault.toggletogglesprint.Config; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; @@ -9,16 +9,16 @@ import org.spongepowered.asm.mixin.injection.At; /** - * Mixin class to cancel untoggling sprint in an actually sensible way, unlike every other mod that does this on Modrinth.
+ * Mixin class to cancel untoggling sprint in an actually sensible way, unlike nearly every other mod that does this on Modrinth.
* (no, patrick, using an {@code @Inject} as an {@code @Overwrite} for {@code ClientPlayerEntity#requestRespawn()} is not sensible.) */ @Mixin(KeyBinding.class) -public abstract class KeyBindingMixin { +abstract class KeyBindingMixin { + //? if >=1.20.1 { @WrapWithCondition(method = "untoggleStickyKeys", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/StickyKeyBinding;untoggle()V")) private static boolean keepSprintOnDeath(StickyKeyBinding instance) { // Only cancel untoggling the sprint key, but don't modify this behavior for other keys - // Note: The != usage here is intentional, as we explicitly want to compare the instance, - // whereas using .equals() compares the bound key, which isn't the behavior we want. return instance != MinecraftClient.getInstance().options.sprintKey || !Config.INSTANCE.keepSprintingOnDeath; } + //? } } diff --git a/src/main/resources/assets/toggle-toggle-sprint/lang/en_us.json b/src/main/resources/assets/toggle-toggle-sprint/lang/en_us.json index 3df2745..d514d46 100644 --- a/src/main/resources/assets/toggle-toggle-sprint/lang/en_us.json +++ b/src/main/resources/assets/toggle-toggle-sprint/lang/en_us.json @@ -16,27 +16,26 @@ "toggle-toggle-sprint.state.unchanged": "Don't modify", "toggle-toggle-sprint.sprintOnDeath": "Keep sprinting after death", - "toggle-toggle-sprint.sprintOnDeath.description.line1": "As of 1.20.1, the game will release all toggled keys when the player respawns, including the Sprint key.", - "toggle-toggle-sprint.sprintOnDeath.description.line2": "This feature prevents vanilla from releasing your sprint key, ensuring that you continue to sprint after respawning.", - "toggle-toggle-sprint.sprintOnDeath.description.line3": "Note that this feature only affects the Sprint key, and all other toggle keys (such as the Sneak key) will still be released.", + "toggle-toggle-sprint.sprintOnDeath.description.line1": "Normally when you respawn, the game will release all your pressed toggle keybinds; this feature prevents the game from releasing your Sprint key, ensuring you continue to sprint after respawning.", + "toggle-toggle-sprint.sprintOnDeath.description.line2": "Note that this feature only affects the Sprint key; all other toggle keys (such as the Sneak key) will still be released as normal.", "toggle-toggle-sprint.sprintOnJoin": "Start sprinting", "toggle-toggle-sprint.sprintOnJoin.description": "If enabled, you'll start sprinting when loading into a world if your Sprint control is set to Toggle", - "toggle-toggle-sprint.sprintState": "Default sprinting state", + "toggle-toggle-sprint.sprintState": "Default sprint state", "toggle-toggle-sprint.sprintState.description": "Changes your default state for sprinting", "toggle-toggle-sprint.sprintState.on": "Your Sprint control will be changed to Toggle when joining a world", "toggle-toggle-sprint.sprintState.off": "Your Sprint control will be changed to Hold when joining a world", "toggle-toggle-sprint.sprintState.unchanged": "Your Sprint control won't be modified when joining a world", - "toggle-toggle-sprint.alsoStartSprinting": "Also start sprinting", + "toggle-toggle-sprint.alsoStartSprinting": "Simulate Sprint key press", "toggle-toggle-sprint.alsoStartSprinting.description": "When enabled, the toggle key will also simulate a Sprint key press when activated if you're not already sprinting", "toggle-toggle-sprint.sneakOnJoin": "Start sneaking", "toggle-toggle-sprint.sneakOnJoin.description": "If enabled, you'll start sneaking when loading into a world if your Sneak control is set to Toggle", - "toggle-toggle-sprint.sneakState": "Default sneaking state", + "toggle-toggle-sprint.sneakState": "Default sneak state", "toggle-toggle-sprint.sneakState.description": "Changes the default state for your Sneak control", "toggle-toggle-sprint.sneakState.on": "Your Sneak control will be changed to Toggle when joining a world", "toggle-toggle-sprint.sneakState.off": "Your Sneak control will be changed to Hold when joining a world", "toggle-toggle-sprint.sneakState.unchanged": "Your Sneak control won't be modified when joining a world", - "toggle-toggle-sprint.alsoStartSneaking": "Also start sneaking", + "toggle-toggle-sprint.alsoStartSneaking": "Simulate Sneak key press", "toggle-toggle-sprint.alsoStartSneaking.description": "When enabled, the toggle key will also simulate a Sneak key press when activated if you're not already sneaking" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7c63e2c..5304371 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,7 +9,7 @@ "sources": "https://github.com/celestialfault/toggle-toggle-sprint", "issues": "https://github.com/celestialfault/toggle-toggle-sprint/issues" }, - "license": "CC0-1.0", + "license": "zlib", "environment": "client", "entrypoints": { "client": ["me.celestialfault.toggletogglesprint.ToggleToggleSprint"], @@ -17,9 +17,8 @@ }, "mixins": ["toggle-toggle-sprint.mixins.json"], "depends": { - "fabricloader": ">=0.15", - "minecraft": ">=1.20.1", - "java": ">=17", + "fabricloader": "${loaderdep}", + "minecraft": "${mcdep}", "fabric-key-binding-api-v1": "*", "fabric-lifecycle-events-v1": "*" }, diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 0000000..e641c6c --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,24 @@ +plugins { + id("dev.kikugie.stonecutter") + id("fabric-loom") version "1.6-SNAPSHOT" apply false +} +stonecutter active "1.20.2" /* [SC] DO NOT EDIT */ + +// Builds every version into `build/libs/{mod.version}/` +stonecutter registerChiseled tasks.register("chiseledBuild", stonecutter.chiseled) { + group = "project" + ofTask("buildAndCollect") +} + +stonecutter configureEach { + /* + See src/main/java/com/example/TemplateMod.java + and https://stonecutter.kikugie.dev/ + */ + // Swaps replace the scope with a predefined value + swap("mod_version", "\"${property("mod.version")}\";") + // Dependencies add targets to check versions against + // Using `project.property()` in this block gets the versioned property + dependency("fapi", project.property("deps.fabric_api").toString()) + dependency("yacl", project.property("deps.yacl").toString()) +} diff --git a/versions/1.19.4/gradle.properties b/versions/1.19.4/gradle.properties new file mode 100644 index 0000000..8fa4ff6 --- /dev/null +++ b/versions/1.19.4/gradle.properties @@ -0,0 +1,10 @@ +mod.mc_dep=>=1.19.4 <1.20.1 +# we don't need mixin extras on <1.20.1, so we can safely relax the loader version requirement +# very heavily, essentially all the way down to "so long as the game loads we don't care" +mod.loader_dep=* +mod.mc_title=1.19.4 + +deps.yarn_build=2 +deps.fabric_api=0.87.2+1.19.4 +deps.yacl=3.1.1 +deps.modmenu=6.3.1 diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties new file mode 100644 index 0000000..ce27f8b --- /dev/null +++ b/versions/1.20.2/gradle.properties @@ -0,0 +1,7 @@ +mod.mc_dep=>=1.20.1 +mod.mc_title=1.20.2 + +deps.yarn_build=4 +deps.fabric_api=0.91.6+1.20.2 +deps.yacl=3.2.1 +deps.modmenu=8.0.0