├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── cn │ └── enaium │ └── foxbase │ ├── FoxBaseMod.java │ ├── client │ ├── FoxBase.java │ ├── clickgui │ │ ├── ClickGUI.java │ │ ├── ModulePanel.java │ │ ├── TypePanel.java │ │ └── setting │ │ │ ├── BooleanSettingElement.java │ │ │ ├── SettingElement.java │ │ │ └── ValueSettingElement.java │ ├── command │ │ ├── SetCommand.java │ │ └── ToggleCommand.java │ ├── config │ │ └── ModuleConfig.java │ ├── configuration │ │ └── FoxBaseConfig.java │ ├── event │ │ └── Events.java │ ├── module │ │ ├── Type.java │ │ ├── combat │ │ │ └── Aura.java │ │ ├── movement │ │ │ └── Sprint.java │ │ └── render │ │ │ ├── FullBright.java │ │ │ ├── GUI.java │ │ │ └── HUD.java │ ├── setting │ │ ├── DoubleSetting.java │ │ ├── EnableSetting.java │ │ ├── FloatSetting.java │ │ ├── IntegerSetting.java │ │ ├── LongSetting.java │ │ └── ModeSetting.java │ └── utils │ │ ├── ChatUtils.java │ │ ├── ColorUtils.java │ │ ├── FontUtils.java │ │ ├── Render2D.java │ │ └── TimeUtils.java │ └── mixin │ ├── ClientPlayerEntityMixin.java │ ├── GameRendererMixin.java │ ├── InGameHudMixin.java │ ├── KeyboardMixin.java │ └── MinecraftClientMixin.java └── resources ├── assets └── foxbase │ └── icon.png ├── fabric.mod.json └── foxbase.mixins.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: "https://donate.enaium.cn/" 2 | -------------------------------------------------------------------------------- /.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/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Enaium 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft 1.18 Fabric 2 | ## Setup 3 | 1. Clone this repository. 4 | 2. Run the following command from the project's root directory: 5 | ``` 6 | ./gradlew genSources 7 | ``` 8 | 3. Open IntelliJ IDEA. 9 | 4. Open `Open => Select FoxBase folder` 10 | 5. Click `Import gradle project` 11 | 12 | ## Dependency 13 | 14 | [fabric-api](https://www.curseforge.com/minecraft/mc-mods/fabric-api) 15 | 16 | [cf4m-fabric](https://github.com/cf4m/cf4m-fabric/releases) -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '0.10-SNAPSHOT' 3 | id 'maven-publish' 4 | } 5 | 6 | repositories { 7 | maven { url = "https://maven.enaium.cn" } 8 | } 9 | 10 | sourceCompatibility = JavaVersion.VERSION_17 11 | targetCompatibility = JavaVersion.VERSION_17 12 | 13 | archivesBaseName = project.archives_base_name 14 | version = project.mod_version 15 | group = project.maven_group 16 | 17 | dependencies { 18 | //to change the versions see the gradle.properties file 19 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 20 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 21 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 22 | 23 | // Fabric API. This is technically optional, but you probably want it anyway. 24 | modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 25 | 26 | modImplementation "cn.enaium.cf4m:cf4m-fabric:${project.cf4m_version}" 27 | 28 | // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. 29 | // You may need to force-disable transitiveness on them. 30 | } 31 | 32 | processResources { 33 | inputs.property "version", project.version 34 | 35 | filesMatching("fabric.mod.json") { 36 | expand "version": project.version 37 | } 38 | } 39 | 40 | // ensure that the encoding is set to UTF-8, no matter what the system default is 41 | // this fixes some edge cases with special characters not displaying correctly 42 | // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html 43 | tasks.withType(JavaCompile) { 44 | options.encoding = "UTF-8" 45 | 46 | it.options.release = 17 47 | } 48 | 49 | java { 50 | // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 51 | // if it is present. 52 | // If you remove this line, sources will not be generated. 53 | withSourcesJar() 54 | } 55 | 56 | jar { 57 | from("LICENSE") { 58 | rename { "${it}_${project.archivesBaseName}" } 59 | } 60 | } 61 | 62 | // configure the maven publication 63 | publishing { 64 | publications { 65 | mavenJava(MavenPublication) { 66 | // add all the jars that should be included when publishing to maven 67 | artifact(remapJar) { 68 | builtBy remapJar 69 | } 70 | artifact(sourcesJar) { 71 | builtBy remapSourcesJar 72 | } 73 | } 74 | } 75 | 76 | // select the repositories you want to publish to 77 | repositories { 78 | // uncomment to publish to the local maven 79 | // mavenLocal() 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /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://fabricmc.net/use 6 | minecraft_version=1.18 7 | yarn_mappings=1.18+build.1 8 | loader_version=0.12.8 9 | 10 | # Mod Properties 11 | mod_version = 1.0.0 12 | maven_group = cn.enaium 13 | archives_base_name = FoxBase 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.43.1+1.18 18 | 19 | cf4m_version=1.9.7 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Enaium/minecraft-code-FoxBase/0c1ee3e2d1b8b0bc2efbee44b26cbcbda72ddf47/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Mar 16 17:31:32 CST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/FoxBaseMod.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | 5 | public class FoxBaseMod implements ModInitializer { 6 | @Override 7 | public void onInitialize() { 8 | System.out.println("Hello Fabric world!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/FoxBase.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | 5 | public enum FoxBase { 6 | 7 | instance; 8 | 9 | public String name = "FoxBase"; 10 | public String author = "Enaium"; 11 | public String version = "1.0"; 12 | public String game = "1.18"; 13 | 14 | public void run() { 15 | CF4M.run(this); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/ClickGUI.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.foxbase.client.utils.FontUtils; 5 | import net.minecraft.client.gui.screen.Screen; 6 | import net.minecraft.client.util.math.MatrixStack; 7 | import net.minecraft.text.LiteralText; 8 | 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * Project: FoxBase 13 | * ----------------------------------------------------------- 14 | * Copyright © 2020-2021 | Enaium | All rights reserved. 15 | */ 16 | public class ClickGUI extends Screen { 17 | 18 | ArrayList typePanels; 19 | 20 | public ClickGUI() { 21 | super(new LiteralText("")); 22 | typePanels = new ArrayList<>(); 23 | double categoryY = 5; 24 | for (String category : CF4M.INSTANCE.getModule().getAllType()) { 25 | typePanels.add(new TypePanel(category, 5, categoryY, getWidestCategory() + 50, FontUtils.getFontHeight() + 10)); 26 | categoryY += FontUtils.getFontHeight() + 10 + 5; 27 | } 28 | } 29 | 30 | @Override 31 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { 32 | for (TypePanel typePanel : typePanels) { 33 | typePanel.render(matrices, mouseX, mouseY, delta); 34 | } 35 | FontUtils.drawString(matrices, "FoxClickGUI Design By - Enaium", 5, this.height - FontUtils.getFontHeight(), 0xFFFFFFFF);//Don't delete 36 | super.render(matrices, mouseX, mouseY, delta); 37 | } 38 | 39 | 40 | @Override 41 | public boolean mouseClicked(double mouseX, double mouseY, int button) { 42 | for (TypePanel typePanel : typePanels) { 43 | typePanel.mouseClicked(mouseX, mouseY, button); 44 | } 45 | return false; 46 | } 47 | 48 | @Override 49 | public boolean mouseReleased(double mouseX, double mouseY, int button) { 50 | for (TypePanel typePanel : typePanels) { 51 | typePanel.mouseReleased(mouseX, mouseY, button); 52 | } 53 | return false; 54 | } 55 | 56 | 57 | private int getWidestCategory() { 58 | int width = 0; 59 | for (String name : CF4M.INSTANCE.getModule().getAllType()) { 60 | int cWidth = FontUtils.getStringWidth( 61 | name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase()); 62 | if (cWidth > width) { 63 | width = cWidth; 64 | } 65 | } 66 | return width; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/ModulePanel.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.cf4m.provider.ModuleProvider; 5 | import cn.enaium.cf4m.provider.SettingProvider; 6 | import cn.enaium.foxbase.client.clickgui.setting.BooleanSettingElement; 7 | import cn.enaium.foxbase.client.clickgui.setting.SettingElement; 8 | import cn.enaium.foxbase.client.clickgui.setting.ValueSettingElement; 9 | import cn.enaium.foxbase.client.setting.*; 10 | import cn.enaium.foxbase.client.utils.ColorUtils; 11 | import cn.enaium.foxbase.client.utils.FontUtils; 12 | import cn.enaium.foxbase.client.utils.Render2D; 13 | import net.minecraft.client.util.math.MatrixStack; 14 | 15 | import java.awt.*; 16 | import java.util.ArrayList; 17 | 18 | /** 19 | * Project: FoxBase 20 | * ----------------------------------------------------------- 21 | * Copyright © 2020-2021 | Enaium | All rights reserved. 22 | */ 23 | public class ModulePanel { 24 | 25 | private final ModuleProvider module; 26 | private boolean hovered; 27 | 28 | private boolean displaySettingElement; 29 | 30 | private final ArrayList settingElements; 31 | 32 | public ModulePanel(ModuleProvider module) { 33 | this.module = module; 34 | this.settingElements = new ArrayList<>(); 35 | ArrayList settings = module.getSetting().getAll(); 36 | if (settings != null) { 37 | for (SettingProvider setting : settings) { 38 | if (setting.getSetting() instanceof EnableSetting) { 39 | this.settingElements.add(new BooleanSettingElement(setting)); 40 | } else if (setting.getSetting() instanceof IntegerSetting || setting.getSetting() instanceof DoubleSetting || setting.getSetting() instanceof FloatSetting || setting.getSetting() instanceof LongSetting || setting.getSetting() instanceof ModeSetting) { 41 | this.settingElements.add(new ValueSettingElement(setting)); 42 | } 43 | } 44 | } 45 | } 46 | 47 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, double x, double y, double width, double height) { 48 | this.hovered = Render2D.isHovered(mouseX, mouseY, x, y, width, height); 49 | int color = ColorUtils.BG; 50 | if (this.module.getEnable()) { 51 | color = ColorUtils.TOGGLE; 52 | } 53 | if (this.hovered) { 54 | color = ColorUtils.SELECT; 55 | } 56 | 57 | Render2D.drawRectWH(matrices, x, y, width, height, color); 58 | FontUtils.drawHVCenteredString(matrices, module.getName(), x + width / 2, y + height / 2, Color.WHITE.getRGB()); 59 | if (this.displaySettingElement) { 60 | double SettingElementY = y; 61 | for (SettingElement settingElement : settingElements) { 62 | settingElement.render(matrices, mouseX, mouseY, delta, x + width, SettingElementY, getWidestSetting(), height); 63 | SettingElementY += height; 64 | } 65 | } 66 | } 67 | 68 | public void mouseClicked(double mouseX, double mouseY, int button) { 69 | if (this.hovered) { 70 | if (button == 0) { 71 | if (!this.module.getName().equals("GUI")) { 72 | module.enable(); 73 | } 74 | } else if (button == 1) { 75 | this.displaySettingElement = !displaySettingElement; 76 | } 77 | } 78 | 79 | for (SettingElement settingElement : settingElements) { 80 | settingElement.mouseClicked(mouseX, mouseY, button); 81 | } 82 | } 83 | 84 | private int getWidestSetting() { 85 | int width = 0; 86 | for (SettingProvider setting : module.getSetting().getAll()) { 87 | String name = setting.getName(); 88 | if (setting.getSetting() instanceof EnableSetting) { 89 | name = name + ": " + (setting.getSetting()).getEnable(); 90 | } else if (setting.getSetting() instanceof IntegerSetting) { 91 | name = name + ": " + setting.getSetting().getCurrent(); 92 | } else if (setting.getSetting() instanceof DoubleSetting) { 93 | name = name + ": " + setting.getSetting().getCurrent(); 94 | } else if (setting.getSetting() instanceof FloatSetting) { 95 | name = name + ": " + setting.getSetting().getCurrent(); 96 | } else if (setting.getSetting() instanceof LongSetting) { 97 | name = name + ": " + setting.getSetting().getCurrent(); 98 | } else if (setting.getSetting() instanceof ModeSetting) { 99 | name = name + ": " + setting.getSetting().getCurrent(); 100 | } 101 | int cWidth = FontUtils.getStringWidth( 102 | name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase()); 103 | if (cWidth > width) { 104 | width = cWidth; 105 | } 106 | } 107 | return width; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/TypePanel.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.cf4m.provider.ModuleProvider; 5 | import cn.enaium.foxbase.client.utils.ColorUtils; 6 | import cn.enaium.foxbase.client.utils.FontUtils; 7 | import cn.enaium.foxbase.client.utils.Render2D; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | 10 | import java.awt.*; 11 | import java.util.ArrayList; 12 | 13 | /** 14 | * Project: FoxBase 15 | * ----------------------------------------------------------- 16 | * Copyright © 2020-2021 | Enaium | All rights reserved. 17 | */ 18 | public class TypePanel { 19 | 20 | private String type; 21 | private double x; 22 | private double y; 23 | private double width; 24 | private double height; 25 | 26 | private double prevX; 27 | private double prevY; 28 | 29 | private boolean hovered; 30 | 31 | private boolean dragging; 32 | 33 | public boolean displayModulePanel; 34 | 35 | private ArrayList modulePanels; 36 | 37 | public TypePanel(String type, double x, double y, double width, double height) { 38 | this.type = type; 39 | this.x = x; 40 | this.y = y; 41 | this.width = width; 42 | this.height = height; 43 | this.modulePanels = new ArrayList<>(); 44 | ArrayList modules = new ArrayList<>(CF4M.INSTANCE.getModule().getAllByType(this.type)); 45 | for (ModuleProvider module : modules) { 46 | this.modulePanels.add(new ModulePanel(module)); 47 | } 48 | } 49 | 50 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { 51 | this.hovered = Render2D.isHovered(mouseX, mouseY, this.x, this.y, this.width, this.height); 52 | if (this.dragging) { 53 | this.x = this.prevX + mouseX; 54 | this.y = this.prevY + mouseY; 55 | } 56 | Render2D.drawRectWH(matrices, this.x, this.y, this.width, this.height, this.hovered ? ColorUtils.SELECT : ColorUtils.BG); 57 | FontUtils.drawHVCenteredString(matrices, this.type, this.x + this.width / 2, this.y + this.height / 2, Color.WHITE.getRGB()); 58 | if (this.displayModulePanel) { 59 | double moduleY = this.y + this.height; 60 | for (ModulePanel modulePanel : this.modulePanels) { 61 | modulePanel.render(matrices, mouseX, mouseY, delta, this.x + this.width / 2 - (getWidestModule() + 10) / 2.0, moduleY, getWidestModule() + 10, FontUtils.getFontHeight() + 10); 62 | moduleY += FontUtils.getFontHeight() + 10; 63 | } 64 | } 65 | } 66 | 67 | public void mouseClicked(double mouseX, double mouseY, int button) { 68 | if (this.hovered) { 69 | if (button == 0) { 70 | this.dragging = true; 71 | this.prevX = this.x - mouseX; 72 | this.prevY = this.y - mouseY; 73 | } else if (button == 1) { 74 | this.displayModulePanel = !this.displayModulePanel; 75 | } 76 | } 77 | 78 | for (ModulePanel modulePanel : this.modulePanels) { 79 | modulePanel.mouseClicked(mouseX, mouseY, button); 80 | } 81 | } 82 | 83 | public void mouseReleased(double mouseX, double mouseY, int button) { 84 | if (button == 0) { 85 | this.dragging = false; 86 | } 87 | } 88 | 89 | private int getWidestModule() { 90 | int width = 0; 91 | for (ModuleProvider module : CF4M.INSTANCE.getModule().getAll()) { 92 | String name = module.getName(); 93 | int cWidth = FontUtils.getStringWidth( 94 | name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase()); 95 | if (cWidth > width) { 96 | width = cWidth; 97 | } 98 | } 99 | return width; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/setting/BooleanSettingElement.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui.setting; 2 | 3 | import cn.enaium.cf4m.provider.SettingProvider; 4 | import cn.enaium.foxbase.client.setting.EnableSetting; 5 | import cn.enaium.foxbase.client.utils.ColorUtils; 6 | import cn.enaium.foxbase.client.utils.Render2D; 7 | import net.minecraft.client.util.math.MatrixStack; 8 | 9 | /** 10 | * Project: FoxBase 11 | * ----------------------------------------------------------- 12 | * Copyright © 2020-2021 | Enaium | All rights reserved. 13 | */ 14 | public class BooleanSettingElement extends SettingElement { 15 | 16 | private boolean hovered; 17 | 18 | public BooleanSettingElement(SettingProvider setting) { 19 | super(setting); 20 | } 21 | 22 | 23 | @Override 24 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, double x, double y, double width, double height) { 25 | super.render(matrices, mouseX, mouseY, delta, x, y, width, height); 26 | this.hovered = Render2D.isHovered(mouseX, mouseY, x + width + 2, y + 2, height - 4, height - 4); 27 | int color = ColorUtils.CHECK_BG; 28 | if (this.setting.getSetting().getEnable()) { 29 | color = ColorUtils.CHECK_TOGGLE; 30 | } 31 | if (this.hovered) { 32 | color = ColorUtils.SELECT; 33 | } 34 | Render2D.drawRectWH(matrices, x + width + 2, y + 2, height - 4, height - 4, color); 35 | } 36 | 37 | @Override 38 | public void mouseClicked(double mouseX, double mouseY, int button) { 39 | if (this.hovered && button == 0) { 40 | this.setting.getSetting().setEnable(!this.setting.getSetting().getEnable()); 41 | } 42 | super.mouseClicked(mouseX, mouseY, button); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/setting/SettingElement.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui.setting; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.cf4m.provider.SettingProvider; 5 | import cn.enaium.foxbase.client.setting.*; 6 | import cn.enaium.foxbase.client.utils.ColorUtils; 7 | import cn.enaium.foxbase.client.utils.FontUtils; 8 | import cn.enaium.foxbase.client.utils.Render2D; 9 | import net.minecraft.client.util.math.MatrixStack; 10 | 11 | import java.awt.*; 12 | 13 | /** 14 | * Project: FoxBase 15 | * ----------------------------------------------------------- 16 | * Copyright © 2020-2021 | Enaium | All rights reserved. 17 | */ 18 | public class SettingElement { 19 | 20 | protected SettingProvider setting; 21 | 22 | public SettingElement(SettingProvider setting) { 23 | this.setting = setting; 24 | } 25 | 26 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, double x, double y, double width, double height) { 27 | Render2D.drawRectWH(matrices, x, y, width + height, height, ColorUtils.BG); 28 | String name = setting.getName(); 29 | if (this.setting.getSetting() instanceof IntegerSetting) { 30 | name = name + ":" + this.setting.getSetting().getCurrent(); 31 | } else if (this.setting.getSetting() instanceof DoubleSetting) { 32 | name = name + ":" + this.setting.getSetting().getCurrent(); 33 | } else if (this.setting.getSetting() instanceof FloatSetting) { 34 | name = name + ":" + this.setting.getSetting().getCurrent(); 35 | } else if (this.setting.getSetting() instanceof LongSetting) { 36 | name = name + ":" + this.setting.getSetting().getCurrent(); 37 | } else if (this.setting.getSetting() instanceof ModeSetting) { 38 | name = name + ":" + this.setting.getSetting().getCurrent(); 39 | } 40 | FontUtils.drawHVCenteredString(matrices, name, x + width / 2, y + height / 2, Color.WHITE.getRGB()); 41 | } 42 | 43 | public void mouseClicked(double mouseX, double mouseY, int button) { 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/clickgui/setting/ValueSettingElement.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.clickgui.setting; 2 | 3 | import cn.enaium.cf4m.provider.SettingProvider; 4 | import cn.enaium.foxbase.client.setting.*; 5 | import cn.enaium.foxbase.client.utils.ColorUtils; 6 | import cn.enaium.foxbase.client.utils.FontUtils; 7 | import cn.enaium.foxbase.client.utils.Render2D; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | 10 | import java.awt.*; 11 | 12 | /** 13 | * Project: FoxBase 14 | * ----------------------------------------------------------- 15 | * Copyright © 2020-2021 | Enaium | All rights reserved. 16 | */ 17 | public class ValueSettingElement extends SettingElement { 18 | 19 | private boolean addHovered; 20 | private boolean removeHovered; 21 | 22 | public ValueSettingElement(SettingProvider setting) { 23 | super(setting); 24 | } 25 | 26 | @Override 27 | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, double x, double y, double width, double height) { 28 | super.render(matrices, mouseX, mouseY, delta, x, y, width, height); 29 | this.addHovered = Render2D.isHovered(mouseX, mouseY, x + width + 2, y + 2, height / 2 - 4, height - 4); 30 | this.removeHovered = Render2D.isHovered(mouseX, mouseY, x + width + 2 + 8, y + 2, height / 2 - 4, height - 4); 31 | Render2D.drawRectWH(matrices, x + width + 2, y + 2, height / 2 - 4, height - 4, this.addHovered ? ColorUtils.CHECK_BG : ColorUtils.SELECT); 32 | Render2D.drawRectWH(matrices, x + width + 2 + 8, y + 2, height / 2 - 4, height - 4, this.removeHovered ? ColorUtils.CHECK_BG : ColorUtils.SELECT); 33 | FontUtils.drawVCenteredString(matrices, "+", x + width + 2, y + 2 + height / 2, Color.WHITE.getRGB()); 34 | FontUtils.drawVCenteredString(matrices, "-", x + width + 2 + 8, y + 2 + height / 2, Color.WHITE.getRGB()); 35 | } 36 | 37 | @Override 38 | public void mouseClicked(double mouseX, double mouseY, int button) { 39 | if (this.addHovered && button == 0) { 40 | if (this.setting.getSetting() instanceof IntegerSetting) { 41 | if (this.setting.getSetting().getCurrent() < this.setting.getSetting().getMax()) { 42 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() + 1); 43 | } 44 | } else if (this.setting.getSetting() instanceof FloatSetting) { 45 | if (this.setting.getSetting().getCurrent() < this.setting.getSetting().getMax()) { 46 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() + 0.1F); 47 | } 48 | } else if (this.setting.getSetting() instanceof DoubleSetting) { 49 | if (this.setting.getSetting().getCurrent() < this.setting.getSetting().getMax()) { 50 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() + 0.1D); 51 | } 52 | } else if (this.setting.getSetting() instanceof LongSetting) { 53 | if (this.setting.getSetting().getCurrent() < this.setting.getSetting().getMax()) { 54 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() + 1L); 55 | } 56 | } else if (this.setting.getSetting() instanceof ModeSetting) { 57 | try { 58 | this.setting.getSetting().setCurrent(this.setting.getSetting().getModes().get(this.setting.getSetting().getCurrentModeIndex() + 1)); 59 | } catch (Exception e) { 60 | this.setting.getSetting().setCurrent(this.setting.getSetting().getModes().get(0)); 61 | } 62 | } 63 | } else if (this.removeHovered && button == 0) { 64 | if (this.setting.getSetting() instanceof IntegerSetting) { 65 | if (this.setting.getSetting().getCurrent() > this.setting.getSetting().getMin()) { 66 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() - 1); 67 | } 68 | } else if (this.setting.getSetting() instanceof FloatSetting) { 69 | if (this.setting.getSetting().getCurrent() > this.setting.getSetting().getMin()) { 70 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() - 0.1F); 71 | } 72 | } else if (this.setting.getSetting() instanceof DoubleSetting) { 73 | if (this.setting.getSetting().getCurrent() > this.setting.getSetting().getMin()) { 74 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() - 0.1D); 75 | } 76 | } else if (this.setting.getSetting() instanceof LongSetting) { 77 | if (this.setting.getSetting().getCurrent() > this.setting.getSetting().getMin()) { 78 | this.setting.getSetting().setCurrent(this.setting.getSetting().getCurrent() - 1L); 79 | } 80 | } else if (this.setting.getSetting() instanceof ModeSetting) { 81 | try { 82 | this.setting.getSetting().setCurrent(this.setting.getSetting().getModes().get(this.setting.getSetting().getCurrentModeIndex() - 1)); 83 | } catch (Exception e) { 84 | this.setting.getSetting().setCurrent(this.setting.getSetting().getModes().get(this.setting.getSetting().getModes().size() - 1)); 85 | } 86 | } 87 | } 88 | super.mouseClicked(mouseX, mouseY, button); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/command/SetCommand.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.command; 2 | 3 | import cn.enaium.cf4m.annotation.Autowired; 4 | import cn.enaium.cf4m.annotation.command.Command; 5 | import cn.enaium.cf4m.annotation.command.Exec; 6 | import cn.enaium.cf4m.annotation.command.Param; 7 | import cn.enaium.cf4m.container.ModuleContainer; 8 | import cn.enaium.cf4m.provider.ModuleProvider; 9 | import cn.enaium.cf4m.provider.SettingProvider; 10 | import cn.enaium.foxbase.client.setting.*; 11 | import cn.enaium.foxbase.client.utils.ChatUtils; 12 | 13 | import java.util.ArrayList; 14 | 15 | /** 16 | * Project: FoxBase 17 | * ----------------------------------------------------------- 18 | * Copyright © 2020-2021 | Enaium | All rights reserved. 19 | */ 20 | @Command({"s", "setting"}) 21 | public class SetCommand { 22 | 23 | @Autowired 24 | private ModuleContainer module; 25 | 26 | private ModuleProvider currentModule; 27 | private ArrayList settings; 28 | private SettingProvider currentSetting; 29 | 30 | @Exec 31 | public void exec(@Param("Module") String moduleName) { 32 | currentModule = module.getByName(moduleName); 33 | if (currentModule == null) { 34 | ChatUtils.message("The module with the name \"" + moduleName + "\" does not exist."); 35 | return; 36 | } 37 | 38 | settings = currentModule.getSetting().getAll(); 39 | 40 | if (settings == null) { 41 | ChatUtils.message("The module with the name \"" + moduleName + "\" no setting exists."); 42 | return; 43 | } 44 | 45 | ChatUtils.message("Here are the list of settings:"); 46 | 47 | for (SettingProvider s : settings) { 48 | ChatUtils.message(s.getName() + "(" + s.getClass().getSimpleName() + ")" + s.getDescription()); 49 | if (s instanceof ModeSetting) { 50 | ((ModeSetting) s).getModes().forEach(ChatUtils::message); 51 | } 52 | } 53 | } 54 | 55 | @Exec 56 | public void exec(@Param("Module") String moduleName, @Param("Setting") String settingName) { 57 | exec(moduleName); 58 | SettingProvider setting = currentModule.getSetting().getByName(settingName); 59 | if (setting != null) { 60 | currentSetting = setting; 61 | ChatUtils.message(currentSetting.getName() + "|" + currentSetting.getClass().getSimpleName()); 62 | } else { 63 | ChatUtils.message("The setting with the name \"" + settingName + "\" does not exist."); 64 | } 65 | } 66 | 67 | @Exec 68 | public void exec(@Param("Module") String moduleName, @Param("Setting") String settingName, @Param("SettingValue") String settingValue) { 69 | exec(moduleName, settingName); 70 | if (currentSetting instanceof EnableSetting) { 71 | ((EnableSetting) currentSetting.getSetting()).setEnable(Boolean.parseBoolean(settingName)); 72 | } else if (currentSetting instanceof IntegerSetting) { 73 | ((IntegerSetting) currentSetting.getSetting()).setCurrent(Integer.parseInt(settingName)); 74 | } else if (currentSetting instanceof DoubleSetting) { 75 | ((DoubleSetting) currentSetting.getSetting()).setCurrent(Double.parseDouble(settingName)); 76 | } else if (currentSetting instanceof LongSetting) { 77 | ((LongSetting) currentSetting.getSetting()).setCurrent(Long.parseLong(settingName)); 78 | } else if (currentSetting instanceof ModeSetting) { 79 | ((ModeSetting) currentSetting.getSetting()).setCurrent(settingValue); 80 | } 81 | 82 | ChatUtils.message(currentSetting.getName() + " has setting to " + settingValue + "."); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/command/ToggleCommand.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.command; 2 | 3 | import cn.enaium.cf4m.annotation.Autowired; 4 | import cn.enaium.cf4m.annotation.command.Command; 5 | import cn.enaium.cf4m.annotation.command.Exec; 6 | import cn.enaium.cf4m.annotation.command.Param; 7 | import cn.enaium.cf4m.container.ModuleContainer; 8 | import cn.enaium.cf4m.provider.ModuleProvider; 9 | import cn.enaium.foxbase.client.utils.ChatUtils; 10 | 11 | /** 12 | * Project: FoxBase 13 | * ----------------------------------------------------------- 14 | * Copyright © 2020-2021 | Enaium | All rights reserved. 15 | */ 16 | @Command({"t", "toggle"}) 17 | public class ToggleCommand { 18 | 19 | @Autowired 20 | private ModuleContainer moduleContainer; 21 | 22 | @Exec 23 | private void exec(@Param("module") String name) { 24 | ModuleProvider module = moduleContainer.getByName(name); 25 | 26 | if (module == null) { 27 | ChatUtils.message("The module with the name " + name + " does not exist."); 28 | return; 29 | } 30 | 31 | module.enable(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/config/ModuleConfig.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.config; 2 | 3 | import cn.enaium.cf4m.annotation.Autowired; 4 | import cn.enaium.cf4m.annotation.config.Config; 5 | import cn.enaium.cf4m.annotation.config.Load; 6 | import cn.enaium.cf4m.annotation.config.Save; 7 | import cn.enaium.cf4m.container.ConfigContainer; 8 | import cn.enaium.cf4m.container.ModuleContainer; 9 | import cn.enaium.cf4m.provider.ModuleProvider; 10 | import com.google.gson.Gson; 11 | import com.google.gson.JsonArray; 12 | import com.google.gson.JsonElement; 13 | import com.google.gson.JsonObject; 14 | import org.apache.commons.io.FileUtils; 15 | 16 | import java.io.File; 17 | import java.io.IOException; 18 | 19 | @Autowired 20 | @Config("Modules") 21 | public class ModuleConfig { 22 | 23 | private ModuleContainer module; 24 | private ConfigContainer config; 25 | 26 | @Load 27 | public void load() { 28 | for (ModuleProvider module : module.getAll()) { 29 | JsonArray jsonArray = new JsonArray(); 30 | try { 31 | jsonArray = new Gson().fromJson(read(config.getByInstance(this).getPath()), JsonArray.class); 32 | } catch (IOException e) { 33 | e.printStackTrace(); 34 | } 35 | for (JsonElement jsonElement : jsonArray) { 36 | JsonObject jsonObject = jsonElement.getAsJsonObject(); 37 | if (module.getName().equals(new Gson().fromJson(jsonObject, JsonObject.class).get("name").getAsString())) { 38 | if (jsonObject.get("enable").getAsBoolean()) { 39 | module.enable(); 40 | } 41 | module.setKey(jsonObject.get("key").getAsInt()); 42 | } 43 | } 44 | } 45 | } 46 | 47 | @Save 48 | public void save() { 49 | JsonArray jsonArray = new JsonArray(); 50 | for (ModuleProvider module : module.getAll()) { 51 | JsonObject jsonObject = new JsonObject(); 52 | jsonObject.addProperty("name", module.getName()); 53 | jsonObject.addProperty("enable", module.getEnable()); 54 | jsonObject.addProperty("key", module.getKey()); 55 | jsonArray.add(jsonObject); 56 | } 57 | try { 58 | write(config.getByInstance(this).getPath(), new Gson().toJson(jsonArray)); 59 | } catch (IOException e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | 64 | private String read(String path) throws IOException { 65 | return FileUtils.readFileToString(new File(path)); 66 | } 67 | 68 | private void write(String path, String string) throws IOException { 69 | FileUtils.writeStringToFile(new File(path), string, "UTF-8"); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/configuration/FoxBaseConfig.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.configuration; 2 | 3 | import cn.enaium.cf4m.configuration.CommandConfiguration; 4 | import cn.enaium.foxbase.client.utils.ChatUtils; 5 | 6 | /** 7 | * Project: FoxBase 8 | * ----------------------------------------------------------- 9 | * Copyright © 2020-2021 | Enaium | All rights reserved. 10 | */ 11 | public class FoxBaseConfig extends CommandConfiguration { 12 | @Override 13 | public void message(String message) { 14 | ChatUtils.message(message); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/event/Events.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.event; 2 | 3 | import net.minecraft.client.util.math.MatrixStack; 4 | 5 | /** 6 | * Project: FoxBase 7 | * Author: Enaium 8 | */ 9 | public class Events { 10 | 11 | public static class UpdatingEvent { 12 | } 13 | 14 | public static class UpdatedEvent { 15 | } 16 | 17 | public static class Render2DEvent { 18 | private final MatrixStack matrixStack; 19 | 20 | public Render2DEvent(MatrixStack matrixStack) { 21 | this.matrixStack = matrixStack; 22 | } 23 | 24 | public MatrixStack getMatrixStack() { 25 | return matrixStack; 26 | } 27 | } 28 | 29 | public static class Render3DEvent { 30 | 31 | public float particleTicks; 32 | 33 | public Render3DEvent(float particleTicks) { 34 | this.particleTicks = particleTicks; 35 | } 36 | 37 | } 38 | 39 | public static class KeyboardEvent { 40 | private final int key; 41 | 42 | public KeyboardEvent(int key) { 43 | this.key = key; 44 | } 45 | 46 | public int getKey() { 47 | return key; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/Type.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module; 2 | 3 | /** 4 | * @author Enaium 5 | */ 6 | public class Type { 7 | public static final String COMBAT = "COMBAT"; 8 | public static final String MOVEMENT = "MOVEMENT"; 9 | public static final String RENDER = "MOVEMENT"; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/combat/Aura.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module.combat; 2 | 3 | import cn.enaium.cf4m.annotation.Event; 4 | import cn.enaium.cf4m.annotation.module.Module; 5 | import cn.enaium.cf4m.annotation.module.Setting; 6 | import cn.enaium.foxbase.client.event.Events.UpdatingEvent; 7 | import cn.enaium.foxbase.client.setting.IntegerSetting; 8 | import cn.enaium.foxbase.client.setting.ModeSetting; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | 13 | /** 14 | * Project: FoxBase 15 | * ----------------------------------------------------------- 16 | * Copyright © 2020-2021 | Enaium | All rights reserved. 17 | */ 18 | @Module("Aura") 19 | public class Aura { 20 | 21 | @Setting("CPS") 22 | IntegerSetting cps = new IntegerSetting(7, 1, 20); 23 | 24 | @Setting("Mode") 25 | ModeSetting mode = new ModeSetting("MOD1", new ArrayList<>(Arrays.asList("MOD1", "MOD2", "MOD3"))); 26 | 27 | @Event 28 | public void onUpdate(UpdatingEvent e) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/movement/Sprint.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module.movement; 2 | 3 | import cn.enaium.cf4m.annotation.Event; 4 | import cn.enaium.cf4m.annotation.module.Module; 5 | import cn.enaium.foxbase.client.event.Events.UpdatedEvent; 6 | import net.minecraft.client.MinecraftClient; 7 | import org.lwjgl.glfw.GLFW; 8 | 9 | import static cn.enaium.foxbase.client.module.Type.MOVEMENT; 10 | 11 | /** 12 | * Project: FoxBase 13 | * ----------------------------------------------------------- 14 | * Copyright © 2020-2021 | Enaium | All rights reserved. 15 | */ 16 | @Module(value = "Sprint", key = GLFW.GLFW_KEY_V, type = MOVEMENT) 17 | public class Sprint { 18 | 19 | @Event 20 | public void onUpdate(UpdatedEvent e) { 21 | assert MinecraftClient.getInstance().player != null; 22 | MinecraftClient.getInstance().player.setSprinting(true); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/render/FullBright.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module.render; 2 | 3 | import cn.enaium.cf4m.annotation.module.Disable; 4 | import cn.enaium.cf4m.annotation.module.Enable; 5 | import cn.enaium.cf4m.annotation.module.Module; 6 | import net.minecraft.client.MinecraftClient; 7 | import org.lwjgl.glfw.GLFW; 8 | 9 | import static cn.enaium.foxbase.client.module.Type.RENDER; 10 | 11 | /** 12 | * Project: FoxBase 13 | * ----------------------------------------------------------- 14 | * Copyright © 2020-2021 | Enaium | All rights reserved. 15 | */ 16 | @Module(value = "FullBright", key = GLFW.GLFW_KEY_G, type = RENDER) 17 | public class FullBright { 18 | 19 | @Enable 20 | public void onEnable() { 21 | MinecraftClient.getInstance().options.gamma = 300; 22 | } 23 | 24 | @Disable 25 | public void onDisable() { 26 | MinecraftClient.getInstance().options.gamma = 1; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/render/GUI.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module.render; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.cf4m.annotation.module.Enable; 5 | import cn.enaium.cf4m.annotation.module.Module; 6 | import cn.enaium.foxbase.client.clickgui.ClickGUI; 7 | import net.minecraft.client.MinecraftClient; 8 | import org.lwjgl.glfw.GLFW; 9 | 10 | import static cn.enaium.foxbase.client.module.Type.RENDER; 11 | 12 | /** 13 | * Project: FoxBase 14 | * ----------------------------------------------------------- 15 | * Copyright © 2020-2021 | Enaium | All rights reserved. 16 | */ 17 | @Module(value = "GUI", key = GLFW.GLFW_KEY_RIGHT_SHIFT, type = RENDER) 18 | public class GUI { 19 | @Enable 20 | public void onEnable() { 21 | MinecraftClient.getInstance().setScreen(new ClickGUI()); 22 | CF4M.INSTANCE.getModule().getByInstance(this).enable(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/module/render/HUD.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.module.render; 2 | 3 | import cn.enaium.cf4m.annotation.Autowired; 4 | import cn.enaium.cf4m.annotation.Event; 5 | import cn.enaium.cf4m.annotation.module.Module; 6 | import cn.enaium.cf4m.CF4M; 7 | import cn.enaium.cf4m.annotation.module.Setting; 8 | import cn.enaium.cf4m.container.ModuleContainer; 9 | import cn.enaium.cf4m.provider.ModuleProvider; 10 | import cn.enaium.cf4m.provider.SettingProvider; 11 | import cn.enaium.foxbase.client.FoxBase; 12 | import cn.enaium.foxbase.client.event.Events.*; 13 | import cn.enaium.foxbase.client.setting.*; 14 | import cn.enaium.foxbase.client.utils.ColorUtils; 15 | import cn.enaium.foxbase.client.utils.FontUtils; 16 | import cn.enaium.foxbase.client.utils.Render2D; 17 | import com.google.common.collect.Lists; 18 | import org.lwjgl.glfw.GLFW; 19 | 20 | import java.awt.*; 21 | import java.util.ArrayList; 22 | import java.util.stream.Collectors; 23 | 24 | import static cn.enaium.foxbase.client.module.Type.RENDER; 25 | 26 | /** 27 | * Project: FoxBase 28 | * ----------------------------------------------------------- 29 | * Copyright © 2020-2021 | Enaium | All rights reserved. 30 | */ 31 | @Autowired 32 | @Module(value = "HUD", key = GLFW.GLFW_KEY_O, type = RENDER) 33 | public class HUD { 34 | 35 | private ModuleContainer module; 36 | 37 | private int currentTypeIndex, currentModIndex, currentSettingIndex; 38 | private boolean editMode; 39 | 40 | private int screen; 41 | 42 | @Setting("TabGUI") 43 | private EnableSetting tabGUI = new EnableSetting(true); 44 | 45 | @Setting("ToggleList") 46 | private EnableSetting toggleList = new EnableSetting(true); 47 | 48 | public HUD() { 49 | this.currentTypeIndex = 0; 50 | this.currentModIndex = 0; 51 | this.currentSettingIndex = 0; 52 | this.editMode = false; 53 | this.screen = 0; 54 | } 55 | 56 | @Event 57 | public void toggleList(Render2DEvent e) { 58 | if (!this.toggleList.getEnable()) { 59 | return; 60 | } 61 | 62 | int yStart = 1; 63 | 64 | 65 | for (ModuleProvider module : module.getAll().stream().filter(ModuleProvider::getEnable).sorted((o1, o2) -> FontUtils.getStringWidth(o2.getName()) - FontUtils.getStringWidth(o1.getName())).collect(Collectors.toCollection(Lists::newArrayList))) { 66 | 67 | int startX = Render2D.getScaledWidth() - FontUtils.getStringWidth(module.getName()) - 6; 68 | 69 | Render2D.drawRect(e.getMatrixStack(), startX, yStart - 1, Render2D.getScaledWidth(), yStart + 12, ColorUtils.BG); 70 | Render2D.drawRect(e.getMatrixStack(), Render2D.getScaledWidth() - 2, yStart - 1, Render2D.getScaledWidth(), yStart + 12, ColorUtils.SELECT); 71 | 72 | Render2D.drawVerticalLine(e.getMatrixStack(), startX - 1, yStart - 2, yStart + 12, ColorUtils.SELECT); 73 | Render2D.drawHorizontalLine(e.getMatrixStack(), startX - 1, Render2D.getScaledWidth(), yStart + 12, ColorUtils.SELECT); 74 | 75 | FontUtils.drawStringWithShadow(e.getMatrixStack(), module.getName(), startX + 3, yStart, ColorUtils.SELECT); 76 | 77 | yStart += 13; 78 | } 79 | } 80 | 81 | @Event 82 | public void onTabGUI(Render2DEvent e) { 83 | if (!this.tabGUI.getEnable()) { 84 | return; 85 | } 86 | 87 | FontUtils.drawStringWithShadow(e.getMatrixStack(), FoxBase.instance.name + " B" 88 | + FoxBase.instance.version, 5, 5, new Color(67, 0, 99).getRGB()); 89 | int startX = 5; 90 | int startY = (5 + 9) + 2; 91 | Render2D.drawRect(e.getMatrixStack(), startX, startY, startX + this.getWidestType() + 5, 92 | startY + this.module.getAllType().size() * (9 + 2), ColorUtils.BG); 93 | for (String name : this.module.getAllType()) { 94 | if (this.getCurrentType().equals(name)) { 95 | Render2D.drawRect(e.getMatrixStack(), startX + 1, startY, startX + this.getWidestType() + 5 - 1, startY + 9 + 2, 96 | ColorUtils.SELECT); 97 | } 98 | 99 | FontUtils.drawStringWithShadow(e.getMatrixStack(), name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(), 100 | startX + 2 + (this.getCurrentType().equals(name) ? 2 : 0), startY + 2, -1); 101 | startY += 9 + 2; 102 | } 103 | 104 | if (screen == 1 || screen == 2) { 105 | int startModsX = startX + this.getWidestType() + 6; 106 | int startModsY = ((5 + 9) + 2) + currentTypeIndex * (9 + 2); 107 | Render2D.drawRect(e.getMatrixStack(), startModsX, startModsY, startModsX + this.getWidestMod() + 5, 108 | startModsY + this.getModsForCurrentType().size() * (9 + 2), ColorUtils.BG); 109 | for (ModuleProvider module : getModsForCurrentType()) { 110 | if (this.getCurrentModule().equals(module)) { 111 | Render2D.drawRect(e.getMatrixStack(), startModsX + 1, startModsY, startModsX + this.getWidestMod() + 5 - 1, 112 | startModsY + 9 + 2, ColorUtils.SELECT); 113 | } 114 | FontUtils.drawStringWithShadow(e.getMatrixStack(), module.getName() + (module.getSetting().getAll().size() != 0 ? ">" : ""), startModsX + 2 + (this.getCurrentModule().equals(module) ? 2 : 0), 115 | startModsY + 2, module.getEnable() ? -1 : Color.GRAY.getRGB()); 116 | startModsY += 9 + 2; 117 | } 118 | } 119 | if (screen == 2) { 120 | int startSettingX = (startX + this.getWidestType() + 6) + this.getWidestType() + 8; 121 | int startSettingY = ((5 + 9) + 2) + (currentTypeIndex * (9 + 2)) + currentModIndex * (9 + 2); 122 | 123 | Render2D.drawRect(e.getMatrixStack(), startSettingX, startSettingY, startSettingX + this.getWidestSetting() + 5, 124 | startSettingY + this.getSettingForCurrentMod().size() * (9 + 2), ColorUtils.BG); 125 | for (SettingProvider setting : this.getSettingForCurrentMod()) { 126 | 127 | if (this.getCurrentSetting().equals(setting)) { 128 | Render2D.drawRect(e.getMatrixStack(), startSettingX + 1, startSettingY, startSettingX + this.getWidestSetting() + 5 - 1, 129 | startSettingY + 9 + 2, ColorUtils.SELECT); 130 | } 131 | if (setting.getSetting() instanceof EnableSetting) { 132 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + ((EnableSetting) setting.getSetting()).getEnable(), 133 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 134 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 135 | } else if (setting.getSetting() instanceof IntegerSetting) { 136 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + setting.getSetting().getCurrent(), 137 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 138 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 139 | } else if (setting.getSetting() instanceof DoubleSetting) { 140 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + setting.getSetting().getCurrent(), 141 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 142 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 143 | } else if (setting.getSetting() instanceof FloatSetting) { 144 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + setting.getSetting().getCurrent(), 145 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 146 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 147 | } else if (setting.getSetting() instanceof LongSetting) { 148 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + setting.getSetting().getCurrent(), 149 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 150 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 151 | } else if (setting.getSetting() instanceof ModeSetting) { 152 | FontUtils.drawStringWithShadow(e.getMatrixStack(), setting.getName() + ": " + setting.getSetting().getCurrent(), 153 | startSettingX + 2 + (this.getCurrentSetting().equals(setting) ? 2 : 0), startSettingY + 2, 154 | editMode && this.getCurrentSetting().equals(setting) ? -1 : Color.GRAY.getRGB()); 155 | } 156 | startSettingY += 9 + 2; 157 | } 158 | } 159 | } 160 | 161 | private void up() { 162 | if (this.currentTypeIndex > 0 && this.screen == 0) { 163 | this.currentTypeIndex--; 164 | } else if (this.currentTypeIndex == 0 && this.screen == 0) { 165 | this.currentTypeIndex = this.module.getAllType().size() - 1; 166 | } else if (this.currentModIndex > 0 && this.screen == 1) { 167 | this.currentModIndex--; 168 | } else if (this.currentModIndex == 0 && this.screen == 1) { 169 | this.currentModIndex = this.getModsForCurrentType().size() - 1; 170 | } else if (this.currentSettingIndex > 0 && this.screen == 2 && !this.editMode) { 171 | this.currentSettingIndex--; 172 | } else if (this.currentSettingIndex == 0 && this.screen == 2 && !this.editMode) { 173 | this.currentSettingIndex = this.getSettingForCurrentMod().size() - 1; 174 | } 175 | 176 | if (editMode) { 177 | SettingProvider setting = this.getCurrentSetting(); 178 | if (setting.getSetting() instanceof EnableSetting) { 179 | setting.getSetting().setEnable(!setting.getSetting().getEnable()); 180 | } else if (setting.getSetting() instanceof IntegerSetting) { 181 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() + 1); 182 | } else if (setting.getSetting() instanceof DoubleSetting) { 183 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() + 0.1D); 184 | } else if (setting.getSetting() instanceof FloatSetting) { 185 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() + 0.1F); 186 | } else if (setting.getSetting() instanceof LongSetting) { 187 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() + 1L); 188 | } else if (setting.getSetting() instanceof ModeSetting) { 189 | try { 190 | setting.getSetting().setCurrent(setting.getSetting().getModes().get(setting.getSetting().getCurrentModeIndex() - 1)); 191 | } catch (Exception e) { 192 | setting.getSetting().setCurrent(setting.getSetting().getModes().get(setting.getSetting().getModes().size() - 1)); 193 | } 194 | 195 | } 196 | } 197 | } 198 | 199 | private void down() { 200 | if (this.currentTypeIndex < this.module.getAllType().size() - 1 && this.screen == 0) { 201 | this.currentTypeIndex++; 202 | } else if (this.currentTypeIndex == this.module.getAllType().size() - 1 && this.screen == 0) { 203 | this.currentTypeIndex = 0; 204 | } else if (this.currentModIndex < this.getModsForCurrentType().size() - 1 && this.screen == 1) { 205 | this.currentModIndex++; 206 | } else if (this.currentModIndex == this.getModsForCurrentType().size() - 1 && this.screen == 1) { 207 | this.currentModIndex = 0; 208 | } else if (this.currentSettingIndex < this.getSettingForCurrentMod().size() - 1 && this.screen == 2 209 | && !this.editMode) { 210 | this.currentSettingIndex++; 211 | } else if (this.currentSettingIndex == this.getSettingForCurrentMod().size() - 1 && this.screen == 2 212 | && !this.editMode) { 213 | this.currentSettingIndex = 0; 214 | } 215 | 216 | if (editMode) { 217 | SettingProvider setting = this.getCurrentSetting(); 218 | if (setting.getSetting() instanceof EnableSetting) { 219 | setting.getSetting().setEnable(!setting.getSetting().getEnable()); 220 | } else if (setting.getSetting() instanceof IntegerSetting) { 221 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() - 1); 222 | } else if (setting.getSetting() instanceof DoubleSetting) { 223 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() - 0.1D); 224 | } else if (setting.getSetting() instanceof FloatSetting) { 225 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() - 0.1F); 226 | } else if (setting.getSetting() instanceof LongSetting) { 227 | setting.getSetting().setCurrent(setting.getSetting().getCurrent() - 1L); 228 | } else if (setting instanceof ModeSetting) { 229 | try { 230 | setting.getSetting().setCurrent(setting.getSetting().getModes().get(setting.getSetting().getCurrentModeIndex() + 1)); 231 | } catch (Exception e) { 232 | setting.getSetting().setCurrent(setting.getSetting().getModes().get(0)); 233 | } 234 | 235 | } 236 | } 237 | } 238 | 239 | 240 | private void right(int key) { 241 | if (this.screen == 0) { 242 | this.screen = 1; 243 | } else if (this.screen == 1 && this.getCurrentModule() != null && this.getSettingForCurrentMod() == null) { 244 | this.getCurrentModule().enable(); 245 | } else if (this.screen == 1 && this.getSettingForCurrentMod() != null && this.getCurrentModule() != null && key == GLFW.GLFW_KEY_ENTER) { 246 | this.getCurrentModule().enable(); 247 | } else if (this.screen == 1 && this.getSettingForCurrentMod() != null && this.getCurrentModule() != null) { 248 | this.screen = 2; 249 | } else if (this.screen == 2) { 250 | this.editMode = !this.editMode; 251 | } 252 | 253 | } 254 | 255 | private void left() { 256 | if (this.screen == 1) { 257 | this.screen = 0; 258 | this.currentModIndex = 0; 259 | } else if (this.screen == 2) { 260 | this.screen = 1; 261 | this.currentSettingIndex = 0; 262 | } 263 | 264 | } 265 | 266 | @Event 267 | public void onKey(KeyboardEvent e) { 268 | switch (e.getKey()) { 269 | case GLFW.GLFW_KEY_UP: 270 | this.up(); 271 | break; 272 | case GLFW.GLFW_KEY_DOWN: 273 | this.down(); 274 | break; 275 | case GLFW.GLFW_KEY_RIGHT: 276 | this.right(GLFW.GLFW_KEY_RIGHT); 277 | break; 278 | case GLFW.GLFW_KEY_LEFT: 279 | this.left(); 280 | break; 281 | case GLFW.GLFW_KEY_ENTER: 282 | this.right(GLFW.GLFW_KEY_ENTER); 283 | break; 284 | } 285 | } 286 | 287 | private SettingProvider getCurrentSetting() { 288 | return getSettingForCurrentMod().get(currentSettingIndex); 289 | } 290 | 291 | private ArrayList getSettingForCurrentMod() { 292 | return getCurrentModule().getSetting().getAll(); 293 | } 294 | 295 | private String getCurrentType() { 296 | return this.module.getAllType().get(this.currentTypeIndex); 297 | } 298 | 299 | private ModuleProvider getCurrentModule() { 300 | return getModsForCurrentType().get(currentModIndex); 301 | } 302 | 303 | private ArrayList getModsForCurrentType() { 304 | return module.getAllByType(getCurrentType()); 305 | } 306 | 307 | private int getWidestSetting() { 308 | int width = 0; 309 | for (SettingProvider setting : getSettingForCurrentMod()) { 310 | String name; 311 | if (setting.getSetting() instanceof EnableSetting) { 312 | name = setting.getName() + ": " + (setting.getSetting()).getEnable(); 313 | } else if (setting.getSetting() instanceof IntegerSetting) { 314 | name = setting.getName() + ": " + setting.getSetting().getCurrent(); 315 | } else if (setting.getSetting() instanceof DoubleSetting) { 316 | name = setting.getName() + ": " + setting.getSetting().getCurrent(); 317 | } else if (setting.getSetting() instanceof FloatSetting) { 318 | name = setting.getName() + ": " + setting.getSetting().getCurrent(); 319 | } else if (setting.getSetting() instanceof LongSetting) { 320 | name = setting.getName() + ": " + setting.getSetting().getCurrent(); 321 | } else if (setting.getSetting() instanceof ModeSetting) { 322 | name = setting.getName() + ": " + setting.getSetting().getCurrent(); 323 | } else { 324 | name = "NULL"; 325 | } 326 | if (FontUtils.getStringWidth(name) > width) { 327 | width = FontUtils.getStringWidth(name); 328 | } 329 | } 330 | return width; 331 | } 332 | 333 | private int getWidestMod() { 334 | int width = 0; 335 | for (ModuleProvider module : module.getAll()) { 336 | int cWidth = FontUtils.getStringWidth(module.getName()); 337 | if (cWidth > width) { 338 | width = cWidth; 339 | } 340 | } 341 | return width; 342 | } 343 | 344 | private int getWidestType() { 345 | int width = 0; 346 | for (String name : this.module.getAllType()) { 347 | int cWidth = FontUtils.getStringWidth( 348 | name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase()); 349 | if (cWidth > width) { 350 | width = cWidth; 351 | } 352 | } 353 | return width; 354 | } 355 | 356 | 357 | } 358 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/DoubleSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | /** 4 | * Project: FoxBase 5 | * ----------------------------------------------------------- 6 | * Copyright © 2020-2021 | Enaium | All rights reserved. 7 | */ 8 | public class DoubleSetting { 9 | 10 | private Double current; 11 | private Double min; 12 | private Double max; 13 | 14 | public DoubleSetting(Double current, Double min, Double max) { 15 | this.current = current; 16 | this.min = min; 17 | this.max = max; 18 | } 19 | 20 | public Double getCurrent() { 21 | return current; 22 | } 23 | 24 | public void setCurrent(Double current) { 25 | this.current = current; 26 | } 27 | 28 | public Double getMin() { 29 | return min; 30 | } 31 | 32 | public void setMin(Double min) { 33 | this.min = min; 34 | } 35 | 36 | public Double getMax() { 37 | return max; 38 | } 39 | 40 | public void setMax(Double max) { 41 | this.max = max; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/EnableSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | /** 4 | * Project: FoxBase 5 | * ----------------------------------------------------------- 6 | * Copyright © 2020-2021 | Enaium | All rights reserved. 7 | */ 8 | public class EnableSetting { 9 | 10 | private boolean enable; 11 | 12 | public EnableSetting(boolean enable) { 13 | this.enable = enable; 14 | } 15 | 16 | public boolean getEnable() { 17 | return enable; 18 | } 19 | 20 | public void setEnable(boolean enable) { 21 | this.enable = enable; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/FloatSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | /** 4 | * Project: FoxBase 5 | * ----------------------------------------------------------- 6 | * Copyright © 2020-2021 | Enaium | All rights reserved. 7 | */ 8 | public class FloatSetting { 9 | 10 | private Float current; 11 | private Float min; 12 | private Float max; 13 | 14 | public FloatSetting(Float current, Float min, Float max) { 15 | this.current = current; 16 | this.min = min; 17 | this.max = max; 18 | } 19 | 20 | public Float getCurrent() { 21 | return current; 22 | } 23 | 24 | public void setCurrent(Float current) { 25 | this.current = current; 26 | } 27 | 28 | public Float getMin() { 29 | return min; 30 | } 31 | 32 | public void setMin(Float min) { 33 | this.min = min; 34 | } 35 | 36 | public Float getMax() { 37 | return max; 38 | } 39 | 40 | public void setMax(Float max) { 41 | this.max = max; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/IntegerSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | /** 4 | * Project: FoxBase 5 | * ----------------------------------------------------------- 6 | * Copyright © 2020-2021 | Enaium | All rights reserved. 7 | */ 8 | public class IntegerSetting { 9 | 10 | private Integer current; 11 | private Integer min; 12 | private Integer max; 13 | 14 | public IntegerSetting(Integer current, Integer min, Integer max) { 15 | this.current = current; 16 | this.min = min; 17 | this.max = max; 18 | } 19 | 20 | public Integer getCurrent() { 21 | return current; 22 | } 23 | 24 | public void setCurrent(Integer current) { 25 | this.current = current; 26 | } 27 | 28 | public Integer getMin() { 29 | return min; 30 | } 31 | 32 | public void setMin(Integer min) { 33 | this.min = min; 34 | } 35 | 36 | public Integer getMax() { 37 | return max; 38 | } 39 | 40 | public void setMax(Integer max) { 41 | this.max = max; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/LongSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | /** 4 | * Project: FoxBase 5 | * ----------------------------------------------------------- 6 | * Copyright © 2020-2021 | Enaium | All rights reserved. 7 | */ 8 | public class LongSetting { 9 | 10 | private Long current; 11 | private Long min; 12 | private Long max; 13 | 14 | public LongSetting(Long current, Long min, Long max) { 15 | this.current = current; 16 | this.min = min; 17 | this.max = max; 18 | } 19 | 20 | public Long getCurrent() { 21 | return current; 22 | } 23 | 24 | public void setCurrent(Long current) { 25 | this.current = current; 26 | } 27 | 28 | public Long getMin() { 29 | return min; 30 | } 31 | 32 | public void setMin(Long min) { 33 | this.min = min; 34 | } 35 | 36 | public Long getMax() { 37 | return max; 38 | } 39 | 40 | public void setMax(Long max) { 41 | this.max = max; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/setting/ModeSetting.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.setting; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Project: FoxBase 7 | * ----------------------------------------------------------- 8 | * Copyright © 2020-2021 | Enaium | All rights reserved. 9 | */ 10 | public class ModeSetting { 11 | 12 | private String current; 13 | private final List modes; 14 | 15 | public ModeSetting(String current, List modes) { 16 | this.current = current; 17 | this.modes = modes; 18 | } 19 | 20 | public String getCurrent() { 21 | return current; 22 | } 23 | 24 | public void setCurrent(String current) { 25 | this.current = current; 26 | } 27 | 28 | public List getModes() { 29 | return modes; 30 | } 31 | 32 | public int getCurrentModeIndex() { 33 | int index = 0; 34 | for (String s : modes) { 35 | if (s.equalsIgnoreCase(current)) { 36 | return index; 37 | } 38 | index++; 39 | } 40 | return index; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/utils/ChatUtils.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.utils; 2 | 3 | import cn.enaium.foxbase.client.FoxBase; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.text.LiteralText; 6 | import net.minecraft.util.Formatting; 7 | 8 | /** 9 | * @author Enaium 10 | */ 11 | public class ChatUtils { 12 | public static void message(String message) { 13 | MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText( 14 | Formatting.WHITE + "[" + Formatting.RED + FoxBase.instance.name + Formatting.WHITE + "] " + message)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/utils/ColorUtils.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.utils; 2 | 3 | import java.awt.*; 4 | 5 | public class ColorUtils { 6 | public static final int SELECT = new Color(33, 170, 47).getRGB(); 7 | public static final int BG = new Color(23, 23, 23).getRGB(); 8 | public static final int TOGGLE = new Color(123, 123, 123).getRGB(); 9 | public static final int CHECK_BG = new Color(123, 123, 123).getRGB(); 10 | public static final int CHECK_TOGGLE = new Color(123, 233, 123).getRGB(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/utils/FontUtils.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.utils; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.font.TextRenderer; 5 | import net.minecraft.client.util.math.MatrixStack; 6 | 7 | public class FontUtils { 8 | 9 | public static TextRenderer tr = MinecraftClient.getInstance().textRenderer; 10 | 11 | public static void drawString(MatrixStack matrices, String string, int x, int y, int color) { 12 | tr.draw(matrices, string, x, y, color); 13 | } 14 | 15 | public static void drawString(MatrixStack matrices, String string, float x, float y, int color) { 16 | tr.draw(matrices, string, x, y, color); 17 | } 18 | 19 | public static void drawStringWithShadow(MatrixStack matrices, String string, int x, int y, int color) { 20 | tr.drawWithShadow(matrices, string, x, y, color); 21 | } 22 | 23 | public static void drawStringWithShadow(MatrixStack matrices, String string, double x, double y, int color) { 24 | tr.drawWithShadow(matrices, string, (float) x, (float) y, color); 25 | } 26 | 27 | public static void drawStringWithShadow(MatrixStack matrices, String string, float x, float y, int color) { 28 | tr.drawWithShadow(matrices, string, x, y, color); 29 | } 30 | 31 | public static void drawHCenteredString(MatrixStack matrices, String text, int x, int y, int color) { 32 | tr.draw(matrices, text, x - tr.getWidth(text) / 2, y, color); 33 | } 34 | 35 | public static void drawHCenteredString(MatrixStack matrices, String text, double x, double y, int color) { 36 | tr.draw(matrices, text, (float) x - tr.getWidth(text) / 2, (float) y, color); 37 | } 38 | 39 | public static void drawHCenteredString(MatrixStack matrices, String text, float x, float y, int color) { 40 | tr.draw(matrices, text, x, y - tr.fontHeight / 2, color); 41 | } 42 | 43 | public static void drawVCenteredString(MatrixStack matrices, String text, int x, int y, int color) { 44 | tr.draw(matrices, text, x, y - tr.fontHeight / 2, color); 45 | } 46 | 47 | public static void drawVCenteredString(MatrixStack matrices, String text, double x, double y, int color) { 48 | tr.draw(matrices, text, (float) x, (float) y - tr.fontHeight / 2, color); 49 | } 50 | 51 | public static void drawHVCenteredString(MatrixStack matrices, String text, int x, int y, int color) { 52 | tr.draw(matrices, text, x - tr.getWidth(text) / 2, y - tr.fontHeight / 2, color); 53 | } 54 | 55 | public static void drawHVCenteredString(MatrixStack matrices, String text, double x, double y, int color) { 56 | tr.draw(matrices, text, (float) x - tr.getWidth(text) / 2, (float) y - tr.fontHeight / 2, color); 57 | } 58 | 59 | public static void drawHVCenteredString(MatrixStack matrices, String text, float x, float y, int color) { 60 | tr.draw(matrices, text, x - tr.getWidth(text) / 2, y - tr.fontHeight / 2, color); 61 | } 62 | 63 | public static void drawVCenteredString(MatrixStack matrices, String text, float x, float y, int color) { 64 | tr.draw(matrices, text, x - tr.getWidth(text) / 2, y - tr.fontHeight / 2, color); 65 | } 66 | 67 | 68 | public static int getStringWidth(String string) { 69 | return tr.getWidth(string); 70 | } 71 | 72 | public static int getFontHeight() { 73 | return tr.fontHeight; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/utils/Render2D.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.utils; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.gui.DrawableHelper; 6 | import net.minecraft.client.render.*; 7 | import net.minecraft.client.util.math.MatrixStack; 8 | import net.minecraft.util.math.Matrix4f; 9 | import org.lwjgl.opengl.GL11; 10 | 11 | import java.awt.*; 12 | 13 | public class Render2D { 14 | 15 | public static int getScaledWidth() { 16 | return MinecraftClient.getInstance().getWindow().getScaledWidth(); 17 | } 18 | 19 | public static int getScaledHeight() { 20 | return MinecraftClient.getInstance().getWindow().getScaledHeight(); 21 | } 22 | 23 | 24 | public static void drawRect(MatrixStack matrices, int x1, int y1, int x2, int y2, int color) { 25 | DrawableHelper.fill(matrices, x1, y1, x2, y2, color); 26 | } 27 | 28 | public static void drawRect(MatrixStack matrices, double x1, double y1, double x2, double y2, int color) { 29 | fill(matrices.peek().getPositionMatrix(), x1, y1, x2, y2, color); 30 | } 31 | 32 | public static void drawRectWH(MatrixStack matrices, int x, int y, int width, int height, int color) { 33 | DrawableHelper.fill(matrices, x, y, x + width, y + height, color); 34 | } 35 | 36 | public static void drawRectWH(MatrixStack matrices, double x, double y, double width, double height, int color) { 37 | fill(matrices.peek().getPositionMatrix(), x, y, x + width, y + height, color); 38 | } 39 | 40 | public static void drawHorizontalLine(MatrixStack matrices, int i, int j, int k, int l) { 41 | if (j < i) { 42 | int m = i; 43 | i = j; 44 | j = m; 45 | } 46 | 47 | drawRect(matrices, i, k, j + 1, k + 1, l); 48 | } 49 | 50 | public static void drawVerticalLine(MatrixStack matrices, int i, int j, int k, int l) { 51 | if (k < j) { 52 | int m = j; 53 | j = k; 54 | k = m; 55 | } 56 | 57 | drawRect(matrices, i, j + 1, i + 1, k, l); 58 | } 59 | 60 | public static void fill(Matrix4f matrix4f, double x1, double y1, double x2, double y2, int color) { 61 | double j; 62 | if (x1 < x2) { 63 | j = x1; 64 | x1 = x2; 65 | x2 = j; 66 | } 67 | 68 | if (y1 < y2) { 69 | j = y1; 70 | y1 = y2; 71 | y2 = j; 72 | } 73 | 74 | float f = (float) (color >> 24 & 255) / 255.0F; 75 | float g = (float) (color >> 16 & 255) / 255.0F; 76 | float h = (float) (color >> 8 & 255) / 255.0F; 77 | float k = (float) (color & 255) / 255.0F; 78 | BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); 79 | RenderSystem.enableBlend(); 80 | RenderSystem.disableTexture(); 81 | RenderSystem.defaultBlendFunc(); 82 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); 83 | bufferBuilder.vertex(matrix4f, (float) x1, (float) y2, 0.0F).color(g, h, k, f).next(); 84 | bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next(); 85 | bufferBuilder.vertex(matrix4f, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next(); 86 | bufferBuilder.vertex(matrix4f, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next(); 87 | bufferBuilder.end(); 88 | BufferRenderer.draw(bufferBuilder); 89 | RenderSystem.enableTexture(); 90 | RenderSystem.disableBlend(); 91 | } 92 | 93 | public static void setColor(Color color) { 94 | GL11.glColor4f(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, 95 | color.getAlpha() / 255.0f); 96 | } 97 | 98 | public static void setColor(int rgba) { 99 | int r = rgba & 0xFF; 100 | int g = rgba >> 8 & 0xFF; 101 | int b = rgba >> 16 & 0xFF; 102 | int a = rgba >> 24 & 0xFF; 103 | GL11.glColor4b((byte) r, (byte) g, (byte) b, (byte) a); 104 | } 105 | 106 | public static int toRGBA(Color c) { 107 | return c.getRed() | c.getGreen() << 8 | c.getBlue() << 16 | c.getAlpha() << 24; 108 | } 109 | 110 | public static boolean isHovered(int mouseX, int mouseY, int x, int y, int width, int height) { 111 | return mouseX >= x && mouseX - width <= x && mouseY >= y && mouseY - height <= y; 112 | } 113 | 114 | public static boolean isHovered(double mouseX, double mouseY, double x, double y, double width, double height) { 115 | return mouseX >= x && mouseX - width <= x && mouseY >= y && mouseY - height <= y; 116 | } 117 | 118 | public static boolean isHovered(float mouseX, float mouseY, float x, float y, float width, float height) { 119 | return mouseX >= x && mouseX - width <= x && mouseY >= y && mouseY - height <= y; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/client/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.client.utils; 2 | 3 | public class TimeUtils { 4 | private long lastMS = 0L; 5 | 6 | public int convertToMS(int d) { 7 | return 1000 / d; 8 | } 9 | 10 | public long getCurrentMS() { 11 | return System.nanoTime() / 1000000L; 12 | } 13 | 14 | public boolean hasReached(long milliseconds) { 15 | return getCurrentMS() - lastMS >= milliseconds; 16 | } 17 | 18 | public boolean hasTimeReached(long delay) { 19 | return System.currentTimeMillis() - lastMS >= delay; 20 | } 21 | 22 | public long getDelay() { 23 | return System.currentTimeMillis() - lastMS; 24 | } 25 | 26 | public void reset() { 27 | lastMS = getCurrentMS(); 28 | } 29 | 30 | public void setLastMS() { 31 | lastMS = System.currentTimeMillis(); 32 | } 33 | 34 | public void setLastMS(long lastMS) { 35 | this.lastMS = lastMS; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/mixin/ClientPlayerEntityMixin.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.mixin; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.foxbase.client.event.Events.UpdatedEvent; 5 | import cn.enaium.foxbase.client.event.Events.UpdatingEvent; 6 | import net.minecraft.client.network.ClientPlayerEntity; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(ClientPlayerEntity.class) 13 | public class ClientPlayerEntityMixin { 14 | 15 | 16 | @Inject(at = @At("HEAD"), method = "sendChatMessage", cancellable = true) 17 | private void onSendChatMessage(String message, CallbackInfo info) { 18 | if (CF4M.COMMAND.execCommand(message)) { 19 | info.cancel(); 20 | } 21 | } 22 | 23 | @Inject(at = @At("HEAD"), method = {"sendMovementPackets()V"}) 24 | private void onSendMovementPacketsHEAD(CallbackInfo ci) { 25 | CF4M.EVENT.post(new UpdatingEvent()); 26 | } 27 | 28 | @Inject(at = @At("TAIL"), method = {"sendMovementPackets()V"}) 29 | private void onSendMovementPacketsTAIL(CallbackInfo ci) { 30 | CF4M.EVENT.post(new UpdatedEvent()); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/mixin/GameRendererMixin.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.mixin; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.foxbase.client.event.Events; 5 | import cn.enaium.foxbase.client.event.Events.Render3DEvent; 6 | import net.minecraft.client.render.GameRenderer; 7 | import net.minecraft.client.util.math.MatrixStack; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(GameRenderer.class) 14 | public class GameRendererMixin { 15 | @Inject( 16 | at = @At(value = "FIELD", 17 | target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", 18 | ordinal = 0), 19 | method = { 20 | "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V"}) 21 | private void onRenderWorld(float partialTicks, long finishTimeNano, 22 | MatrixStack matrixStack, CallbackInfo ci) { 23 | CF4M.EVENT.post(new Render3DEvent(partialTicks)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/mixin/InGameHudMixin.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.mixin; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.foxbase.client.event.Events; 5 | import cn.enaium.foxbase.client.event.Events.Render2DEvent; 6 | import net.minecraft.client.gui.hud.InGameHud; 7 | import net.minecraft.client.util.math.MatrixStack; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(InGameHud.class) 14 | public class InGameHudMixin { 15 | @Inject(at = @At(value = "INVOKE", 16 | target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V", 17 | ordinal = 4), method = "render") 18 | private void render(MatrixStack matrixStack, float partialTicks, CallbackInfo info) { 19 | CF4M.EVENT.post(new Render2DEvent(matrixStack)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/mixin/KeyboardMixin.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.mixin; 2 | 3 | import cn.enaium.cf4m.CF4M; 4 | import cn.enaium.foxbase.client.event.Events; 5 | import net.minecraft.client.Keyboard; 6 | import net.minecraft.client.MinecraftClient; 7 | import org.lwjgl.glfw.GLFW; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | /** 14 | * Project: FoxBase 15 | * ----------------------------------------------------------- 16 | * Copyright © 2020-2021 | Enaium | All rights reserved. 17 | */ 18 | @Mixin(Keyboard.class) 19 | public class KeyboardMixin { 20 | @Inject(at = @At("HEAD"), method = "onKey") 21 | private void onOnKey(long windowHandle, int keyCode, int scanCode, int action, int modifiers, CallbackInfo callbackInfo) { 22 | if (action == GLFW.GLFW_PRESS && MinecraftClient.getInstance().currentScreen == null) { 23 | CF4M.MODULE.onKey(keyCode); 24 | CF4M.EVENT.post(new Events.KeyboardEvent(keyCode)); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/cn/enaium/foxbase/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package cn.enaium.foxbase.mixin; 2 | 3 | import cn.enaium.foxbase.client.FoxBase; 4 | import net.minecraft.client.MinecraftClient; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | /** 11 | * Project: FoxBase 12 | * ----------------------------------------------------------- 13 | * Copyright © 2020-2021 | Enaium | All rights reserved. 14 | */ 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | // private Window window; 19 | // 20 | // @Inject(at = @At("RETURN"), method = "updateWindowTitle") 21 | // private void updateWindowTitle(CallbackInfo callbackInfo) { 22 | // this.window.setTitle(FoxBase.instance.name + " | Author:" + FoxBase.instance.author + " | Version:" + FoxBase.instance.version + " | Minecraft:" + FoxBase.instance.game); 23 | // } 24 | 25 | @Inject(at = @At("HEAD"), method = "run") 26 | private void run(CallbackInfo callbackInfo) { 27 | FoxBase.instance.run(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/foxbase/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Enaium/minecraft-code-FoxBase/0c1ee3e2d1b8b0bc2efbee44b26cbcbda72ddf47/src/main/resources/assets/foxbase/icon.png -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "foxbase", 4 | "version": "1.0", 5 | 6 | "name": "Fox Base", 7 | "description": "Fox Base!", 8 | "authors": [ 9 | "Enaium!" 10 | ], 11 | "contact": { 12 | "homepage": "https://github.com/Enaium/FoxBase", 13 | "sources": "https://github.com/Enaium/FoxBase" 14 | }, 15 | 16 | "license": "", 17 | "icon": "assets/foxbase/icon.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "main": [ 22 | "cn.enaium.foxbase.FoxBaseMod" 23 | ] 24 | }, 25 | "mixins": [ 26 | "foxbase.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.7.4", 31 | "fabric": "*", 32 | "minecraft": "1.18.x", 33 | "cf4m": ">=1.9.7" 34 | }, 35 | "suggests": { 36 | "flamingo": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/foxbase.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "cn.enaium.foxbase.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "ClientPlayerEntityMixin", 10 | "MinecraftClientMixin", 11 | "GameRendererMixin", 12 | "InGameHudMixin", 13 | "KeyboardMixin" 14 | ], 15 | "injectors": { 16 | "defaultRequire": 1 17 | } 18 | } 19 | --------------------------------------------------------------------------------