├── images └── ingame_hud.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ ├── assets │ │ └── modid │ │ │ ├── icon.png │ │ │ ├── icon.png~ │ │ │ ├── icon_400x400.kra │ │ │ └── icon_400x400.png │ ├── simple_utilities.mixins.json │ └── fabric.mod.json │ └── java │ └── net │ └── johnvictorfs │ └── simple_utilities │ ├── mixin │ ├── GameClientMixin.java │ └── GameInfoMixin.java │ ├── helpers │ └── Colors.java │ ├── SimpleUtilities.java │ └── hud │ └── GameInfoHud.java ├── settings.gradle ├── .gitignore ├── gradle.properties ├── LICENSE ├── gradlew.bat ├── README.md └── gradlew /images/ingame_hud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/images/ingame_hud.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/modid/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/src/main/resources/assets/modid/icon.png -------------------------------------------------------------------------------- /src/main/resources/assets/modid/icon.png~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/src/main/resources/assets/modid/icon.png~ -------------------------------------------------------------------------------- /src/main/resources/assets/modid/icon_400x400.kra: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/src/main/resources/assets/modid/icon_400x400.kra -------------------------------------------------------------------------------- /src/main/resources/assets/modid/icon_400x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/simple-utilities-mod/master/src/main/resources/assets/modid/icon_400x400.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | jcenter() 8 | gradlePluginPortal() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # idea 9 | 10 | .idea/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # vscode 16 | 17 | .settings/ 18 | .vscode/ 19 | bin/ 20 | .classpath 21 | .project 22 | 23 | # fabric 24 | 25 | run/ -------------------------------------------------------------------------------- /src/main/resources/simple_utilities.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.johnvictorfs.simple_utilities.mixin", 4 | "compatibilityLevel": "JAVA_8", 5 | "mixins": [ 6 | ], 7 | "client": [ 8 | "GameInfoMixin", 9 | "GameClientMixin" 10 | ], 11 | "injectors": { 12 | "defaultRequire": 1 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/net/johnvictorfs/simple_utilities/mixin/GameClientMixin.java: -------------------------------------------------------------------------------- 1 | package net.johnvictorfs.simple_utilities.mixin; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(MinecraftClient.class) 8 | public interface GameClientMixin { 9 | @Accessor("currentFps") 10 | public abstract int getCurrentFps(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/net/johnvictorfs/simple_utilities/helpers/Colors.java: -------------------------------------------------------------------------------- 1 | package net.johnvictorfs.simple_utilities.helpers; 2 | 3 | public class Colors { 4 | public static final int lightGray = Integer.parseInt("bebebe", 16); 5 | public static final int lightRed = Integer.parseInt("db4f4f", 16); 6 | public static final int lightYellow = Integer.parseInt("e0ed53", 16); 7 | public static final int lightOrange = Integer.parseInt("edb753", 16); 8 | public static final int lightGreen = Integer.parseInt("3ade65", 16); 9 | public static final int white = 0x00E0E0E0; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/net/johnvictorfs/simple_utilities/SimpleUtilities.java: -------------------------------------------------------------------------------- 1 | package net.johnvictorfs.simple_utilities; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | 5 | public class SimpleUtilities implements ModInitializer { 6 | @Override 7 | public void onInitialize() { 8 | /* 9 | This code runs as soon as Minecraft is in a mod-load-ready state. 10 | However, some things (like resources) may still be unitialized. 11 | Proceed with mild caution. 12 | */ 13 | System.out.println("Simple Utilities Mod started."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | 4 | # Fabric Properties 5 | # check these on https://modmuss50.me/fabric.html 6 | minecraft_version=1.16.3 7 | yarn_mappings=1.16.3+build.39 8 | loader_version=0.10.1+build.209 9 | 10 | # Mod Properties 11 | mod_version = 1.2.0 12 | maven_group = net.fabricmc 13 | archives_base_name = simple-utilities-mod 14 | 15 | # Dependencies 16 | # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api 17 | fabric_version=0.24.0+build.411-1.16 18 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "simple_utilities", 4 | "version": "${version}", 5 | 6 | "name": "Simple Utilities", 7 | "description": "Adds simple utilities like extra simplified info on HUD and Toggle Sprint", 8 | "authors": [ 9 | "johnvictorfs", 10 | "bloopletech" 11 | ], 12 | "contact": { 13 | "homepage": "https://fabricmc.net/", 14 | "sources": "https://github.com/bloopletech/simple-utilities-mod" 15 | }, 16 | 17 | "license": "CC0-1.0", 18 | "icon": "assets/modid/icon.png", 19 | 20 | "environment": "*", 21 | "entrypoints": { 22 | "main": [ 23 | "net.johnvictorfs.simple_utilities.SimpleUtilities" 24 | ] 25 | }, 26 | "mixins": [ 27 | "simple_utilities.mixins.json" 28 | ], 29 | 30 | "depends": { 31 | "fabricloader": ">=0.10.1", 32 | "fabric": "*", 33 | "minecraft": "1.16.x" 34 | }, 35 | "suggests": { 36 | "flamingo": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 John Victor, Brenton Fletcher 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/net/johnvictorfs/simple_utilities/mixin/GameInfoMixin.java: -------------------------------------------------------------------------------- 1 | package net.johnvictorfs.simple_utilities.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.johnvictorfs.simple_utilities.hud.GameInfoHud; 6 | import net.minecraft.client.MinecraftClient; 7 | import net.minecraft.client.gui.hud.InGameHud; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(value = InGameHud.class) 16 | public abstract class GameInfoMixin { 17 | private GameInfoHud hudInfo; 18 | 19 | @Inject(method = "(Lnet/minecraft/client/MinecraftClient;)V", at = @At(value = "RETURN")) 20 | private void onInit(MinecraftClient client, CallbackInfo ci) { 21 | // Start Mixin 22 | System.out.println("Init Coordinates Mixin"); 23 | this.hudInfo = new GameInfoHud(client); 24 | } 25 | 26 | @Inject(method = "renderStatusEffectOverlay", at = @At(value = "HEAD")) 27 | private void onDraw(MatrixStack matrices, CallbackInfo ci) { 28 | // Draw Game info on every GameHud render 29 | this.hudInfo.draw(matrices); 30 | } 31 | } -------------------------------------------------------------------------------- /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 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Utilities Mod (Minecraft 1.16.x) 2 | 3 | Forked from https://github.com/johnvictorfs/simple-utilities-mod. 4 | 5 | Built using [Fabric Example Mod Template](https://github.com/FabricMC/fabric-example-mod) and made with the [Fabric](https://fabricmc.net) modding toolchain for Minecraft. 6 | 7 | A Minecraft Mod that enhances the Game's HUD with some simple utilities like the following: 8 | 9 | - **HUD Features:** 10 | - Simplified coordinates that are available at all times on the screen (Example: `39, 64, 200` as `X, Y, Z`) 11 | - Cardinal directions and which Coordinates are increasing/decreasing (Example: `(East X+)` when looking East, where the `X` coordinate is increasing) 12 | - Current armour and hand items and their durabilities, available at all times on the screen 13 | - Different colors based on how low the durability is 14 | - Current Game time in AM/PM format 15 | - Current sprinting status 16 | - Current framerate 17 | - Current Biome the player is on 18 | 19 | --- 20 | 21 | ## Images 22 | 23 | ![In-game HUD Example](images/ingame_hud.png) 24 | 25 | --- 26 | 27 | ## Installation 28 | 29 | - Install [Fabric Loader](https://fabricmc.net/use/) on your Minecraft client 30 | - Recommended to install with the [MultiMC](https://multimc.org/) Minecraft client, which allows you to install Fabric in one click in the Minecraft instance settings 31 | - Download latest Mod `.jar` from [Github](https://github.com/bloopletech/simple-utilities-mod/releases/latest) 32 | - Put the downloaded Mod `.jar` in the `.minecraft/mods` folder 33 | - Or if you're using MultiMC, open the Minecraft instance settings you're using, and look for the option to add a Mod, then select the `.jar` file you downloaded 34 | - Done! 35 | 36 | --- 37 | 38 | ## Building from source 39 | 40 | - Clone the project with `git clone https://github.com/bloopletech/simple-utilities-mod.git` 41 | - Cd into the project's directory `cd simple-utilities-mod` 42 | - Run `./gradlew build` to build the `.jar` 43 | - Built Mod `.jar` files will be located at `build/libs` 44 | - Example: `build/libs/simple-utilities-mod-1.0.0.jar` 45 | - This will be the Mod `.jar` file you can put in your `.minecraft/mods` folder 46 | 47 | --- 48 | 49 | ## Planned features 50 | 51 | - Allow the User to toggle the HUD utilities, both individually and as a whole, could be done either with Hotkeys or with a Settings interface, possibly both 52 | - Add current status effects duration to HUD 53 | - Add Sun/Moon icons to the current game time, so it's easier to notice if it's Day or Night 54 | 55 | --- 56 | 57 | ## FAQ 58 | 59 | - **Does this Mod work on versions below 1.16?** 60 | - For 1.15, download this version: https://github.com/bloopletech/simple-utilities-mod/releases/tag/1.0.3 61 | - For 1.14, no, it *might* work on 1.14 with some changes, but not anything below 1.14, since this Mod is made with Fabric, which only supports Minecraft 1.14 and above. 62 | 63 | - **Will this Mod get me banned from *X multiplayer server*?** 64 | - Maybe, maybe not, the Mod is entirely Client-sided and does not require it to be installed on the Server, and mostly shows things already available to you at all times like coordinates and Cardinal directions, like an extended but simplified F3 Menu, but it has some exceptions, like very specific Game time, so some servers may not allow it, do look into the Server's rules carefully before using it, do **not** create issues here asking about that, since I won't know. 65 | 66 | - **Will you add '*X feature not present in the [Planned Features](#planned-features) section*'**? 67 | - Maybe, and only if it fits with the other features of the mod, create [an issue](https://github.com/bloopletech/simple-utilities-mod/issues/new) about it, I only on this project on my spare time, but I'd be happy to add wanted features in my spare time. 68 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or 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 UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /src/main/java/net/johnvictorfs/simple_utilities/hud/GameInfoHud.java: -------------------------------------------------------------------------------- 1 | package net.johnvictorfs.simple_utilities.hud; 2 | 3 | import net.johnvictorfs.simple_utilities.helpers.Colors; 4 | import com.google.common.collect.Lists; 5 | import net.fabricmc.api.EnvType; 6 | import net.fabricmc.api.Environment; 7 | import net.johnvictorfs.simple_utilities.mixin.GameClientMixin; 8 | import net.minecraft.block.Blocks; 9 | import net.minecraft.client.MinecraftClient; 10 | import net.minecraft.client.font.TextRenderer; 11 | import net.minecraft.client.network.ClientPlayerEntity; 12 | import net.minecraft.client.resource.language.I18n; 13 | import net.minecraft.entity.effect.StatusEffect; 14 | import net.minecraft.entity.effect.StatusEffectInstance; 15 | import net.minecraft.entity.player.PlayerInventory; 16 | import net.minecraft.item.ItemStack; 17 | import net.minecraft.util.math.Direction; 18 | import net.minecraft.client.util.math.MatrixStack; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | @Environment(EnvType.CLIENT) 25 | public class GameInfoHud { 26 | private final MinecraftClient client; 27 | private final TextRenderer textRenderer; 28 | private ClientPlayerEntity player; 29 | private MatrixStack matrices; 30 | 31 | public GameInfoHud(MinecraftClient client) { 32 | this.client = client; 33 | textRenderer = client.textRenderer; 34 | } 35 | 36 | public void draw(MatrixStack matrices) { 37 | if(client.options.debugEnabled) return; 38 | 39 | client.getProfiler().push("gameInfoHud"); 40 | 41 | player = client.player; 42 | this.matrices = matrices; 43 | 44 | drawInfos(); 45 | 46 | client.getProfiler().pop(); 47 | } 48 | 49 | private void drawInfos() { 50 | // Draw lines of Array of Game info in the screen 51 | 52 | List gameInfo = getGameInfo(); 53 | drawEquipementInfo(); 54 | 55 | int lineHeight = textRenderer.fontHeight + 2; 56 | int top = 0; 57 | int left = 4; 58 | 59 | for (String line : gameInfo) { 60 | textRenderer.draw(matrices, line, left, top + 4, Colors.white); 61 | top += lineHeight; 62 | } 63 | 64 | if (player.isSprinting()) { 65 | final String sprintingText = "Sprinting"; 66 | 67 | int maxLineHeight = Math.max(10, textRenderer.getWidth(sprintingText)); 68 | maxLineHeight = (int) (Math.ceil(maxLineHeight / 5.0D + 0.5D) * 5); 69 | int scaleHeight = client.getWindow().getScaledHeight(); 70 | int sprintingTop = scaleHeight - maxLineHeight; 71 | 72 | // Sprinting Info 73 | textRenderer.draw(matrices, sprintingText, 2, sprintingTop + 20, Colors.white); 74 | } 75 | } 76 | 77 | private static String capitalize(String str) { 78 | // Capitalize first letter of a String 79 | if (str == null) return null; 80 | return str.substring(0, 1).toUpperCase() + str.substring(1); 81 | } 82 | 83 | private static String getOffset(Direction facing) { 84 | String offset = ""; 85 | 86 | if (facing.getOffsetX() > 0) { 87 | offset += "+X"; 88 | } else if (facing.getOffsetX() < 0) { 89 | offset += "-X"; 90 | } 91 | 92 | if (facing.getOffsetZ() > 0) { 93 | offset += " +Z"; 94 | } else if (facing.getOffsetZ() < 0) { 95 | offset += " -Z"; 96 | } 97 | 98 | return offset.trim(); 99 | } 100 | 101 | private String zeroPadding(int number) { 102 | return (number >= 10) ? Integer.toString(number) : String.format("0%s", number); 103 | } 104 | 105 | private String secondsToString(int pTime) { 106 | final int min = pTime / 60; 107 | final int sec = pTime - (min * 60); 108 | 109 | final String strMin = zeroPadding(min); 110 | final String strSec = zeroPadding(sec); 111 | return String.format("%s:%s", strMin, strSec); 112 | } 113 | 114 | private void drawStatusEffectInfo() { 115 | if (client.player != null) { 116 | Map effects = client.player.getActiveStatusEffects(); 117 | 118 | for (Map.Entry effect : effects.entrySet()) { 119 | String effectName = I18n.translate(effect.getKey().getTranslationKey()); 120 | 121 | String duration = secondsToString(effect.getValue().getDuration() / 20); 122 | 123 | int color = effect.getKey().getColor(); 124 | 125 | textRenderer.draw(matrices, effectName + " " + duration, 40, 200, color); 126 | } 127 | } 128 | } 129 | 130 | private void drawEquipementInfo() { 131 | List equippedItems = new ArrayList<>(); 132 | PlayerInventory inventory = player.inventory; 133 | int maxLineHeight = Math.max(10, textRenderer.getWidth("")); 134 | 135 | ItemStack mainHandItem = inventory.getMainHandStack(); 136 | maxLineHeight = Math.max(maxLineHeight, textRenderer.getWidth(I18n.translate(mainHandItem.getTranslationKey()))); 137 | equippedItems.add(mainHandItem); 138 | 139 | for (ItemStack secondHandItem : inventory.offHand) { 140 | maxLineHeight = Math.max(maxLineHeight, textRenderer.getWidth(I18n.translate(secondHandItem.getTranslationKey()))); 141 | equippedItems.add(secondHandItem); 142 | } 143 | 144 | for (ItemStack armourItem : player.inventory.armor) { 145 | maxLineHeight = Math.max(maxLineHeight, textRenderer.getWidth(I18n.translate(armourItem.getTranslationKey()))); 146 | equippedItems.add(armourItem); 147 | } 148 | 149 | maxLineHeight = (int) (Math.ceil(maxLineHeight / 5.0D + 0.5D) * 5); 150 | int itemTop = client.getWindow().getScaledHeight() - maxLineHeight; 151 | 152 | int lineHeight = textRenderer.fontHeight + 6; 153 | 154 | // Draw in order Helmet -> Chestplate -> Leggings -> Boots 155 | for (ItemStack equippedItem : Lists.reverse(equippedItems)) { 156 | if (equippedItem.getItem().equals(Blocks.AIR.asItem())) { 157 | // Skip empty slots 158 | continue; 159 | } 160 | 161 | client.getItemRenderer().renderGuiItemIcon(equippedItem, 2, itemTop - 68); 162 | 163 | if (equippedItem.getMaxDamage() != 0) { 164 | int currentDurability = equippedItem.getMaxDamage() - equippedItem.getDamage(); 165 | 166 | String itemDurability = currentDurability + "/" + equippedItem.getMaxDamage(); 167 | 168 | // Default Durability Color 169 | int color = Colors.white; 170 | 171 | if (currentDurability < equippedItem.getMaxDamage()) { 172 | // Start as Green if item has lost at least 1 durability 173 | color = Colors.lightGreen; 174 | } 175 | if (currentDurability <= (equippedItem.getMaxDamage() / 1.5)) { 176 | color = Colors.lightYellow; 177 | } 178 | if (currentDurability <= (equippedItem.getMaxDamage() / 2.5)) { 179 | color = Colors.lightOrange; 180 | } 181 | if (currentDurability <= (equippedItem.getMaxDamage()) / 4) { 182 | color = Colors.lightRed; 183 | } 184 | 185 | textRenderer.draw(matrices, itemDurability, 22, itemTop - 64, color); 186 | } else { 187 | int count = equippedItem.getCount(); 188 | 189 | if (count > 1) { 190 | String itemCount = String.valueOf(count); 191 | textRenderer.draw(matrices, itemCount, 22, itemTop - 64, Colors.white); 192 | } 193 | } 194 | 195 | itemTop += lineHeight; 196 | } 197 | } 198 | 199 | private static String parseTime(long time) { 200 | long hours = (time / 1000 + 6) % 24; 201 | long minutes = (time % 1000) * 60 / 1000; 202 | String ampm = "AM"; 203 | 204 | if (hours >= 12) { 205 | hours -= 12; 206 | ampm = "PM"; 207 | } 208 | 209 | if (hours >= 12) { 210 | hours -= 12; 211 | ampm = "AM"; 212 | } 213 | 214 | if (hours == 0) hours = 12; 215 | 216 | String mm = "0" + minutes; 217 | mm = mm.substring(mm.length() - 2); 218 | 219 | return hours + ":" + mm + " " + ampm; 220 | } 221 | 222 | private List getGameInfo() { 223 | List gameInfo = new ArrayList<>(); 224 | 225 | Direction facing = player.getHorizontalFacing(); 226 | 227 | String coordsFormat = "%.0f, %.0f, %.0f %s"; 228 | 229 | String direction = "(" + capitalize(facing.asString()) + " " + getOffset(facing) + ")"; 230 | 231 | // Coordinates and Direction info 232 | gameInfo.add(String.format(coordsFormat, player.getX(), player.getY(), player.getZ(), direction)); 233 | 234 | // Get everything from fps debug string until the 's' from 'fps' 235 | // gameInfo.add(client.fpsDebugString.substring(0, client.fpsDebugString.indexOf("s") + 1)); 236 | gameInfo.add(String.format("%d fps", ((GameClientMixin) client.getInstance()).getCurrentFps())); 237 | 238 | // Get biome info 239 | if (client.world != null) { 240 | gameInfo.add(capitalize(client.world.getBiome(player.getBlockPos()).getCategory().getName()) + " Biome"); 241 | 242 | // Add current parsed time 243 | gameInfo.add(parseTime(client.world.getTimeOfDay())); 244 | } 245 | 246 | return gameInfo; 247 | } 248 | } --------------------------------------------------------------------------------