├── .github └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── animation.gif ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── icon-large.png ├── icon-largest.png ├── screenshot.png ├── settings.gradle └── src └── main ├── java └── se │ └── icus │ └── mag │ └── statuseffecttimer │ └── mixin │ └── StatusEffectTimerMixin.java └── resources ├── assets └── statuseffecttimer │ └── icon.png ├── fabric.mod.json └── statuseffecttimer.mixins.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build on Push/PR 2 | 3 | on: 4 | pull_request: 5 | push: 6 | workflow_dispatch: 7 | 8 | env: 9 | JAVA_VERSION: 21 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Check out source code 16 | uses: actions/checkout@v4 17 | 18 | - name: Validate Gradle wrapper 19 | uses: gradle/actions/wrapper-validation@v3 20 | 21 | - name: Setup JDK 22 | uses: actions/setup-java@v4 23 | with: 24 | distribution: "temurin" 25 | java-version: "${{env.JAVA_VERSION}}" 26 | 27 | - name: Setup Gradle 28 | uses: gradle/actions/setup-gradle@v3 29 | 30 | - name: Build with Gradle 31 | run: gradle build 32 | 33 | - name: Upload build artifacts 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: Artifacts 37 | path: build/libs/ 38 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release on tag 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | tags: 7 | - '*' 8 | 9 | env: 10 | JAVA_VERSION: 21 11 | MODRINTH_ID: 'T9FDHbY5' 12 | CURSEFORGE_ID: '484738' 13 | 14 | jobs: 15 | build-and-release: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Check out source code 19 | uses: actions/checkout@v4 20 | 21 | - name: Validate Gradle wrapper 22 | uses: gradle/actions/wrapper-validation@v3 23 | 24 | - name: Setup JDK 25 | uses: actions/setup-java@v4 26 | with: 27 | distribution: 'temurin' 28 | java-version: '${{env.JAVA_VERSION}}' 29 | 30 | - name: Setup Gradle 31 | uses: gradle/actions/setup-gradle@v3 32 | 33 | - name: Build with Gradle 34 | run: gradle build 35 | 36 | - name: Get version numbers from tag 37 | id: version 38 | run: | 39 | # Extract mod and minecraft version from tag 40 | mod_version=${GITHUB_REF_NAME#v} 41 | mod_version="${mod_version%+*}" 42 | minecraft_version=${GITHUB_REF_NAME#*+} 43 | echo "mod=$mod_version" >> $GITHUB_OUTPUT 44 | echo "minecraft=$minecraft_version" >> $GITHUB_OUTPUT 45 | echo "full=$mod_version+$minecraft_version" >> $GITHUB_OUTPUT 46 | echo Mod version: $mod_version 47 | echo Minecraft version: $minecraft_version 48 | 49 | - name: Install parse-changelog 50 | uses: taiki-e/install-action@v2 51 | with: 52 | tool: parse-changelog 53 | 54 | - name: Parse changelog 55 | id: changelog 56 | continue-on-error: true 57 | run: | 58 | # Extract the changelog entry for this release 59 | mkdir -p output 60 | changelog=output/changelog.md 61 | parse-changelog CHANGELOG.md ${{ steps.version.outputs.full }} > $changelog || true 62 | if [[ ! -s $changelog ]]; then 63 | # No changelog for specific version (mod+minecraft), try just mod version 64 | parse-changelog CHANGELOG.md ${{ steps.version.outputs.mod }} > $changelog || true 65 | fi 66 | if [[ ! -s $changelog ]]; then 67 | echo "No changelog available" > $changelog 68 | fi 69 | echo Extracted changelog for this release: 70 | cat $changelog 71 | echo "file=$changelog" >> $GITHUB_OUTPUT 72 | 73 | - name: Publish release 74 | id: publish 75 | uses: Kir-Antipov/mc-publish@v3.3 76 | with: 77 | modrinth-id: ${{ env.MODRINTH_ID }} 78 | curseforge-id: ${{ env.CURSEFORGE_ID }} 79 | github-token: ${{ secrets.MY_GITHUB_TOKEN }} 80 | modrinth-token: ${{ secrets.MODRINTH_TOKEN }} 81 | curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} 82 | name: Status Effect Timer ${{ steps.version.outputs.mod }} (${{ steps.version.outputs.minecraft }}) 83 | version: ${{ steps.version.outputs.full }} 84 | version-type: release 85 | changelog-file: ${{ steps.changelog.outputs.file }} 86 | 87 | - name: Show results 88 | run: | 89 | # Show results from mc-publish 90 | echo Successfully published Status Effect Timer ${{ steps.version.outputs.full }} 91 | echo Modrinth release ${{ steps.publish.outputs.modrinth-version }}: ${{ steps.publish.outputs.modrinth-url }} 92 | echo CurseForge release ${{ steps.publish.outputs.curseforge-version }}: ${{ steps.publish.outputs.curseforge-url }} 93 | echo GitHub release ${{ steps.publish.outputs.github-tag }}: ${{ steps.publish.outputs.github-url }} 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.2.0+1.21 - 2024-06-13 4 | 5 | ### Added 6 | 7 | - Support for Minecraft 1.21 8 | 9 | ## 1.2.0+1.20.5 - 2024-04-26 10 | 11 | ### Added 12 | 13 | - Support for Minecraft 1.20.5 14 | 15 | ## 1.2.0+1.20 - 2024-01-19 16 | 17 | ### Added 18 | 19 | - Support for Minecraft 1.20 20 | 21 | ## 1.2.0+1.19.4 - 2024-01-19 22 | 23 | ### Added 24 | 25 | - Support for Minecraft 1.19.4 (infinite durability) 26 | 27 | ## 1.2.0 - 2024-01-19 28 | 29 | ### Fixed 30 | 31 | - Be more friendly to other mods by injecting mixin more specifically 32 | 33 | ## 1.1.1+1.19 - 2022-06-14 34 | 35 | ### Added 36 | 37 | - Support for Minecraft 1.19 38 | 39 | ## 1.1.1 - 2022-04-15 40 | 41 | ### Fixed 42 | 43 | - Fix interoperability with HUDTweaks by lowering mixin priority 44 | 45 | ## 1.1.0 - 2021-12-30 46 | 47 | ### Added 48 | 49 | - Support for Minecraft 1.18 and 1.18.1 50 | - Display effect amplification level, partially contributed by @ewewukek (#4) 51 | 52 | ## 1.0.3 - 2021-07-16 53 | 54 | ### Added 55 | 56 | - Support for Minecraft 1.17.1 57 | 58 | ## 1.0.2 - 2021-06-24 59 | 60 | ### Added 61 | 62 | - Support for Minecraft 1.17 63 | 64 | ## 1.0.1 - 2021-05-21 65 | 66 | ### Fixed 67 | 68 | - Fix license description in fabric.mod.json 69 | 70 | ## 1.0.0 - 2021-05-21 71 | 72 | ### Added 73 | 74 | - First release 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Status Effect Timer 2 | 3 | [![Modrinth](https://img.shields.io/modrinth/dt/statuseffecttimer?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAHZklEQVRoge1afYxUVxV%2FW5aydEsspWrFUkM%2FUlOTes99M0OmUB0TXdhKUpSuf4itmrZUUChitNpz7uSK7dJ1k6VdpAaIxPrVhDYa77lvmKGr01CypUrTFrIx8Q%2FRkvpFC4IFKVt4%2FjEz5M3beW%2Fna7sx8ST3r3n33N%2F5uOfrjuP8n6LJ9%2F0O3%2Fc7phvHpJQp6i43R9dLj5aBpXWC1QAw7hSGfgpMPxZMPwBLCgzelWCdcllfpX19yXSD7oScvlka%2BjoweWDoNcF4Vhj0oxedB8Z%2FAdMrwPSE9Gh5Oq%2BvfPeBs0oD404w9LpgvBAPOnoB03%2BAaRQsrbm1oN835eCTVl8HjI8D07EYUOPAdBKY%2FiaYjpaEpDfjrANM42DwBTDZlb254VltB97n754hOfsZYDo0AQDjBWHoH8CYl0waTHZlgnUqsYduSlp9nczrG5KeFtJmlwKr9YLpZ8D0R2Aar%2BFi%2F5YWt6X54Q%2B2DXx6dGg2WHpQGDoR9mfBeFgaQrlH35Ip6q56lZEs4AJgdbdgKoDBMxMUwlQEVh9tGXxPYbBbsBqYYH6mo8LiQ61qKlPUl0tPfU4wHRCGzofc6hCwSjfNvDc3PEtYehgYz4W0UxBGJdsZ32Gvni8sDQnGt0LWOOyylk0xFUatDZoXmMYF046pihZ9Y%2FpSaej%2BcIAApn0u62sbYgYefgwY%2F3qRicF3gHHr4v0Dc6YCfIV83%2B%2BQjKvA4BvVQuDOeu%2BYkxrpnweMIyEt%2FDxT1Fc0A6o3Nzxrid08t16X832%2FAyytAabTAQWekYyr6joQWK0Hg%2B8ENv8%2BVaCFjYB2D26fKZhuBEv3CKZfAdM%2BYfHWevf35oZnAePWkBIPwl49P3ZjKbxVxfpTwsveUc%2BhmaLuTBVoIbC6G5ieAkOvVSmC8Q%2BuzX6iXiFc1tcC40vBAAKMG2M3SaavBksDYHqyb0xfOtlhyQIuEEw7hMEjtRNUxZr0i0YyrbD4RWHo7YASXooMIov3D8wRjL8NSHxcWnXbZIeUcgXtqqP2OdJoXE%2Fn9ZWC6flA8nwbmO6s%2BTGwSgezLTD9erKbX75w3whqKWKdAoN3NQK%2BQtKqDaEkuqtmKQ6MG4Wh86WQSeOS6b7JmIPJ9gLjP2MrzhK%2Ffvfg9pnNCCCMSgrG4wF%2BY0lPXz3hw6SnBZjsSmnps8LL3gG5%2FvfGMU7soZuA6ZW4ClMwvgyMG5sNwY7jOEvs5rmC8cWgNRM5tbhZfo7jOE6mqK8AxmdiwP9FsLp30cgj72%2FpoDJJi9uC%2FCXTl1sB3wlMm4IhMuzv0qov1MvPPbh9Znp0aHbcN4LVvVUKsuq7TQtQigxVJg31B2ogU9Sdk%2FHJFHVXuWT5kbRqMC68ujb76VA4%2FWHTAjiO4wimB8Ll78VkY2lN3N6ewmC3y7RCMP6yEvWA6aT0aHnUngRTJlRYPtlSNZz09NXA9LvaFsAXo5JNxf1qtpdMxajL3nYBHMdxwNI9Vb1CIGwKpgdqHeAyrZjY2V0E5UVVu9Kj5cGzWnYhx6lUrTQaAeYYWFpXSYQ9hcFu4WU%2FJRgPR9ydv7uMS6LOKltgrCIEMG1qCbzv%2Bx3So2XC0J9iEtgZYHwcLK0Bg3uB6WSEy12QTDrOJbSvLyl1bdgHTD8Bk1054SMw6uOS1deEUWulofsX5fQ1tZhlirpTeupLwYYnetH5mpe92vefbyRfZIq6s2ZWL5USwVhL68LfuKwvE0zfidRmw4tOCKbb6wUfS66nFlXVHIz5nsJgd%2BX31Ej%2FPDA0PPn4sP4lmR6rJ2fURZmivhwM%2FaY6o2aXOo7jgIcfAqanI93h4iyH9tUDHJiOCaZdyQIuaAv4Cgmj1gZBAmM%2BwZQBpufi%2FByYnoK9ev6inL6m1I3VKDNKjdIRYXALeDrRbHUaS2UAhwICnIufg%2BI5aXFbcMK8xG6eKwxuqbhaee75qrD4kGC6ccrH6uGmPsYNTgPTpuA9qVB6dGi2ZPomMD0rme5z8498oBEMi%2FcPzAFWX5EeLWu4FK81VqnhDseB1fq4fjlT1J0u68saOtyplBv47XL7eBqYRqVVG2opKpLCg63qBEWvS8ZVff7uGY2Cqwd86R7iqVCu2NHw2D08Wixr%2Fqy0anW7gTtOKceApQfDOQaY9jUVraKGu%2BUXlU%2B20wJujq4XTLvCOQaYDiVyCppm3FMY7AZDj05gbPANYWnIZf3hVqJKaqR%2FnrRqNRgcqxEkWhuvV6gUUfBbwSwdsMafhcEt0qrb3GcffU89NXqmqLsgp2%2BWVm0QTAdqluRMzyU9LVoGX6E%2Bf%2FcMl2kFGHw1IqSeLIPZKq1aLW12aYJ1qvS0pNwEU0aw%2Bjyw%2Bh4w5koBomZH9xYwPdHWJ6YgpQq0UDI9FpfcSmUFni0L9aYwdKI0aY6uSstN0AFgunNKHvmC1PZnVoMvvGvPrGFBknn1EWDcCIw5wXS0nofuUgmNL0uL26bloTtCmC6Z1zcIptvLT6nfD%2F7VABi3AiNJxlXCqGRqpH%2FetP%2FVoB76n%2Fijx3TTfwGWd%2FQ%2FPbYNFgAAAABJRU5ErkJggg%3D%3D)](https://modrinth.com/mod/statuseffecttimer) 4 | [![CurseForge](https://cf.way2muchnoise.eu/short_status-effect-timer.svg)](https://www.curseforge.com/minecraft/mc-mods/status-effect-timer) 5 | [![GitHub](https://img.shields.io/github/downloads/magicus/statuseffecttimer/total?logo=github)](https://github.com/magicus/statuseffecttimer/releases) 6 | 7 | This is a Minecraft mod for Fabric that overlays a timer on the Vanilla status effect HUD icons. 8 | 9 | This mod overlays the time left of the status effect on the vanilla indicator. If the effect has an amplifier (as in "Haste II"), the amplifier is also overlaid. That's it. This is a very minimalistic mod. No settings are required nor provided. 10 | 11 | The time is presented as seconds remaining. Durations longer than 60 seconds are presented as minutes remaining (followed by "m"), and durations longer than 60 minutes are presented as hours remaining (followed by "h"). 12 | 13 | Prior to 1.19.4, status effects longer than 32147 ticks (roughly 25 minutes) where considered "infinite", and are marked as "**" in the mod. Starting with 1.19.4, status effects can be properly infinite, which is marked by a "∞" symbol, and the 32147 tick limit has been removed. 14 | 15 | I created this since the vanilla user experience of going into the inventory, and closing the recipe book, to check the remaining time of status effects was .. not ideal. There are some other mods that tried to achieve this, but most are bloated replacement for large parts of vanilla code, and the remaining still did not keep the vanilla basics. 16 | 17 | ## Screenshot 18 | 19 | This is what it looks like when you are using the mod. 20 | 21 | ![Screenshot](screenshot.png?raw=true) 22 | 23 | ![Animation](animation.gif?raw=true) 24 | 25 | ## Download 26 | 27 | You can download the mod from any of these sites: 28 | 29 | * [GitHub releases](https://github.com/magicus/statuseffecttimer/releases) 30 | * [Modrinth versions](https://modrinth.com/mod/statuseffecttimer/versions) 31 | * [CurseForge](https://www.curseforge.com/minecraft/mc-mods/status-effect-timer/files) 32 | 33 | ## Installation 34 | 35 | Install this as you would any other Fabric mod. (I recommend using [Prism Launcher](https://prismlauncher.org/) as Minecraft launcher for modded Minecraft.) 36 | 37 | ## Support 38 | 39 | Do you have any problems with the mod? Please open an issue here on Github. 40 | 41 | ## Known Incompatibilities 42 | 43 | This mod does not work if the mod ['Slight' Gui Modifications](https://github.com/shedaniel/slight-gui-modifications) is installed and the configuration `fluidStatusEffects` is enabled. 44 | 45 | This mod conflicts with [Giselbaer's Durability Viewer](https://github.com/gbl/DurabilityViewer), since that mod also draws a timer on the status effect icon. You need to disable the effect time feature in Durability Viewer to avoid clutter. 46 | -------------------------------------------------------------------------------- /animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/animation.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'fabric-loom' version '1.6-SNAPSHOT' 4 | } 5 | 6 | dependencies { 7 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 8 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 9 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 10 | } 11 | 12 | version = "${project.mod_version}+${project.minecraft_version}" 13 | 14 | processResources { 15 | inputs.property "version", project.version 16 | 17 | filesMatching("fabric.mod.json") { 18 | expand "mod_version": project.version 19 | } 20 | 21 | filesMatching("*.mixins.json") { 22 | expand "java_version": project.java_version 23 | } 24 | } 25 | 26 | java { 27 | sourceCompatibility = JavaVersion.toVersion(project.java_version) 28 | targetCompatibility = JavaVersion.toVersion(project.java_version) 29 | } 30 | 31 | tasks.withType(JavaCompile).configureEach { 32 | it.options.release = project.java_version.toInteger() 33 | } 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Mod version 2 | mod_version=1.2.0 3 | 4 | # Minecraft/Java version 5 | # Also hardcoded in fabric.mod.json and *.mixin.json 6 | minecraft_version=1.21 7 | java_version=21 8 | 9 | # Fabric versions -- check these on https://fabricmc.net/develop 10 | # Also hardcoded in fabric.mod.json 11 | yarn_mappings=1.21+build.1 12 | loader_version=0.15.11 13 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /icon-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/icon-large.png -------------------------------------------------------------------------------- /icon-largest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/icon-largest.png -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/screenshot.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | gradlePluginPortal() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/se/icus/mag/statuseffecttimer/mixin/StatusEffectTimerMixin.java: -------------------------------------------------------------------------------- 1 | package se.icus.mag.statuseffecttimer.mixin; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.minecraft.client.MinecraftClient; 7 | import net.minecraft.client.gui.DrawContext; 8 | import net.minecraft.client.gui.hud.InGameHud; 9 | import net.minecraft.client.render.RenderTickCounter; 10 | import net.minecraft.client.resource.language.I18n; 11 | import net.minecraft.entity.effect.StatusEffectInstance; 12 | import net.minecraft.util.math.MathHelper; 13 | import org.spongepowered.asm.mixin.Final; 14 | import org.spongepowered.asm.mixin.Mixin; 15 | import org.spongepowered.asm.mixin.Shadow; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | import java.util.List; 21 | 22 | // Set priority to 500, to load before default at 1000. This is to better cooperate with HUDTweaks. 23 | @Environment(EnvType.CLIENT) 24 | @Mixin(value = InGameHud.class, priority = 500) 25 | public abstract class StatusEffectTimerMixin { 26 | @Shadow @Final 27 | private MinecraftClient client; 28 | 29 | @Inject(method = "renderStatusEffectOverlay", 30 | at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", shift = At.Shift.AFTER)) 31 | private void appendOverlayDrawing(DrawContext context, RenderTickCounter tickCounter, CallbackInfo c, 32 | @Local List list, @Local StatusEffectInstance statusEffectInstance, 33 | @Local(ordinal = 4) int x, @Local(ordinal = 3) int y) { 34 | list.add(() -> { 35 | drawStatusEffectOverlay(context, statusEffectInstance, x, y); 36 | }); 37 | } 38 | 39 | private void drawStatusEffectOverlay(DrawContext context, StatusEffectInstance statusEffectInstance, int x, int y) { 40 | String duration = getDurationAsString(statusEffectInstance); 41 | int durationLength = client.textRenderer.getWidth(duration); 42 | context.drawTextWithShadow(client.textRenderer, duration, x + 13 - (durationLength / 2), y + 14, 0x99FFFFFF); 43 | 44 | int amplifier = statusEffectInstance.getAmplifier(); 45 | if (amplifier > 0) { 46 | // Convert to roman numerals if possible 47 | String amplifierString = (amplifier < 10) ? I18n.translate("enchantment.level." + (amplifier + 1)) : "**"; 48 | int amplifierLength = client.textRenderer.getWidth(amplifierString); 49 | context.drawTextWithShadow(client.textRenderer, amplifierString, x + 22 - amplifierLength, y + 3, 0x99FFFFFF); 50 | } 51 | } 52 | 53 | private String getDurationAsString(StatusEffectInstance statusEffectInstance) { 54 | if (statusEffectInstance.isInfinite()) { 55 | return I18n.translate("effect.duration.infinite"); 56 | } 57 | 58 | int ticks = MathHelper.floor((float) statusEffectInstance.getDuration()); 59 | int seconds = ticks / 20; 60 | 61 | if (seconds >= 3600) { 62 | return seconds / 3600 + "h"; 63 | } else if (seconds >= 60) { 64 | return seconds / 60 + "m"; 65 | } else { 66 | return String.valueOf(seconds); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/resources/assets/statuseffecttimer/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magicus/statuseffecttimer/73a750fee272e153ba82086d5fe6237cd9ef0773/src/main/resources/assets/statuseffecttimer/icon.png -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "statuseffecttimer", 4 | "version": "${mod_version}", 5 | 6 | "name": "Status Effect Timer", 7 | "description": "Overlay a timer on the Vanilla status effect HUD icons", 8 | "authors": [ 9 | "magicus" 10 | ], 11 | "contact": { 12 | "homepage": "https://github.com/magicus/statuseffecttimer", 13 | "issues": "https://github.com/magicus/statuseffecttimer/issues", 14 | "sources": "https://github.com/magicus/statuseffecttimer" 15 | }, 16 | 17 | "license": "LGPLv3", 18 | "icon": "assets/statuseffecttimer/icon.png", 19 | 20 | "environment": "client", 21 | 22 | "mixins": [ 23 | "statuseffecttimer.mixins.json" 24 | ], 25 | 26 | "depends": { 27 | "minecraft": "~1.21", 28 | "fabricloader": ">=0.15.6" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/statuseffecttimer.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "se.icus.mag.statuseffecttimer.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "client": [ 6 | "StatusEffectTimerMixin" 7 | ], 8 | "injectors": { 9 | "defaultRequire": 1 10 | } 11 | } 12 | --------------------------------------------------------------------------------