diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12f8644 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# eclipse +bin +*.launch +.settings +.metadata +.classpath +.project + +# idea +out +*.ipr +*.iws +*.iml +.idea + +# gradle +build +.gradle + +# other +eclipse +run + +# Files from Forge MDK +forge*changelog.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9f5110c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 RafaΕ‚ Ε»elazko (Ray Ferric) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..effa1f9 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# Havook 1.12.2 + +[![](https://img.shields.io/github/downloads/Crimz8n/havook-1.12.2/total?style=for-the-badge)](https://github.com/rayferric/havook-1.12.2/releases) +[![](https://img.shields.io/github/license/Crimz8n/havook-1.12.2?style=for-the-badge)](https://opensource.org/licenses/MPL-2.0) +[![](https://img.shields.io/github/v/release/Crimz8n/havook-1.12.2?style=for-the-badge)](https://github.com/rayferric/havook-1.12.2/releases) + +πŸŒͺ Havook hacked client for Minecraft Forge 1.12.2. + +## Features + +### Mods + +- πŸ“œ Active List +- 🎣 Auto Fish +- 🐍 Auto Sneak +- πŸƒπŸ»β€β™€οΈ Auto Sprint +- 🚢🏻 Auto Walk +- πŸ“¦ Chest ESP +- πŸš€ Elytra Boost +- ⚑ Fast Place +- ✈️ Fly +- πŸ”† Full Bright +- ❀️ Health Tags +- πŸ’° Item ESP +- πŸ‘Ή Mob ESP +- πŸ”ͺ Hitman Radar +- πŸ§—πŸ» Parkour +- πŸ‘Ύ Player ESP +- ⛰️ Safe Walk +- 🏹 Trajectories +- βš”οΈ Trigger Bot + +### Commands + +`.author` `.bind` `.clearchat` `.copydata`\ +`.copyitem` `.forward` `.friend` `.give`\ +`.gui` `.hat` `.head` `.help`\ +`.lore` `.mod` `.nbt` `.panic`\ +`.rename` `.repair` `.say` `.tp` + +## Getting Started + +### Installing + +- Download the latest version of **[Minecraft Forge 1.12.2](https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.12.2.html)**. +- Download the latest Havook binary. +- Place the downloaded `.jar` in your `.minecraft/mods/` directory. If you want to organize your modifications, you can place it under `.minecraft/mods/1.12.2/`. +- Launch Minecraft using the Forge profile. Havook should now be loaded. + +### Usage + +Type `.help` in the chat to get the ball rolling. + +## Development + +### Prerequisites + +- β˜• Java SE Development Kit 8 + +### Building + +πŸ–₯ Run the following command in your terminal: + +```bash +./gradlew build +``` + +The output binaries will be generated in the `./build/libs/` directory. + +## About + +### Authors + +- Ray Ferric (**[rayferric](https://github.com/rayferric)**) + +### License + +This project is licensed under the MIT License. See the **[LICENSE](LICENSE)** file for details. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e07de6a --- /dev/null +++ b/build.gradle @@ -0,0 +1,45 @@ +buildscript { + repositories { + maven { url = 'https://files.minecraftforge.net/maven' } + jcenter() + mavenCentral() + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:3.+' + } +} + +apply plugin: 'net.minecraftforge.gradle' + +version = '1.0.0' +group = 'com.rayferric.havook' +archivesBaseName = 'havook' + +sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' + +minecraft { + mappings channel: 'snapshot', version: '20171003-1.12' + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + runs { + client { + workingDirectory project.file('run') + + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + } + + server { + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + } + } +} + +dependencies { + minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854' +} + +jar { + manifest.attributes('FMLAT': 'accesstransformer.cfg') +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..878bf1f --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7a3265e Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..949819d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/com/rayferric/havook/Havook.java b/src/main/java/com/rayferric/havook/Havook.java new file mode 100644 index 0000000..7becad1 --- /dev/null +++ b/src/main/java/com/rayferric/havook/Havook.java @@ -0,0 +1,42 @@ +package com.rayferric.havook; + +import java.util.logging.Logger; + +import com.rayferric.havook.proxy.ServerProxy; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +@Mod(modid = Havook.MODID, name = Havook.NAME, version = Havook.VERSION) +public class Havook { + public static final String MODID = "havook"; + public static final String NAME = "Havook"; + public static final String VERSION = "1.0.0"; + public static final String CLIENT_PROXY = "com.rayferric.havook.proxy.ClientProxy"; + public static final String SERVER_PROXY = "com.rayferric.havook.proxy.ServerProxy"; + + public static final Logger LOGGER = Logger.getLogger(Havook.MODID); + + @Mod.Instance + public static Havook instance; + + @SidedProxy(clientSide = CLIENT_PROXY, serverSide = SERVER_PROXY) + public static ServerProxy proxy; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + proxy.preInit(event); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/Command.java b/src/main/java/com/rayferric/havook/feature/Command.java new file mode 100644 index 0000000..7768100 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/Command.java @@ -0,0 +1,15 @@ +package com.rayferric.havook.feature; + +public abstract class Command { + public String name = ""; + public String syntax = ""; + public String description = ""; + + public Command(String name, String syntax, String description) { + this.name = name; + this.syntax = syntax; + this.description = description; + } + + public abstract void execute(String[] args); +} diff --git a/src/main/java/com/rayferric/havook/feature/Keybind.java b/src/main/java/com/rayferric/havook/feature/Keybind.java new file mode 100644 index 0000000..809e8fc --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/Keybind.java @@ -0,0 +1,28 @@ +package com.rayferric.havook.feature; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.util.ChatUtil; + +public class Keybind { + public int id; + public int key; + public String message; + private transient Boolean active; + + public Keybind(int id, int key, String message) { + this.id = id; + this.key = key; + this.message = message; + active = false; + } + + public void process() { + if (active == false && Keyboard.isKeyDown(key)) { + active = true; + ChatUtil.sendChatMessage(message, false); + } else if (!Keyboard.isKeyDown(key)) { + active = false; + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/Mod.java b/src/main/java/com/rayferric/havook/feature/Mod.java new file mode 100644 index 0000000..6b4f2ab --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/Mod.java @@ -0,0 +1,77 @@ +package com.rayferric.havook.feature; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +import com.rayferric.havook.feature.mod.ModAttribute; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.ModManager; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.client.event.sound.PlaySoundEvent; + +public abstract class Mod { + protected boolean enabled = false; + public String id = ""; + public transient String name = ""; + public transient String description = ""; + public transient ModCategoryEnum category = null; + @SerializedName("attributes") + public List ATTRIBUTES = new ArrayList(); + + public Mod(String id, String name, String description, ModCategoryEnum category) { + this.id = id; + this.name = name; + this.description = description; + this.category = category; + } + + public boolean isEnabled() { + return enabled; + + } + + public void setEnabled(boolean enabled) { + boolean lastState = this.enabled; + this.enabled = enabled; + if (enabled && lastState != enabled)onEnable(); + else onDisable(); + ModManager.saveMods(); + } + + public void addAttrib(ModAttribute attrib) { + ATTRIBUTES.add(attrib); + } + + public ModAttribute getAttribByName(String name) { + for (ModAttribute attrib : ATTRIBUTES) { + if (attrib.name.equalsIgnoreCase(name)) { + return attrib; + } + } + return null; + } + + public void onEnable() { + } + + public void onDisable() { + } + + public void onLocalPlayerUpdate() { + } + + public void onRenderWorldLast(float partialTicks) { + } + + public void onPlaySound(PlaySoundEvent event) { + } + + public void onRenderGameOverlay(RenderGameOverlayEvent event) { + } + + public void onRenderLivingSpecialsPre(RenderLivingEvent.Specials.Pre event) { + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/AuthorCommand.java b/src/main/java/com/rayferric/havook/feature/command/AuthorCommand.java new file mode 100644 index 0000000..ddc6b0d --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/AuthorCommand.java @@ -0,0 +1,40 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagString; + +public class AuthorCommand extends Command { + public AuthorCommand() { + super("author", ".author ", "Changes held book's author."); + } + + @Override + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty() || Item.getIdFromItem(stack.getItem()) != 387) { + ChatUtil.error("You must hold a written book in your hand."); + return; + } + String author = args[0]; + for (int i = 1; i < args.length; i++) { + author += " " + args[i]; + } + author = author.replace('&', '\247').replace("\247\247", "&"); + stack.setTagInfo("author", new NBTTagString(author)); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Book's author changed to \2477" + author + "\247e."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/BindCommand.java b/src/main/java/com/rayferric/havook/feature/command/BindCommand.java new file mode 100644 index 0000000..cdd5d1f --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/BindCommand.java @@ -0,0 +1,115 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.feature.Keybind; +import com.rayferric.havook.manager.KeybindManager; +import com.rayferric.havook.util.ChatUtil; + +public class BindCommand extends Command { + public BindCommand() { + super("bind", ".bind [message]|remove |list|reset>", + "Manages havook keybindings. You can find all available key codes at https://minecraft.gamepedia.com/Key_codes."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args[0].equals("set")) { + if (args.length < 3) { + ChatUtil.error("No key specified."); + return; + } + if (args.length < 2) { + ChatUtil.error("No id specified."); + return; + } + int id = 0; + int key = 0; + String message = ""; + if (args.length > 3) { + message = args[3]; + for (int i = 4; i < args.length; i++) { + message += " " + args[i]; + } + } + try { + id = Integer.parseInt(args[1]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[1] + "\247e is not a valid number."); + return; + } + try { + key = Integer.parseInt(args[2]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[2] + "\247e is not a valid number."); + return; + } + Keybind target = KeybindManager.getKeybindById(id); + if (target != null) { + target.key = key; + if (message != "") { + target.message = message; + } + ChatUtil.info("Updated existing keybind with id \2479" + id + "\247e."); + } else { + if (message == "") { + ChatUtil.error("You must provide a message to create new keybind."); + return; + } + KeybindManager.addKeybind(id, key, message); + ChatUtil.info("Created new keybind with id \2479" + id + "\247e."); + } + KeybindManager.saveKeybinds(); + } else if (args[0].equals("remove")) { + if (args.length < 2) { + ChatUtil.error("No id specified."); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + int id = 0; + try { + id = Integer.parseInt(args[1]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[1] + "\247e is not a valid number."); + return; + } + if (KeybindManager.removeKeybind(id)) { + ChatUtil.info("Removed keybind with id \2479" + id + "\247e."); + } else { + ChatUtil.error("There's no such keybind with id \2479" + id + "\247e."); + return; + } + } else if (args[0].equals("list")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + ChatUtil.info("\2473\247l--------------------------------"); + ChatUtil.info("\247lRegistered keybinds:"); + ChatUtil.info(""); + if (KeybindManager.KEYBINDS.size() < 1) { + ChatUtil.info("\247c\247l"); + } else + for (Keybind keybind : KeybindManager.KEYBINDS) { + ChatUtil.info("\247c\247lID\247e\247l:\2479" + keybind.id + " \247c\247lKEY\247e\247l:\2479" + + keybind.key + " \247a\247lMSG\247e\247l:\2477" + keybind.message); + } + ChatUtil.info("\2473\247l--------------------------------"); + } else if (args[0].equals("reset")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + KeybindManager.resetKeybinds(); + ChatUtil.info("All keybinds have been reset."); + } else { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/ClearChatCommand.java b/src/main/java/com/rayferric/havook/feature/command/ClearChatCommand.java new file mode 100644 index 0000000..6cedd9e --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/ClearChatCommand.java @@ -0,0 +1,18 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; + +public class ClearChatCommand extends Command { + public ClearChatCommand() { + super("clearchat", ".clearchat", "Clears the chat completely."); + } + + @Override + public void execute(String[] args) { + if (args.length > 0) { + ChatUtil.warning("Too many arguments."); + } + ChatUtil.clear(256); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/CopyDataCommand.java b/src/main/java/com/rayferric/havook/feature/command/CopyDataCommand.java new file mode 100644 index 0000000..8e44a6d --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/CopyDataCommand.java @@ -0,0 +1,46 @@ +package com.rayferric.havook.feature.command; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class CopyDataCommand extends Command { + public CopyDataCommand() { + super("copydata", ".copydata", "Generates give command from held item's data."); + } + + @Override + public void execute(String[] args) { + if (args.length > 0) { + ChatUtil.warning("Too many arguments."); + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + int id = Item.getIdFromItem(stack.getItem()); + int amount = stack.getCount(); + int metadata = stack.getMetadata(); + String nbt = ""; + if (stack.hasTagCompound()) { + nbt = stack.getTagCompound().toString(); + nbt = nbt.replace("&", "&&").replace("\247", "&"); + nbt = " " + nbt; + } + + String command = ".give " + id + " " + amount + " " + metadata + nbt; + + StringSelection selection = new StringSelection(command); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + ChatUtil.info("The command has been copied to clipboard."); + + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/CopyItemCommand.java b/src/main/java/com/rayferric/havook/feature/command/CopyItemCommand.java new file mode 100644 index 0000000..e48b0ea --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/CopyItemCommand.java @@ -0,0 +1,65 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class CopyItemCommand extends Command { + public CopyItemCommand() { + super("copyitem", ".copyitem ", + "Copies item from other player's armor slot or hand."); + } + + @Override + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ItemStack stack = null; + // find player + EntityPlayer target = Minecraft.getMinecraft().world.getPlayerEntityByName(args[0]); + if (target == null) { + ChatUtil.error("Player \2477" + args[0] + "\247c can not be found."); + return; + } + if (args.length < 2) { + ChatUtil.error("You must specify the slot you want to copy item from."); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + // find item + switch (args[1].toLowerCase()) { + case "hand": + stack = target.inventory.getCurrentItem(); + break; + case "head": + stack = target.inventory.armorItemInSlot(3); + break; + case "chest": + stack = target.inventory.armorItemInSlot(2); + break; + case "legs": + stack = target.inventory.armorItemInSlot(1); + break; + case "feet": + stack = target.inventory.armorItemInSlot(0); + break; + default: + ChatUtil.error("Invalid slot specified."); + return; + } + // give item stack + InventoryUtil.updateFirstEmptySlot(stack.copy()); + ChatUtil.info("Item copied."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/ForwardCommand.java b/src/main/java/com/rayferric/havook/feature/command/ForwardCommand.java new file mode 100644 index 0000000..ec9be7c --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/ForwardCommand.java @@ -0,0 +1,42 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; + +public class ForwardCommand extends Command { + public ForwardCommand() { + super("forward", ".forward ", "Teleports you forward by given distance."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + + double distance = 0; + try { + distance = Double.parseDouble(args[0]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[0] + " \247cis not a valid number."); + return; + } + + double y = Minecraft.getMinecraft().player.posY; + float yaw = Minecraft.getMinecraft().player.rotationYaw; + + double newX = -Math.sin(Math.toRadians(yaw)) * distance + Minecraft.getMinecraft().player.posX; + double newZ = Math.cos(Math.toRadians(yaw)) * distance + Minecraft.getMinecraft().player.posZ; + + Minecraft.getMinecraft().player.setPosition(newX, y, newZ); + + ChatUtil.info("Teleported \2477" + Minecraft.getMinecraft().player.getName() + "\247e to \2479" + newX + + "\247e, \2479" + y + "\247e, \2479" + newZ + "\247e."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/FriendCommand.java b/src/main/java/com/rayferric/havook/feature/command/FriendCommand.java new file mode 100644 index 0000000..8e732a7 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/FriendCommand.java @@ -0,0 +1,75 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.ChatUtil; + +public class FriendCommand extends Command { + public FriendCommand() { + super("friend", ".friend |remove |list|clear>", "Manages friend list."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args[0].equals("add")) { + if (args.length < 2) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + if (FriendManager.addFriend(args[1])) { + ChatUtil.info("Added \2477" + args[1] + "\247e to friends."); + } else { + ChatUtil.error("Player \2477" + args[1] + " \247cis already in friends."); + return; + } + } else if (args[0].equals("remove")) { + if (args.length < 2) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + if (FriendManager.removeFriend(args[1])) { + ChatUtil.info("Removed \2477" + args[1] + " \247efrom friends."); + } else { + ChatUtil.error("There is no player \2477" + args[1] + " \247cin friends."); + return; + } + } else if (args[0].equals("list")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + ChatUtil.info("\2473\247l--------------------------------"); + ChatUtil.info("\247lFriends:"); + ChatUtil.info(""); + if (FriendManager.FRIENDS.size() < 1) { + ChatUtil.info("\247c\247l"); + } else + for (String friend : FriendManager.FRIENDS) { + ChatUtil.info("\247c" + friend); + } + ChatUtil.info("\2473\247l--------------------------------"); + } else if (args[0].equals("clear")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + FriendManager.clearFriends(); + ChatUtil.info("All friends have been removed."); + } else { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/GiveCommand.java b/src/main/java/com/rayferric/havook/feature/command/GiveCommand.java new file mode 100644 index 0000000..1efce8a --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/GiveCommand.java @@ -0,0 +1,78 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTException; + +public class GiveCommand extends Command { + public GiveCommand() { + super("give", ".give [amount] [data] [dataTag]", "Gives you an item."); + } + + @Override + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + Item item = null; + int amount = 1; + int metadata = 0; + String nbt = null; + // item + item = Item.getByNameOrId(args[0]); + if (item == null) { + ChatUtil.error("There's no such item with name \2477" + args[0] + "\247c."); + return; + } + // amount + if (args.length > 1) { + try { + amount = Integer.parseInt(args[1]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[1] + "\247c is not a valid number."); + return; + } + // metadata + if (args.length > 2) { + try { + metadata = Integer.parseInt(args[2]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[2] + "\247c is not a valid number."); + return; + } + // nbt + if (args.length > 3) { + nbt = args[3]; + for (int i = 4; i < args.length; i++) + nbt += " " + args[i]; + nbt = nbt.replace('&', '\247').replace("\247\247", "&"); + } + } + } + // generate item stack + ItemStack stack = new ItemStack(item, amount, metadata); + // apply nbt data + if (nbt != null) { + try { + stack.setTagCompound(JsonToNBT.getTagFromJson(nbt)); + } catch (NBTException e) { + ChatUtil.error("Data tag parsing failed: " + e.getMessage()); + return; + } + } + // give item stack + InventoryUtil.updateFirstEmptySlot(stack); + ChatUtil.info("Given \2477" + stack.getDisplayName() + "\247e * \2479" + amount + "\247e to \2477" + + Minecraft.getMinecraft().player.getName() + "\247e."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/GuiCommand.java b/src/main/java/com/rayferric/havook/feature/command/GuiCommand.java new file mode 100644 index 0000000..09c2e95 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/GuiCommand.java @@ -0,0 +1,23 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.gui.LongMessageSenderGui; +import com.rayferric.havook.gui.MainMenuGui; +import com.rayferric.havook.handler.ClientTickHandler; +import com.rayferric.havook.util.ChatUtil; + +public class GuiCommand extends Command { + + public GuiCommand() { + super("gui", ".gui", "Opens graphical interface. This command is binded to RSHIFT key by default."); + } + + @Override + public void execute(String[] args) { + if (args.length > 0) { + ChatUtil.warning("Too many arguments."); + } + ClientTickHandler.queueGui(new MainMenuGui()); + } + +} diff --git a/src/main/java/com/rayferric/havook/feature/command/HatCommand.java b/src/main/java/com/rayferric/havook/feature/command/HatCommand.java new file mode 100644 index 0000000..7a2eeda --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/HatCommand.java @@ -0,0 +1,35 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +public class HatCommand extends Command { + public HatCommand() { + super("hat", ".hat", "Moves item from your hand to head slot."); + } + + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length > 0) { + ChatUtil.warning("Too many arguments."); + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + + ItemStack head = Minecraft.getMinecraft().player.inventory.armorItemInSlot(3); + + Minecraft.getMinecraft().player.inventory.armorInventory.set(3, stack); + InventoryUtil.updateSlot(5, stack); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, head); + + ChatUtil.info("Item \2477" + stack.getDisplayName() + " \247ehas been moved to your head slot."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/HeadCommand.java b/src/main/java/com/rayferric/havook/feature/command/HeadCommand.java new file mode 100644 index 0000000..1ef0d10 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/HeadCommand.java @@ -0,0 +1,43 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagString; + +public class HeadCommand extends Command { + public HeadCommand() { + super("head", ".head ", "Sets the owner of the head you are holding or creates new one."); + } + + @Override + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (!stack.isEmpty() && Item.getIdFromItem(stack.getItem()) == 397 && stack.getMetadata() == 3) { + stack.setTagInfo("SkullOwner", new NBTTagString(args[0])); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Head's owner changed to \2477" + args[0] + "\247e."); + return; + } + ItemStack newStack = new ItemStack(new Item().getItemById(397), 1, 3); + newStack.setTagInfo("SkullOwner", new NBTTagString(args[0])); + InventoryUtil.updateFirstEmptySlot(newStack); + ChatUtil.info("Given head of player \2477" + args[0] + "\247e to \2477" + + Minecraft.getMinecraft().player.getName() + "\247e."); + return; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/HelpCommand.java b/src/main/java/com/rayferric/havook/feature/command/HelpCommand.java new file mode 100644 index 0000000..3cca4d4 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/HelpCommand.java @@ -0,0 +1,38 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.manager.CommandManager; +import com.rayferric.havook.util.ChatUtil; + +public class HelpCommand extends Command { + public HelpCommand() { + super("help", ".help [command]", "Displays all available havook commands and their syntax."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.info("\2473\247l--------------------------------"); + ChatUtil.info("\247lAll available commands:"); + ChatUtil.info(""); + for (Command command : CommandManager.COMMANDS) { + ChatUtil.info("\247c." + command.name); + } + ChatUtil.info("\2473\247l--------------------------------"); + return; + } + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + + for (Command command : CommandManager.COMMANDS) { + if (args[0].equalsIgnoreCase(command.name)) { + ChatUtil.syntax(command.syntax); + ChatUtil.info("\247lDESCRIPTION: \247e" + command.description); + return; + } + } + ChatUtil.error("There's no such command with name \2477" + args[0] + + "\247c. Type .havook help to list all available commands."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/LoreCommand.java b/src/main/java/com/rayferric/havook/feature/command/LoreCommand.java new file mode 100644 index 0000000..cec3cc7 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/LoreCommand.java @@ -0,0 +1,56 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; + +public class LoreCommand extends Command { + public LoreCommand() { + super("lore", ".lore ", "Adds lore to item."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + String lore = args[0]; + for (int i = 1; i < args.length; i++) { + lore += " " + args[i]; + } + lore = lore.replace('&', '\247').replace("\247\247", "&"); + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (stack.hasTagCompound() && stack.getTagCompound().getCompoundTag("display") != null) { + NBTTagList lores = new NBTTagList(); + if (stack.getTagCompound().getCompoundTag("display").getTag("Lore") != null) { + lores = (NBTTagList) stack.getTagCompound().getCompoundTag("display").getTag("Lore"); + } + lores.appendTag(new NBTTagString(lore)); + NBTTagCompound display = new NBTTagCompound(); + display.setTag("Lore", lores); + stack.getTagCompound().getCompoundTag("display").merge(display); + } else { + NBTTagList lores = new NBTTagList(); + lores.appendTag(new NBTTagString(lore)); + NBTTagCompound display = new NBTTagCompound(); + display.setTag("Lore", lores); + stack.setTagInfo("display", display); + } + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Added lore \2477" + lore + "\247e to the item."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/ModCommand.java b/src/main/java/com/rayferric/havook/feature/command/ModCommand.java new file mode 100644 index 0000000..5d078dc --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/ModCommand.java @@ -0,0 +1,225 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttribute; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.ModManager; +import com.rayferric.havook.util.ChatUtil; + +public class ModCommand extends Command { + public ModCommand() { + super("mod", ".mod |t |reset |attrib >>", + "Allows you to toggle havook mods and modify their attributes."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args[0].equals("list")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + ChatUtil.info("\2473\247l--------------------------------"); + ChatUtil.info("\247lAll available mods:"); + ChatUtil.info(""); + ChatUtil.info("COMBAT:"); + for (Mod mod : ModManager.MODS) { + if (mod.category == ModCategoryEnum.COMBAT) { + String active = mod.isEnabled() ? "\247a" : "\247c"; + ChatUtil.info(active + "\247l" + mod.name + " \247e[\2477" + mod.id + "\247e]"); + } + } + ChatUtil.info(""); + ChatUtil.info("MISC:"); + for (Mod mod : ModManager.MODS) { + if (mod.category == ModCategoryEnum.MISC) { + String active = mod.isEnabled() ? "\247a" : "\247c"; + ChatUtil.info(active + "\247l" + mod.name + " \247e[\2477" + mod.id + "\247e]"); + } + } + ChatUtil.info(""); + ChatUtil.info("MOVEMENT:"); + for (Mod mod : ModManager.MODS) { + if (mod.category == ModCategoryEnum.MOVEMENT) { + String active = mod.isEnabled() ? "\247a" : "\247c"; + ChatUtil.info(active + "\247l" + mod.name + " \247e[\2477" + mod.id + "\247e]"); + } + } + ChatUtil.info(""); + ChatUtil.info("RENDER:"); + for (Mod mod : ModManager.MODS) { + if (mod.category == ModCategoryEnum.RENDER) { + String active = mod.isEnabled() ? "\247a" : "\247c"; + ChatUtil.info(active + "\247l" + mod.name + " \247e[\2477" + mod.id + "\247e]"); + } + } + ChatUtil.info("\2473\247l--------------------------------"); + return; + } else if (args[0].equals("toggle")) { + if (args.length < 2) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + Mod targetMod = ModManager.getModById(args[1]); + if (targetMod == null) { + ChatUtil.error("There's no such mod with id \2477" + args[1] + "\247c."); + return; + } + targetMod.setEnabled(!targetMod.isEnabled()); + ChatUtil.info("Mod " + (targetMod.isEnabled() ? "\247a" : "\247c") + "\247l" + targetMod.name + " \247ehas been toggled " + (targetMod.isEnabled() ? "\247a\247lON" : "\247c\247lOFF") + "\247e."); + return; + } else if (args[0].equals("t")) { + if (args.length < 2) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + Mod targetMod = ModManager.getModById(args[1]); + if (targetMod == null) { + ChatUtil.error("There's no such mod with id \2477" + args[1] + "\247c."); + return; + } + targetMod.setEnabled(!targetMod.isEnabled()); + return; + } else if (args[0].equals("reset")) { + if (args.length < 2) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + Mod targetMod = ModManager.getModById(args[1]); + if (targetMod == null) { + ChatUtil.error("There's no such mod with id \2477" + args[1] + "\247c."); + return; + } + for (ModAttribute attribute : targetMod.ATTRIBUTES) { + + if (attribute instanceof ModAttributeBoolean) + ((ModAttributeBoolean) attribute).value = ((ModAttributeBoolean) attribute).getNativeValue(); + else if (attribute instanceof ModAttributeDouble) + ((ModAttributeDouble) attribute).value = ((ModAttributeDouble) attribute).getNativeValue(); + else if (attribute instanceof ModAttributeString) + ((ModAttributeString) attribute).value = ((ModAttributeString) attribute).getNativeValue(); + } + ChatUtil.info("Mod " + (targetMod.isEnabled() ? "\247a" : "\247c") + "\247l" + targetMod.name + " \247ehas been reset."); + ModManager.saveMods(); + return; + } else if (args[0].equals("attrib")) { + if (args.length < 3) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + Mod targetMod = ModManager.getModById(args[1]); + if (targetMod == null) { + ChatUtil.error("There's no such mod with id \2477" + args[1] + "\247c."); + return; + } + if(args[2].equals("list")) { + ChatUtil.info((targetMod.isEnabled() ? "\247a" : "\247c") + "\247l" + targetMod.name + " \2473\247l| \247e" + targetMod.description); + ChatUtil.info("\2473\247l--------------------------------"); + ChatUtil.info("\247lAttributes:"); + ChatUtil.info(""); + if (targetMod.ATTRIBUTES.size() < 1) { + ChatUtil.info("\247c\247l"); + } else + for (ModAttribute attribute : targetMod.ATTRIBUTES) { + if (attribute instanceof ModAttributeBoolean) { + String value = "\247d" + ((ModAttributeBoolean) attribute).value; + ChatUtil.info("\247c\247l" + attribute.name + " \247e\247l: " + value + + " \247e[\247d\247lBOOLEAN\247e]"); + } else if (attribute instanceof ModAttributeDouble) { + String value = "\2479" + ((ModAttributeDouble) attribute).value; + ChatUtil.info("\247c\247l" + attribute.name + " \247e\247l: " + value + + " \247e[\2479\247lDOUBLE\247e]"); + } else if (attribute instanceof ModAttributeString) { + String value = "\247a" + ((ModAttributeString) attribute).value; + ChatUtil.info("\247c\247l" + attribute.name + " \247e\247l: " + value + + " \247e[\247a\247lSTRING\247e]"); + } + } + ChatUtil.info("\2473\247l--------------------------------"); + } else if(args[2].equals("set")) { + if (args.length < 5) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ModAttribute targetAttribute = targetMod.getAttribByName(args[3]); + if (targetAttribute == null) { + String active = targetMod.isEnabled() ? "\247a" : "\247c"; + ChatUtil.error("Mod " + active + "\247l" + targetMod.name + + "\247c has no such attribute with name \2477" + args[3] + "\247c."); + return; + } + if (targetAttribute instanceof ModAttributeBoolean) { + if (args[4].equalsIgnoreCase("true") || args[4].equalsIgnoreCase("false")) { + if (args.length > 5) { + ChatUtil.warning("Too many arguments."); + } + Boolean value = Boolean.parseBoolean(args[4]); + ((ModAttributeBoolean) targetAttribute).value = value; + ChatUtil.info("Attribute \247c\247l" + targetAttribute.name + "\247e has been set to \247d" + + value + " \247e[\247d\247lBOOLEAN\247e]."); + ModManager.saveMods(); + return; + } else { + ChatUtil.error("You must choose between \2477true \247cand \2477false\247c."); + return; + } + } else if (targetAttribute instanceof ModAttributeDouble) { + if (args.length > 5) { + ChatUtil.warning("Too many arguments."); + } + double number; + try { + number = Double.parseDouble(args[4]); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[4] + "\247c is not a valid number."); + return; + } + ((ModAttributeDouble) targetAttribute).value = number; + ChatUtil.info("Attribute \247c\247l" + targetAttribute.name + "\247e has been set to \2479" + number + + " \247e[\2479\247lDOUBLE\247e]."); + ModManager.saveMods(); + return; + } else if (targetAttribute instanceof ModAttributeString) { + String val = args[4]; + for (int i = 5; i < args.length; i++)val += " " + args[i]; + ((ModAttributeString) targetAttribute).value = val; + ChatUtil.info("Attribute \247c\247l" + targetAttribute.name + "\247e has been set to \247a" + + args[4] + " \247e[\247a\247lSTRING\247e]."); + ModManager.saveMods(); + return; + } + } else { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + return; + } else { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/NbtCommand.java b/src/main/java/com/rayferric/havook/feature/command/NbtCommand.java new file mode 100644 index 0000000..a0c54c1 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/NbtCommand.java @@ -0,0 +1,134 @@ +package com.rayferric.havook.feature.command; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTException; + +public class NbtCommand extends Command { + public NbtCommand() { + super("nbt", ".nbt |set |remove |clear|copy>", + "Modifies held item's NBT data."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + if (args[0].equals("add")) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 2) { + ChatUtil.error("No NBT data provided."); + return; + } + String nbt = args[1]; + for (int i = 2; i < args.length; i++) { + nbt += " " + args[i]; + } + nbt = nbt.replace('&', '\247').replace("\247\247", "&"); + try { + if (!stack.hasTagCompound()) { + stack.setTagCompound(JsonToNBT.getTagFromJson(nbt)); + } else { + stack.getTagCompound().merge(JsonToNBT.getTagFromJson(nbt)); + } + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Item modified."); + } catch (NBTException e) { + ChatUtil.error("Data tag parsing failed: " + e.getMessage()); + return; + } + } else if (args[0].equals("set")) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 2) { + ChatUtil.error("No NBT data provided."); + return; + } + String nbt = args[1]; + for (int i = 2; i < args.length; i++) { + nbt += " " + args[i]; + } + nbt = nbt.replace('&', '\247').replace("\247\247", "&"); + try { + stack.setTagCompound(JsonToNBT.getTagFromJson(nbt)); + } catch (NBTException e) { + ChatUtil.error("Data tag parsing failed: " + e.getMessage()); + return; + } + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Item modified."); + } else if (args[0].equals("remove")) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length < 2) { + ChatUtil.error("No NBT tag specified."); + return; + } + if (args.length > 2) { + ChatUtil.warning("Too many arguments."); + } + String tag = args[1]; + if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey(tag)) { + ChatUtil.error("Item has no NBT tag with name \2477" + args[1] + "\247c."); + return; + } + stack.getTagCompound().removeTag(tag); + if (stack.getTagCompound().hasNoTags()) { + stack.setTagCompound(null); + } + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Item modified."); + } else if (args[0].equals("clear")) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + if (!stack.hasTagCompound()) { + ChatUtil.error("Item has no NBT data."); + return; + } + stack.setTagCompound(null); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Cleared item's NBT data."); + + } else if (args[0].equals("copy")) { + if (args.length > 1) { + ChatUtil.warning("Too many arguments."); + } + if (!stack.hasTagCompound()) { + ChatUtil.error("Item has no NBT data."); + return; + } + StringSelection selection = new StringSelection(stack.getTagCompound().toString()); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + ChatUtil.info("Copied item's NBT data to clipboard."); + } else { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/PanicCommand.java b/src/main/java/com/rayferric/havook/feature/command/PanicCommand.java new file mode 100644 index 0000000..25d4e7e --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/PanicCommand.java @@ -0,0 +1,20 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import com.rayferric.havook.util.ChatUtil; + +public class PanicCommand extends Command { + public PanicCommand() { + super("panic", ".panic", "Disables all mods."); + } + + @Override + public void execute(String[] args) { + for (Mod mod : ModManager.MODS) { + if(mod.id == "activelist")continue; + mod.setEnabled(false); + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/RenameCommand.java b/src/main/java/com/rayferric/havook/feature/command/RenameCommand.java new file mode 100644 index 0000000..0654871 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/RenameCommand.java @@ -0,0 +1,38 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +public class RenameCommand extends Command { + public RenameCommand() { + super("rename", ".rename ", "Changes held item's name."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + String name = args[0]; + for (int i = 1; i < args.length; i++) { + name += " " + args[i]; + } + name = name.replace('&', '\247').replace("\247\247", "&"); + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode!"); + } + stack.setStackDisplayName(name); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Item's name changed to \2477" + name + "\247e."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/RepairCommand.java b/src/main/java/com/rayferric/havook/feature/command/RepairCommand.java new file mode 100644 index 0000000..0087d4c --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/RepairCommand.java @@ -0,0 +1,40 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +public class RepairCommand extends Command { + public RepairCommand() { + super("repair", ".repair", "Repairs the item in your hand."); + } + + public void execute(String[] args) { + if (!Minecraft.getMinecraft().player.isCreative()) { + ChatUtil.warning("You must be in creative mode."); + } + if (args.length > 0) { + ChatUtil.warning("Too many arguments."); + } + + ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); + if (stack.isEmpty()) { + ChatUtil.error("You must hold an item in your hand."); + return; + } + if (!stack.isItemStackDamageable()) { + ChatUtil.error("This item cannot take any damage."); + return; + } + if (!stack.isItemDamaged()) { + ChatUtil.error("This item is not damaged."); + return; + } + + stack.setItemDamage(0); + InventoryUtil.updateSlot(36 + Minecraft.getMinecraft().player.inventory.currentItem, stack); + ChatUtil.info("Item \2477" + stack.getDisplayName() + " \247ehas been repaired."); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/SayCommand.java b/src/main/java/com/rayferric/havook/feature/command/SayCommand.java new file mode 100644 index 0000000..20f2ae5 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/SayCommand.java @@ -0,0 +1,25 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; + +public class SayCommand extends Command { + public SayCommand() { + super("say", ".say ", "Sends given message to chat."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } + String message = args[0]; + for (int i = 1; i < args.length; i++) { + message += " " + args[i]; + } + Minecraft.getMinecraft().player.sendChatMessage(message); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/command/TpCommand.java b/src/main/java/com/rayferric/havook/feature/command/TpCommand.java new file mode 100644 index 0000000..29d1922 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/command/TpCommand.java @@ -0,0 +1,126 @@ +package com.rayferric.havook.feature.command; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; + +public class TpCommand extends Command { + public TpCommand() { + super("tp", ".tp < [yaw] [pitch]|>", "Teleports you to specified player or position."); + } + + @Override + public void execute(String[] args) { + if (args.length < 1) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } else if (args.length < 2) { + EntityPlayer target = Minecraft.getMinecraft().world.getPlayerEntityByName(args[0]); + if (target == null) { + ChatUtil.error("Player \2477" + args[0] + " \247ccan not be found."); + return; + } + double x = target.posX; + double y = target.posY; + double z = target.posZ; + float pitch = target.rotationPitch; + float yaw = target.rotationYaw; + Minecraft.getMinecraft().player.setPositionAndRotation(x, y, z, yaw, pitch); + ChatUtil.info("Teleported \2477" + Minecraft.getMinecraft().player.getName() + "\247e to \2479" + x + + "\247e, \2479" + y + "\247e, \2479" + z + "\247e."); + return; + } else if (args.length < 3) { + ChatUtil.error("Invalid syntax."); + ChatUtil.syntax(syntax); + return; + } else { + double x = Minecraft.getMinecraft().player.posX; + double y = Minecraft.getMinecraft().player.posY; + double z = Minecraft.getMinecraft().player.posZ; + float pitch = Minecraft.getMinecraft().player.rotationPitch; + float yaw = Minecraft.getMinecraft().player.rotationYaw; + // CALC X + try { + x = parseMath(args[0], x); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[0] + " \247cis not a valid number."); + return; + } + // CALC Y + try { + y = parseMath(args[1], y); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[1] + " \247cis not a valid number."); + return; + } + // CALC Z + try { + z = parseMath(args[2], z); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[2] + " \247cis not a valid number."); + return; + } + if (args.length > 3) { + // CALC YAW + try { + yaw = (float) parseMath(args[3], yaw); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[3] + " \247cis not a valid number."); + return; + } + } + if (args.length > 4) { + // CALC PITCH + try { + pitch = (float) parseMath(args[4], pitch); + } catch (NullPointerException | NumberFormatException e) { + ChatUtil.error("\2477" + args[4] + " \247cis not a valid number."); + return; + } + } + if (args.length > 5) { + ChatUtil.warning("Too many arguments."); + } + Minecraft.getMinecraft().player.setPositionAndRotation(x, y, z, yaw, pitch); + ChatUtil.info("Teleported \2477" + Minecraft.getMinecraft().player.getName() + "\247e to \2479" + x + + "\247e, \2479" + y + "\247e, \2479" + z + "\247e."); + return; + } + } + + private static double parseMath(String input, double old) { + if (input.length() < 1) { + throw new NumberFormatException(); + } + if (input.charAt(0) == '~') { + if (input.length() > 2 && input.charAt(1) == '+') { + String coord = input.substring(2); + + try { + return old + Double.parseDouble(coord); + } catch (NullPointerException | NumberFormatException e) { + throw e; + } + } else if (input.length() > 2 && input.charAt(1) == '-') { + String coord = input.substring(2); + + try { + return old - Double.parseDouble(coord); + } catch (NullPointerException | NumberFormatException e) { + throw e; + } + } else if (input.length() != 1) { + throw new NumberFormatException(); + } + return old; + } else { + try { + return Double.parseDouble(input); + } catch (NullPointerException | NumberFormatException e) { + throw e; + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/ModAttribute.java b/src/main/java/com/rayferric/havook/feature/mod/ModAttribute.java new file mode 100644 index 0000000..fd14f00 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/ModAttribute.java @@ -0,0 +1,9 @@ +package com.rayferric.havook.feature.mod; + +public abstract class ModAttribute { + public String name = ""; + + public ModAttribute(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/ModAttributeBoolean.java b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeBoolean.java new file mode 100644 index 0000000..6a45ac9 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeBoolean.java @@ -0,0 +1,16 @@ +package com.rayferric.havook.feature.mod; + +public class ModAttributeBoolean extends ModAttribute { + public boolean value; + private final transient boolean nativeValue; + + public ModAttributeBoolean(String name, boolean nativeValue) { + super(name); + this.nativeValue = nativeValue; + value = nativeValue; + } + + public boolean getNativeValue() { + return nativeValue; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/ModAttributeDouble.java b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeDouble.java new file mode 100644 index 0000000..45b81f7 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeDouble.java @@ -0,0 +1,16 @@ +package com.rayferric.havook.feature.mod; + +public class ModAttributeDouble extends ModAttribute { + public double value; + private final transient double nativeValue; + + public ModAttributeDouble(String name, double nativeValue) { + super(name); + this.nativeValue = nativeValue; + value = nativeValue; + } + + public double getNativeValue() { + return nativeValue; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/ModAttributeString.java b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeString.java new file mode 100644 index 0000000..b81f700 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/ModAttributeString.java @@ -0,0 +1,16 @@ +package com.rayferric.havook.feature.mod; + +public class ModAttributeString extends ModAttribute { + public String value; + private final transient String nativeValue; + + public ModAttributeString(String name, String nativeValue) { + super(name); + this.nativeValue = nativeValue; + value = nativeValue; + } + + public String getNativeValue() { + return nativeValue; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/ModCategoryEnum.java b/src/main/java/com/rayferric/havook/feature/mod/ModCategoryEnum.java new file mode 100644 index 0000000..4224888 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/ModCategoryEnum.java @@ -0,0 +1,5 @@ +package com.rayferric.havook.feature.mod; + +public enum ModCategoryEnum { + COMBAT, MOVEMENT, RENDER, MISC +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/combat/TriggerBotMod.java b/src/main/java/com/rayferric/havook/feature/mod/combat/TriggerBotMod.java new file mode 100644 index 0000000..e394b55 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/combat/TriggerBotMod.java @@ -0,0 +1,128 @@ +package com.rayferric.havook.feature.mod.combat; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttribute; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.EntityUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemAppleGold; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemShield; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; + +public class TriggerBotMod extends Mod { + public transient ModAttributeDouble speed = new ModAttributeDouble("Speed", 7.0); + public transient ModAttributeDouble range = new ModAttributeDouble("Range", 4.75); + public transient ModAttributeBoolean useCooldown = new ModAttributeBoolean("UseCooldown", true); + public transient ModAttributeBoolean attackPlayers = new ModAttributeBoolean("AttackPlayers", true); + public transient ModAttributeBoolean attackMobs = new ModAttributeBoolean("AttackMobs", true); + public transient ModAttributeBoolean attackAnimals = new ModAttributeBoolean("AttackAnimals", false); + public transient ModAttributeBoolean attackInvisibleEntities = new ModAttributeBoolean("AttackInvisibleEntities", true); + public transient ModAttributeBoolean useAxeToBreakShield = new ModAttributeBoolean("UseAxeToBreakShield", true); + public transient ModAttributeBoolean attackWhileMainhandInUse = new ModAttributeBoolean("AttackWhileMainhandInUse", false); + + private transient long time; + + public TriggerBotMod() { + super("triggerbot", "Trigger Bot", "Automatically attacks the entity you're looking at.", + ModCategoryEnum.COMBAT); + addAttrib(speed); + addAttrib(range); + addAttrib(useCooldown); + addAttrib(attackPlayers); + addAttrib(attackMobs); + addAttrib(attackAnimals); + addAttrib(attackInvisibleEntities); + addAttrib(useAxeToBreakShield); + addAttrib(attackWhileMainhandInUse); + } + + @Override + public void onEnable() { + time = System.currentTimeMillis(); + } + + @Override + public void onLocalPlayerUpdate() { + if ((useCooldown.value ? Minecraft.getMinecraft().player.getCooledAttackStrength(0) < 1 + : (speed.value == 0 || System.currentTimeMillis() - time < 1000.0d / speed.value)) + || Minecraft.getMinecraft().objectMouseOver == null) + return; + + long newTime = System.currentTimeMillis(); + Entity entity = Minecraft.getMinecraft().objectMouseOver.entityHit; + + if (entity == null) + return; + if (Minecraft.getMinecraft().player.getDistance(entity) > range.value) + return; + if (entity instanceof EntityLivingBase && (entity.isDead || ((EntityLivingBase) entity).getHealth() < 0)) + return; + + if (entity instanceof EntityPlayer) { + if (!attackPlayers.value) + return; + if (FriendManager.isFriend(entity.getName())) + return; + double angle1 = (entity.rotationYaw + 180) % 360; + double angle2 = Minecraft.getMinecraft().player.rotationYaw % 360; + if(angle1 < 0)angle1 += 360; + if(angle2 < 0)angle2 += 360; + if(isPlayerShielded((EntityPlayer)entity) && 180 - Math.abs(Math.abs(angle1 - angle2) - 180) < 95 && (!useAxeToBreakShield.value || !(Minecraft.getMinecraft().player.getHeldItemMainhand().getItem() instanceof ItemAxe))) + return; + } else if (entity instanceof IMob) { + if (!attackMobs.value) + return; + } else if (EntityUtil.isAnimal(entity)) { + if (!attackAnimals.value) + return; + } else return; + + if(!isPlayerShielded(Minecraft.getMinecraft().player) && (attackWhileMainhandInUse.value || !isPlayerUsingMainhand(Minecraft.getMinecraft().player))) { + Minecraft.getMinecraft().playerController.attackEntity(Minecraft.getMinecraft().player, entity); + Minecraft.getMinecraft().player.swingArm(EnumHand.MAIN_HAND); + time = newTime; + } + } + + private static boolean isPlayerShielded(EntityPlayer player) { + return player.getItemInUseCount() > 0 && ( + player.getHeldItemMainhand().getItem() instanceof ItemShield || + (player.getHeldItemOffhand().getItem() instanceof ItemShield && !isPlayerUsingMainhand(player)) + ); + } + + private static boolean isPlayerUsingMainhand(EntityPlayer player) { + ItemStack main = player.getHeldItemMainhand(); + return player.getItemInUseCount() > 0 && ( + (main.getItemUseAction() == EnumAction.EAT && (!player.isCreative() && (player.getFoodStats().needFood() || main.getItem() instanceof ItemAppleGold))) || + (main.getItemUseAction() == EnumAction.BOW && canShootBow(player)) || + main.getItemUseAction() == EnumAction.DRINK || main.getItemUseAction() == EnumAction.BLOCK + ); + } + + private static boolean canShootBow(EntityPlayer player) { + if(player.isCreative())return true; + for(ItemStack stack : player.inventory.mainInventory) { + if(stack.getItem() == Items.ARROW)return true; + } + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/misc/AutoFishMod.java b/src/main/java/com/rayferric/havook/feature/mod/misc/AutoFishMod.java new file mode 100644 index 0000000..7049894 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/misc/AutoFishMod.java @@ -0,0 +1,39 @@ +package com.rayferric.havook.feature.mod.misc; + +import java.util.Timer; +import java.util.TimerTask; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraftforge.client.event.sound.PlaySoundEvent; + +public class AutoFishMod extends Mod { + private transient Timer timer = new Timer(); + + public AutoFishMod() { + super("autofish", "Auto Fish", "Catches fish automatically with fishing rod.", ModCategoryEnum.MISC); + } + + @Override + public void onPlaySound(PlaySoundEvent event) { + if (Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.fishEntity != null + && event.getName().equals("entity.bobber.splash")) { + sheduleUse(500); + sheduleUse(1000); + } + } + + private void sheduleUse(int delay) { + timer.schedule(new TimerTask() { + @Override + public void run() { + KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode()); + } + }, delay); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/misc/FastPlaceMod.java b/src/main/java/com/rayferric/havook/feature/mod/misc/FastPlaceMod.java new file mode 100644 index 0000000..c8d06b4 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/misc/FastPlaceMod.java @@ -0,0 +1,29 @@ +package com.rayferric.havook.feature.mod.misc; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; + +public class FastPlaceMod extends Mod { + private transient int nativeDelay; + + public FastPlaceMod() { + super("fastplace", "Fast Place", "Allows to place blocks faster.", ModCategoryEnum.MISC); + } + + @Override + public void onEnable() { + nativeDelay = Minecraft.getMinecraft().rightClickDelayTimer; + } + + @Override + public void onDisable() { + Minecraft.getMinecraft().rightClickDelayTimer = nativeDelay; + } + + @Override + public void onLocalPlayerUpdate() { + Minecraft.getMinecraft().rightClickDelayTimer = 0; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSneakMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSneakMod.java new file mode 100644 index 0000000..17d0543 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSneakMod.java @@ -0,0 +1,25 @@ +package com.rayferric.havook.feature.mod.movement; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; + +public class AutoSneakMod extends Mod { + public AutoSneakMod() { + super("autosneak", "Auto Sneak", "Makes you sneak automatically.", ModCategoryEnum.MOVEMENT); + } + + @Override + public void onDisable() { + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), + Minecraft.getMinecraft().gameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak)); + } + + @Override + public void onLocalPlayerUpdate() { + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSprintMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSprintMod.java new file mode 100644 index 0000000..77ae918 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoSprintMod.java @@ -0,0 +1,20 @@ +package com.rayferric.havook.feature.mod.movement; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; + +public class AutoSprintMod extends Mod { + public AutoSprintMod() { + super("autosprint", "Auto Sprint", "Makes you sprint automatically.", ModCategoryEnum.MOVEMENT); + } + + @Override + public void onLocalPlayerUpdate() { + if (Minecraft.getMinecraft().player.collidedHorizontally || Minecraft.getMinecraft().player.isSneaking()) + return; + if (Minecraft.getMinecraft().player.moveForward > 0) + Minecraft.getMinecraft().player.setSprinting(true); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/AutoWalkMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoWalkMod.java new file mode 100644 index 0000000..5299320 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/AutoWalkMod.java @@ -0,0 +1,23 @@ +package com.rayferric.havook.feature.mod.movement; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; + +public class AutoWalkMod extends Mod { + public AutoWalkMod() { + super("autowalk", "Auto Walk", "Makes you walk automatically.", ModCategoryEnum.MOVEMENT); + } + + @Override + public void onDisable() { + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode(), + Minecraft.getMinecraft().gameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward)); + } + + @Override + public void onLocalPlayerUpdate() { + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode(), true); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/ElytraBoostMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/ElytraBoostMod.java new file mode 100644 index 0000000..32929ee --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/ElytraBoostMod.java @@ -0,0 +1,27 @@ +package com.rayferric.havook.feature.mod.movement; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; +import net.minecraft.util.math.Vec3d; + +public class ElytraBoostMod extends Mod { + public ElytraBoostMod() { + super("elytraboost", "Elytra Boost", "Allows you to gain extra speed when flying with elytra.", ModCategoryEnum.MOVEMENT); + } + + @Override + public void onLocalPlayerUpdate() { + if(!Minecraft.getMinecraft().player.isElytraFlying())return; + float yaw = Minecraft.getMinecraft().player.rotationYaw; + float pitch = Minecraft.getMinecraft().player.rotationPitch; + if (Minecraft.getMinecraft().gameSettings.keyBindForward.isKeyDown()) { + Minecraft.getMinecraft().player.motionX -= Math.sin(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 0.05; + Minecraft.getMinecraft().player.motionZ += Math.cos(Math.toRadians(yaw)) * Math.cos(Math.toRadians(pitch)) * 0.05; + Minecraft.getMinecraft().player.motionY += Math.sin(Math.toRadians(pitch)) * 0.05; + } + if (Minecraft.getMinecraft().gameSettings.keyBindJump.isKeyDown())Minecraft.getMinecraft().player.motionY += 0.05; + if (Minecraft.getMinecraft().gameSettings.keyBindSneak.isKeyDown())Minecraft.getMinecraft().player.motionY -= 0.05; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/FlyMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/FlyMod.java new file mode 100644 index 0000000..2ae0f2f --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/FlyMod.java @@ -0,0 +1,47 @@ +package com.rayferric.havook.feature.mod.movement; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; + +public class FlyMod extends Mod { + public transient ModAttributeDouble speed = new ModAttributeDouble("Speed", 1.0); + + public FlyMod() { + super("fly", "Fly", "Allows you to fly.", ModCategoryEnum.MOVEMENT); + addAttrib(speed); + } + + @Override + public void onLocalPlayerUpdate() { + float yaw = Minecraft.getMinecraft().player.rotationYaw; + int dx = 0, dy = 0, dz = 0; + + if (Minecraft.getMinecraft().gameSettings.keyBindForward.isKeyDown()) + dz--; + if (Minecraft.getMinecraft().gameSettings.keyBindBack.isKeyDown()) + dz++; + + if (Minecraft.getMinecraft().gameSettings.keyBindLeft.isKeyDown()) + dx--; + if (Minecraft.getMinecraft().gameSettings.keyBindRight.isKeyDown()) + dx++; + + if (Minecraft.getMinecraft().gameSettings.keyBindJump.isKeyDown()) + dy++; + if (Minecraft.getMinecraft().gameSettings.keyBindSneak.isKeyDown()) + dy--; + + double tempSpeed = speed.value * 0.5; + + // FORWARD & BACKWARD MOVEMENT + Minecraft.getMinecraft().player.motionX = tempSpeed * dz * Math.sin(Math.toRadians(yaw)); + Minecraft.getMinecraft().player.motionZ = tempSpeed * dz * -Math.cos(Math.toRadians(yaw)); + // LEFT & RIGHT MOVEMENT + Minecraft.getMinecraft().player.motionX += tempSpeed * dx * -Math.cos(Math.toRadians(yaw)); + Minecraft.getMinecraft().player.motionZ += tempSpeed * dx * -Math.sin(Math.toRadians(yaw)); + // UP & DOWN MOVEMENT + Minecraft.getMinecraft().player.motionY = tempSpeed * dy; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/ParkourMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/ParkourMod.java new file mode 100644 index 0000000..71b4ac3 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/ParkourMod.java @@ -0,0 +1,24 @@ +package com.rayferric.havook.feature.mod.movement; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; + +public class ParkourMod extends Mod { + public ParkourMod() { + super("parkour", "Parkour", "Makes you jump automatically when reaching the edge of a block.", + ModCategoryEnum.MOVEMENT); + } + + @Override + public void onLocalPlayerUpdate() { + if (Minecraft.getMinecraft().player.onGround && !Minecraft.getMinecraft().player.isSneaking() + && !Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed() + && Minecraft.getMinecraft().world + .getCollisionBoxes(Minecraft.getMinecraft().player, Minecraft.getMinecraft().player + .getEntityBoundingBox().offset(0, -0.5, 0).expand(-0.001, 0, -0.001)) + .isEmpty()) { + Minecraft.getMinecraft().player.jump(); + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/movement/SafeWalkMod.java b/src/main/java/com/rayferric/havook/feature/mod/movement/SafeWalkMod.java new file mode 100644 index 0000000..b9589fc --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/movement/SafeWalkMod.java @@ -0,0 +1,40 @@ +package com.rayferric.havook.feature.mod.movement; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.util.BlockUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class SafeWalkMod extends Mod { + public SafeWalkMod() { + super("safewalk", "Safe Walk", "Makes you sneak on edges.", ModCategoryEnum.MOVEMENT); + } + + @Override + public void onDisable() { + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), + Minecraft.getMinecraft().gameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak)); + } + + @Override + public void onLocalPlayerUpdate() { + if (Minecraft.getMinecraft().player.onGround + && !Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed() + && !BlockUtil.isCollidable(Minecraft.getMinecraft().world + .getBlockState(new BlockPos( + Minecraft.getMinecraft().player.getPositionVector().add(new Vec3d(0, -0.5, 0)))) + .getBlock())) + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true); + + else if (!Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode())) + KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/ActiveListMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/ActiveListMod.java new file mode 100644 index 0000000..f389d16 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/ActiveListMod.java @@ -0,0 +1,32 @@ +package com.rayferric.havook.feature.mod.render; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; + +public class ActiveListMod extends Mod { + public transient ModAttributeDouble topMargin = new ModAttributeDouble("TopMargin", 0); + + public ActiveListMod() { + super("activelist", "Active List", "Shows other active mods in upper-left corner of the screen.", ModCategoryEnum.RENDER); + enabled = true; // overwritten when loading config (this enables the mod on first start) + addAttrib(topMargin); + } + + @Override + public void onRenderGameOverlay(RenderGameOverlayEvent event) { + if(event.getType() != ElementType.TEXT || Minecraft.getMinecraft().gameSettings.showDebugInfo)return; + int i = 0; + for(Mod mod : ModManager.MODS) { + if(!mod.isEnabled() || mod.id == "activelist")continue; + Minecraft.getMinecraft().fontRenderer.drawString(mod.name, 2, 2 + i++ * 10 + (int)(topMargin.value * 10), 0xEEEEEE); + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/ChestESPMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/ChestESPMod.java new file mode 100644 index 0000000..656a7d7 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/ChestESPMod.java @@ -0,0 +1,145 @@ +package com.rayferric.havook.feature.mod.render; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.EntityUtil; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.block.BlockChest; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityMinecartChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityEnderChest; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class ChestESPMod extends Mod { + private transient List TILE_ENTITIES = new ArrayList(); + private transient List ENTITIES = new ArrayList(); + private transient List TILE_BOXES = new ArrayList(); + + public ChestESPMod() { + super("chestesp", "Chest ESP", "Highlights nearby chests.", ModCategoryEnum.RENDER); + } + + @Override + public void onLocalPlayerUpdate() { + TILE_BOXES.clear(); + TILE_ENTITIES.clear(); + // TILE ENTITIES + for (TileEntity tileEntity : Minecraft.getMinecraft().world.loadedTileEntityList) { + AxisAlignedBB bb; + if (tileEntity instanceof TileEntityChest) { + TileEntityChest chest = (TileEntityChest) tileEntity; + + if (chest.adjacentChestXPos != null || chest.adjacentChestZPos != null) + continue; + + bb = Minecraft.getMinecraft().world.getBlockState(chest.getPos()) + .getBoundingBox(Minecraft.getMinecraft().world, chest.getPos()).offset(chest.getPos()); + if (bb == null) + continue; + + if (chest.adjacentChestXNeg != null) { + BlockPos pos = chest.adjacentChestXNeg.getPos(); + AxisAlignedBB newBb = Minecraft.getMinecraft().world.getBlockState(pos) + .getBoundingBox(Minecraft.getMinecraft().world, pos).offset(pos); + bb = bb.union(newBb); + + } else if (chest.adjacentChestZNeg != null) { + BlockPos pos = chest.adjacentChestZNeg.getPos(); + AxisAlignedBB newBb = Minecraft.getMinecraft().world.getBlockState(pos) + .getBoundingBox(Minecraft.getMinecraft().world, pos).offset(pos); + bb = bb.union(newBb); + } + } else if (tileEntity instanceof TileEntityEnderChest) { + TileEntityEnderChest chest = (TileEntityEnderChest) tileEntity; + bb = Minecraft.getMinecraft().world.getBlockState(chest.getPos()) + .getBoundingBox(Minecraft.getMinecraft().world, chest.getPos()).offset(chest.getPos()); + } else + continue; + + TILE_ENTITIES.add(tileEntity); + TILE_BOXES.add(bb); + } + ENTITIES.clear(); + // ENTITIES + for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { + if (entity instanceof EntityMinecartChest) + ENTITIES.add(entity); + } + } + + @Override + public void onRenderWorldLast(float partialTicks) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(3); + + GL11.glPushMatrix(); + GL11.glTranslated(-Minecraft.getMinecraft().getRenderManager().renderPosX, + -Minecraft.getMinecraft().getRenderManager().renderPosY, + -Minecraft.getMinecraft().getRenderManager().renderPosZ); + + drawESPBoxes(partialTicks); + + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } + + private void drawESPBoxes(float partialTicks) { + GL11.glLineWidth(2); + // TILE ENTITIES + for (int i = 0; i < TILE_ENTITIES.size(); i++) { + TileEntity tileEntity = TILE_ENTITIES.get(i); + + GL11.glPushMatrix(); + + if (tileEntity instanceof TileEntityChest + && ((TileEntityChest) tileEntity).getChestType() == BlockChest.Type.TRAP) + GL11.glColor4f(1f, 0.6f, 0f, 0.3f); + else if (tileEntity instanceof TileEntityEnderChest) + GL11.glColor4f(0f, 1f, 1f, 0.3f); + else + GL11.glColor4f(0f, 1f, 0f, 0.3f); + + RenderUtil.drawSolidBox(TILE_BOXES.get(i)); + RenderUtil.drawOutlinedBox(TILE_BOXES.get(i)); + + GL11.glPopMatrix(); + } + // ENTITIES + AxisAlignedBB box = new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5); + for (Entity entity : ENTITIES) { + GL11.glPushMatrix(); + Vec3d interpolated = EntityUtil.getInterpolatedPos(entity, partialTicks); + GL11.glTranslated(interpolated.x, interpolated.y + 0.38, interpolated.z); + GL11.glScaled(0.66, 0.66, 0.66); + + GL11.glColor4f(0f, 1f, 0f, 0.3f); + RenderUtil.drawSolidBox(box); + RenderUtil.drawOutlinedBox(box); + + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/FullBrightMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/FullBrightMod.java new file mode 100644 index 0000000..e59506e --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/FullBrightMod.java @@ -0,0 +1,27 @@ +package com.rayferric.havook.feature.mod.render; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; + +public class FullBrightMod extends Mod { + private transient float nativeGamma; + + public FullBrightMod() { + super("fullbright", "Full Bright", "Allows you to see in the dark.", ModCategoryEnum.RENDER); + } + + @Override + public void onEnable() { + nativeGamma = Minecraft.getMinecraft().gameSettings.gammaSetting; + Minecraft.getMinecraft().gameSettings.gammaSetting = 8f; + } + + @Override + public void onDisable() { + if (nativeGamma < 1.0) // if game has closed with Full Bright enabled, the gamma will be ducked up + Minecraft.getMinecraft().gameSettings.gammaSetting = nativeGamma; + else + Minecraft.getMinecraft().gameSettings.gammaSetting = 0.5f; + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/HealthTags.java b/src/main/java/com/rayferric/havook/feature/mod/render/HealthTags.java new file mode 100644 index 0000000..ea054ac --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/HealthTags.java @@ -0,0 +1,50 @@ +package com.rayferric.havook.feature.mod.render; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.event.RenderLivingEvent; + +public class HealthTags extends Mod { + public transient ModAttributeBoolean showSneakingPlayers = new ModAttributeBoolean("ShowSneakingPlayers", true); + public transient ModAttributeBoolean upscaleDistantTags = new ModAttributeBoolean("UpscaleDistantTags", true); + + public HealthTags() { + super("healthtags", "Health Tags", "Shows the health of players in their nametags.", ModCategoryEnum.RENDER); + addAttrib(showSneakingPlayers); + addAttrib(upscaleDistantTags); + } + + @Override + public void onRenderLivingSpecialsPre(RenderLivingEvent.Specials.Pre event) { + EntityLivingBase entity = event.getEntity(); + if(!(entity instanceof EntityPlayer) || entity == Minecraft.getMinecraft().player) + return; + if (entity.isDead || entity.getHealth() < 0 || entity.isInvisible()) + return; + GL11.glPushMatrix(); + Vec3d pos = new Vec3d(event.getX(), event.getY() + entity.height / 1.5, event.getZ()); + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + GL11.glTranslated(pos.x, pos.y + 1, pos.z); + if(upscaleDistantTags.value) { + double scale = Math.max(1, pos.distanceTo(new Vec3d(0, 0, 0)) / 6); + GL11.glScaled(scale, scale, scale); + } + int health = (int)Math.ceil(entity.getHealth()); + EntityRenderer.drawNameplate(Minecraft.getMinecraft().fontRenderer, + "\2477" + entity.getDisplayName().getFormattedText() + (health > 12 ? " \247a" : (health > 6 ? " \247e" : " \247c")) + health, 0, 0, 0, 0, + Minecraft.getMinecraft().getRenderManager().playerViewY, + Minecraft.getMinecraft().getRenderManager().playerViewX, + Minecraft.getMinecraft().gameSettings.thirdPersonView == 2, showSneakingPlayers.value ? false : entity.isSneaking()); + GL11.glPopMatrix(); + event.setCanceled(true); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/HitmanRadarMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/HitmanRadarMod.java new file mode 100644 index 0000000..0623350 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/HitmanRadarMod.java @@ -0,0 +1,135 @@ +package com.rayferric.havook.feature.mod.render; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.ChatUtil; +import com.rayferric.havook.util.EntityUtil; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public class HitmanRadarMod extends Mod { + public transient ModAttributeBoolean tracers = new ModAttributeBoolean("Tracers", true); + public transient ModAttributeBoolean showInvisibleEntities = new ModAttributeBoolean("ShowInvisibleEntities", + false); + public transient ModAttributeBoolean cacheNames = new ModAttributeBoolean("CacheNames", true); + + private transient List HITMEN = new ArrayList(); + private transient List CACHE = new ArrayList(); + private transient int BOX = 0; + private transient ItemStack WOODEN_SWORD = new ItemStack(Items.WOODEN_SWORD); + private transient ItemStack STONE_SWORD = new ItemStack(Items.STONE_SWORD); + private transient ItemStack IRON_SWORD = new ItemStack(Items.IRON_SWORD); + private transient ItemStack GOLDEN_SWORD = new ItemStack(Items.GOLDEN_SWORD); + private transient ItemStack DIAMOND_SWORD = new ItemStack(Items.DIAMOND_SWORD); + + public HitmanRadarMod() { + super("hitmanradar", "Hitman Radar", "Highlights players with a sword. Useful when playing Murder Mystery minigame.", ModCategoryEnum.RENDER); + + addAttrib(tracers); + addAttrib(showInvisibleEntities); + addAttrib(cacheNames); + } + + @Override + public void onEnable() { + BOX = GL11.glGenLists(1); + GL11.glNewList(BOX, GL11.GL_COMPILE); + RenderUtil.drawOutlinedBox(new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5)); + GL11.glEndList(); + CACHE.clear(); + } + + @Override + public void onDisable() { + GL11.glDeleteLists(BOX, 1); + } + + @Override + public void onLocalPlayerUpdate() { + HITMEN.clear(); + for (EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) { + if (entity.isDead || entity.getHealth() < 0) + continue; + if (entity == Minecraft.getMinecraft().player) + continue; + if (entity.isInvisible() && !showInvisibleEntities.value) + continue; + if (!(entity.inventory.hasItemStack(WOODEN_SWORD) || entity.inventory.hasItemStack(STONE_SWORD) + || entity.inventory.hasItemStack(IRON_SWORD) || entity.inventory.hasItemStack(GOLDEN_SWORD) + || entity.inventory.hasItemStack(DIAMOND_SWORD)) && !CACHE.contains(entity.getName())) + continue; + HITMEN.add(entity); + if(cacheNames.value)CACHE.add(entity.getName()); + } + } + + @Override + public void onRenderWorldLast(float partialTicks) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT | GL11.GL_CURRENT_BIT); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + + GL11.glPushMatrix(); + GL11.glTranslated(-Minecraft.getMinecraft().getRenderManager().renderPosX, + -Minecraft.getMinecraft().getRenderManager().renderPosY, + -Minecraft.getMinecraft().getRenderManager().renderPosZ); + + drawBoxes(partialTicks); + if (tracers.value) + drawTracers(); + + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } + + private void drawBoxes(float partialTicks) { + GL11.glLineWidth(4); + for (EntityPlayer entity : HITMEN) { + GL11.glPushMatrix(); + Vec3d interpolated = EntityUtil.getInterpolatedPos(entity, partialTicks); + GL11.glTranslated(interpolated.x, interpolated.y, interpolated.z); + GL11.glScaled(entity.width + 0.1, entity.height + 0.1, entity.width + 0.1); + GL11.glColor4f(0, 0, 0, 1); + GL11.glCallList(BOX); + GL11.glPopMatrix(); + } + } + + private void drawTracers() { + GL11.glLineWidth(4); + Vec3d start = new Vec3d(Minecraft.getMinecraft().getRenderManager().viewerPosX, + Minecraft.getMinecraft().getRenderManager().viewerPosY + Minecraft.getMinecraft().player.getEyeHeight(), + Minecraft.getMinecraft().getRenderManager().viewerPosZ) + .add(Minecraft.getMinecraft().player.getLookVec()); + GL11.glBegin(GL11.GL_LINES); + for (EntityPlayer entity : HITMEN) { + Vec3d target = entity.getEntityBoundingBox().getCenter(); + GL11.glColor4f(0, 0, 0, 1); + GL11.glVertex3d(start.x, start.y, start.z); + GL11.glVertex3d(target.x, target.y, target.z); + } + GL11.glEnd(); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/ItemESPMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/ItemESPMod.java new file mode 100644 index 0000000..8a63fab --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/ItemESPMod.java @@ -0,0 +1,98 @@ +package com.rayferric.havook.feature.mod.render; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.util.EntityUtil; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public class ItemESPMod extends Mod { + public transient ModAttributeBoolean tracers = new ModAttributeBoolean("Tracers", false); + public transient ModAttributeBoolean showItemNames = new ModAttributeBoolean("ShowItemNames", true); + + private transient List ENTITIES = new ArrayList(); + private transient int BOX = 0; + + public ItemESPMod() { + super("itemesp", "Item ESP", "Highlights nearby items.", ModCategoryEnum.RENDER); + + addAttrib(tracers); + addAttrib(showItemNames); + } + + @Override + public void onEnable() { + BOX = GL11.glGenLists(1); + GL11.glNewList(BOX, GL11.GL_COMPILE); + RenderUtil.drawOutlinedBox(new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5)); + GL11.glEndList(); + } + + @Override + public void onDisable() { + GL11.glDeleteLists(BOX, 1); + } + + @Override + public void onLocalPlayerUpdate() { + ENTITIES.clear(); + for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { + if (entity instanceof EntityItem) + ENTITIES.add(entity); + } + } + + @Override + public void onRenderWorldLast(float partialTicks) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT | GL11.GL_CURRENT_BIT); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + + GL11.glPushMatrix(); + GL11.glTranslated(-Minecraft.getMinecraft().getRenderManager().renderPosX, + -Minecraft.getMinecraft().getRenderManager().renderPosY, + -Minecraft.getMinecraft().getRenderManager().renderPosZ); + + RenderUtil.drawESPBoxes(ENTITIES, BOX, partialTicks); + if (tracers.value) + RenderUtil.drawESPTracers(ENTITIES); + GL11.glPopAttrib(); + if (showItemNames.value) + drawStackNames(partialTicks); + + GL11.glPopMatrix(); + } + + private void drawStackNames(float partialTicks) { + for (Entity entity : ENTITIES) { + GL11.glPushMatrix(); + Vec3d interpolated = EntityUtil.getInterpolatedPos(entity, partialTicks); + GL11.glTranslated(interpolated.x, interpolated.y, interpolated.z); + ItemStack stack = ((EntityItem) entity).getItem(); + EntityRenderer.drawNameplate(Minecraft.getMinecraft().fontRenderer, + stack.getCount() + "x " + stack.getDisplayName(), 0, 1, 0, 0, + Minecraft.getMinecraft().getRenderManager().playerViewY, + Minecraft.getMinecraft().getRenderManager().playerViewX, + Minecraft.getMinecraft().gameSettings.thirdPersonView == 2, false); + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/MobESPMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/MobESPMod.java new file mode 100644 index 0000000..dea3419 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/MobESPMod.java @@ -0,0 +1,93 @@ +package com.rayferric.havook.feature.mod.render; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.EntityUtil; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public class MobESPMod extends Mod { + public transient ModAttributeBoolean tracers = new ModAttributeBoolean("Tracers", false); + public transient ModAttributeBoolean showAnimals = new ModAttributeBoolean("ShowAnimals", true); + public transient ModAttributeBoolean showInvisibleEntities = new ModAttributeBoolean("ShowInvisibleEntities", + true); + + private transient List ENTITIES = new ArrayList(); + private transient int BOX = 0; + + public MobESPMod() { + super("mobesp", "Mob ESP", "Highlights nearby mobs.", ModCategoryEnum.RENDER); + + addAttrib(tracers); + addAttrib(showAnimals); + addAttrib(showInvisibleEntities); + } + + @Override + public void onEnable() { + BOX = GL11.glGenLists(1); + GL11.glNewList(BOX, GL11.GL_COMPILE); + RenderUtil.drawOutlinedBox(new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5)); + GL11.glEndList(); + } + + @Override + public void onDisable() { + GL11.glDeleteLists(BOX, 1); + } + + @Override + public void onLocalPlayerUpdate() { + ENTITIES.clear(); + for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { + if (!(entity instanceof EntityLiving)) + continue; + if (entity.isDead || ((EntityLiving) entity).getHealth() < 0) + continue; + if (EntityUtil.isAnimal(entity) && !showAnimals.value) + continue; + if (entity.isInvisible() && !showInvisibleEntities.value) + continue; + ENTITIES.add(entity); + } + } + + @Override + public void onRenderWorldLast(float partialTicks) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT | GL11.GL_CURRENT_BIT); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + + GL11.glPushMatrix(); + GL11.glTranslated(-Minecraft.getMinecraft().getRenderManager().renderPosX, + -Minecraft.getMinecraft().getRenderManager().renderPosY, + -Minecraft.getMinecraft().getRenderManager().renderPosZ); + + RenderUtil.drawESPBoxes(ENTITIES, BOX, partialTicks); + if (tracers.value) + RenderUtil.drawESPTracers(ENTITIES); + + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/PlayerESPMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/PlayerESPMod.java new file mode 100644 index 0000000..7c151c9 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/PlayerESPMod.java @@ -0,0 +1,86 @@ +package com.rayferric.havook.feature.mod.render; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public class PlayerESPMod extends Mod { + public transient ModAttributeBoolean tracers = new ModAttributeBoolean("Tracers", true); + public transient ModAttributeBoolean showInvisibleEntities = new ModAttributeBoolean("ShowInvisibleEntities", + true); + + private transient List ENTITIES = new ArrayList(); + private transient int BOX = 0; + + public PlayerESPMod() { + super("playeresp", "Player ESP", "Highlights nearby players.", ModCategoryEnum.RENDER); + + addAttrib(tracers); + addAttrib(showInvisibleEntities); + } + + @Override + public void onEnable() { + BOX = GL11.glGenLists(1); + GL11.glNewList(BOX, GL11.GL_COMPILE); + RenderUtil.drawOutlinedBox(new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5)); + GL11.glEndList(); + } + + @Override + public void onDisable() { + GL11.glDeleteLists(BOX, 1); + } + + @Override + public void onLocalPlayerUpdate() { + ENTITIES.clear(); + for (EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) { + if (entity.isDead || entity.getHealth() < 0) + continue; + if (entity == Minecraft.getMinecraft().player) + continue; + if (entity.isInvisible() && !showInvisibleEntities.value) + continue; + ENTITIES.add(entity); + } + } + + @Override + public void onRenderWorldLast(float partialTicks) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT | GL11.GL_CURRENT_BIT); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + + GL11.glPushMatrix(); + GL11.glTranslated(-Minecraft.getMinecraft().getRenderManager().renderPosX, + -Minecraft.getMinecraft().getRenderManager().renderPosY, + -Minecraft.getMinecraft().getRenderManager().renderPosZ); + + RenderUtil.drawESPBoxes(ENTITIES, BOX, partialTicks); + if (tracers.value) + RenderUtil.drawESPTracers(ENTITIES); + + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } +} diff --git a/src/main/java/com/rayferric/havook/feature/mod/render/TrajectoriesMod.java b/src/main/java/com/rayferric/havook/feature/mod/render/TrajectoriesMod.java new file mode 100644 index 0000000..a3c2975 --- /dev/null +++ b/src/main/java/com/rayferric/havook/feature/mod/render/TrajectoriesMod.java @@ -0,0 +1,218 @@ +package com.rayferric.havook.feature.mod.render; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModCategoryEnum; +import com.rayferric.havook.util.BlockUtil; +import com.rayferric.havook.util.EntityUtil; +import com.rayferric.havook.util.RenderUtil; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemEgg; +import net.minecraft.item.ItemEnderPearl; +import net.minecraft.item.ItemFishingRod; +import net.minecraft.item.ItemLingeringPotion; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemSnowball; +import net.minecraft.item.ItemSplashPotion; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; + +public class TrajectoriesMod extends Mod { + private transient int BOX = 0; + + public TrajectoriesMod() { + super("trajectories", "Trajectories", "Predicts the flight path of arrows and throwable items.", + ModCategoryEnum.RENDER); + } + + @Override + public void onEnable() { + BOX = GL11.glGenLists(1); + GL11.glNewList(BOX, GL11.GL_COMPILE); + RenderUtil.drawSolidBox(new AxisAlignedBB(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5)); + GL11.glEndList(); + } + + @Override + public void onDisable() { + GL11.glDeleteLists(BOX, 1); + } + + public void onRenderWorldLast(float partialTicks) { + EntityPlayer player = Minecraft.getMinecraft().player; + + ItemStack stack = player.inventory.getCurrentItem(); + if (stack == null) + return; + + Item item = stack.getItem(); + if (!(item instanceof ItemBow || item instanceof ItemSnowball || item instanceof ItemEgg + || item instanceof ItemEnderPearl || item instanceof ItemSplashPotion + || item instanceof ItemLingeringPotion || item instanceof ItemFishingRod)) + return; + + boolean bow = stack.getItem() instanceof ItemBow; + + double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks + - Math.cos((float) Math.toRadians(player.rotationYaw)) * 0.08f; + double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks + + player.getEyeHeight() - 0.04; + double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks + - Math.sin((float) Math.toRadians(player.rotationYaw)) * 0.08f; + + float arrowMotionFactor = bow ? 1f : 0.4f; + float yaw = (float) Math.toRadians(player.rotationYaw); + float pitch = (float) Math.toRadians(player.rotationPitch); + double arrowMotionX = -Math.sin(yaw) * Math.cos(pitch) * arrowMotionFactor; + double arrowMotionY = -Math.sin(pitch) * arrowMotionFactor; + double arrowMotionZ = Math.cos(yaw) * Math.cos(pitch) * arrowMotionFactor; + double arrowMotion = Math + .sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ); + arrowMotionX /= arrowMotion; + arrowMotionY /= arrowMotion; + arrowMotionZ /= arrowMotion; + if (bow) { + float bowPower = (72000 - player.getItemInUseCount()) / 20f; + bowPower = (bowPower * bowPower + bowPower * 2f) / 3f; + + if (bowPower > 1f || bowPower <= 0.1f) + bowPower = 1f; + + bowPower *= 3f; + arrowMotionX *= bowPower; + arrowMotionY *= bowPower; + arrowMotionZ *= bowPower; + + } else { + arrowMotionX *= 1.5; + arrowMotionY *= 1.5; + arrowMotionZ *= 1.5; + } + + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LINE_BIT | GL11.GL_CURRENT_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + + double gravity = bow ? 0.005 + : item instanceof ItemPotion ? 0.04 : item instanceof ItemFishingRod ? 0.015 : 0.003; + Vec3d eyePos = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); + boolean hit = false; + boolean predictedHit = predictHit(eyePos, new Vec3d(arrowPosX, arrowPosY, arrowPosZ), + new Vec3d(arrowMotionX, arrowMotionY, arrowMotionZ), gravity); + if (predictedHit) + GL11.glColor4f(0.9f, 0.2f, 0.1f, 0.5f); + else + GL11.glColor4f(0, 0.9f, 0.8f, 0.5f); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = 0; i < 1000; i++) { + if (Minecraft.getMinecraft().world.rayTraceBlocks(eyePos, + new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null) { + if (predictedHit) + GL11.glColor4f(0.3f, 0.1f, 0.1f, 0.5f); + else + GL11.glColor4f(0.1f, 0.3f, 0.3f, 0.5f); + } else { + if (predictedHit) + GL11.glColor4f(0.9f, 0.2f, 0.1f, 0.5f); + else + GL11.glColor4f(0, 0.9f, 0.8f, 0.5f); + } + GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, + arrowPosZ - renderManager.renderPosZ); + + arrowPosX += arrowMotionX * 0.1; + arrowPosY += arrowMotionY * 0.1; + arrowPosZ += arrowMotionZ * 0.1; + arrowMotionX *= 0.999; + arrowMotionY *= 0.999; + arrowMotionZ *= 0.999; + arrowMotionY -= gravity; + + for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { + if (entity instanceof EntityLiving && entity.getEntityBoundingBox().grow(0.35, 0.35, 0.35) + .contains(new Vec3d(arrowPosX, arrowPosY, arrowPosZ))) { + hit = true; + break; + } + } + if (hit) + break; + for (EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) { + if (entity != Minecraft.getMinecraft().player && entity.getEntityBoundingBox().grow(0.35, 0.35, 0.35) + .contains(new Vec3d(arrowPosX, arrowPosY, arrowPosZ))) { + hit = true; + break; + } + } + if (hit) + break; + Block block = Minecraft.getMinecraft().world + .getBlockState(new BlockPos(new Vec3d(arrowPosX, arrowPosY, arrowPosZ))).getBlock(); + if (BlockUtil.isCollidable(block)) + break; + } + GL11.glEnd(); + + GL11.glPushMatrix(); + GL11.glTranslated(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, + arrowPosZ - renderManager.renderPosZ); + GL11.glCallList(BOX); + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } + + boolean predictHit(Vec3d eyePos, Vec3d arrowPos, Vec3d arrowMotion, double gravity) { + boolean hit = false; + for (int i = 0; i < 250; i++) { + arrowPos = arrowPos.add(arrowMotion.scale(0.4)); + arrowMotion = new Vec3d(arrowMotion.x * 0.996, arrowMotion.y * 0.996 - gravity * 4.0, + arrowMotion.z * 0.996); + + for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { + if (entity instanceof EntityLiving + && entity.getEntityBoundingBox().grow(0.35, 0.35, 0.35).contains(arrowPos)) { + hit = true; + break; + } + } + if (hit) + break; + for (EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) { + if (entity != Minecraft.getMinecraft().player + && entity.getEntityBoundingBox().grow(0.35, 0.35, 0.35).contains(arrowPos)) { + hit = true; + break; + } + } + if (hit) + break; + + Block block = Minecraft.getMinecraft().world.getBlockState(new BlockPos(arrowPos)).getBlock(); + if (BlockUtil.isCollidable(block)) + break; + } + return hit; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/FriendsGui.java b/src/main/java/com/rayferric/havook/gui/FriendsGui.java new file mode 100644 index 0000000..f74d484 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/FriendsGui.java @@ -0,0 +1,117 @@ +package com.rayferric.havook.gui; + +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.gui.list.FriendList; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; + +public class FriendsGui extends GuiScreen { + FriendList friendList; + GuiButton removeFriendButton; + GuiTextField addFriendField; + + @Override + public void initGui() { + friendList = new FriendList(width / 2, height - 150, width / 4, 60); + + buttonList.add(new GuiButton(0, 20, 20, 100, 20, "\247lBack")); + buttonList.add(new GuiButton(1, width - 120, 20, 100, 20, "Clear")); + buttonList.add(new GuiButton(2, width / 2 + 3, height - 10 - 30, 97, 20, "Add")); + removeFriendButton = new GuiButton(2, width / 2 - 100, height - 10 - 30, 97, 20, "Remove"); + + addFriendField = new GuiTextField(0, fontRenderer, width / 2 - 100, height - 10 - 60, 200, 20); + addFriendField.setMaxStringLength(128); + addFriendField.setText(""); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + friendList.drawScreen(mouseX, mouseY, partialTicks); + + if (friendList.selection != null) + removeFriendButton.drawButton(mc, mouseX, mouseY, partialTicks); + + addFriendField.drawTextBox(); + + drawCenteredString(fontRenderer, "\247lFriends", width / 2, 20, 0xff55ff); + drawString(fontRenderer, Havook.NAME + " " + Havook.VERSION, 2, height - 10, 0x808080); + } + + @Override + public void updateScreen() { + addFriendField.updateCursorCounter(); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + friendList.actionPerformed(button); + + if (!button.enabled) { + return; + } + + switch (button.id) { + case 0: + Minecraft.getMinecraft().displayGuiScreen(new MainMenuGui()); + break; + case 1: + FriendManager.clearFriends(); + friendList.updateEntries(); + break; + case 2: + String text = addFriendField.getText().replaceAll("\\s+", ""); + if (text.isEmpty() || FriendManager.isFriend(text)) + break; + FriendManager.addFriend(text); + friendList.updateEntries(); + addFriendField.setText(""); + break; + default: + break; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + addFriendField.textboxKeyTyped(typedChar, keyCode); + if (keyCode == Keyboard.KEY_ESCAPE) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) throws IOException { + super.mouseClicked(x, y, button); + addFriendField.mouseClicked(x, y, button); + if (friendList.selection != null && removeFriendButton.mousePressed(mc, x, y)) { + FriendManager.removeFriend(friendList.selection); + friendList.updateEntries(); + } + } + + @Override + public void mouseReleased(int x, int y, int button) { + super.mouseReleased(x, y, button); + if (friendList.selection != null) + removeFriendButton.mouseReleased(x, y); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/KeybindsGui.java b/src/main/java/com/rayferric/havook/gui/KeybindsGui.java new file mode 100644 index 0000000..46a24ee --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/KeybindsGui.java @@ -0,0 +1,174 @@ +package com.rayferric.havook.gui; + +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Keybind; +import com.rayferric.havook.gui.list.KeybindList; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.manager.KeybindManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; + +public class KeybindsGui extends GuiScreen { + private KeybindList keybindList; + private GuiButton setKeyButton; + private GuiButton removeKeybindButton; + private GuiTextField setKeybindField; + private int keybindId = 0; + private int keybindKey = Keyboard.KEY_NONE; + private boolean keyListenerEnabled = false; + + @Override + public void initGui() { + keybindList = new KeybindList(width / 2 - 30, height - 120, 20, 60); + + buttonList.add(new GuiButton(0, 20, 20, 100, 20, "\247lBack")); + buttonList.add(new GuiButton(1, width - 120, 20, 100, 20, "Reset")); + buttonList.add(new GuiButton(2, width / 4 * 3 - 10 - 90, height / 2 - 10 - 60, 20, 20, "-")); + buttonList.add(new GuiButton(3, width / 4 * 3 - 10 - 10, height / 2 - 10 - 60, 20, 20, "+")); + buttonList.add(new GuiButton(4, width / 4 * 3 + 3, height / 2 - 10 + 45, 97, 20, "Set")); + setKeyButton = new GuiButton(5, width / 4 * 3 - 100, height / 2 - 10 - 30, 100, 20, "KEY"); + removeKeybindButton = new GuiButton(6, width / 4 * 3 - 100, height / 2 - 10 + 45, 97, 20, "Remove"); + + setKeybindField = new GuiTextField(0, fontRenderer, width / 4 * 3 - 100, height / 2 - 10, 200, 20); + setKeybindField.setMaxStringLength(32768); + setKeybindField.setText(""); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + // LOGIC + if (keybindList.hasSelectionUpdated) { + keybindId = keybindList.selection.id; + keybindKey = keybindList.selection.key; + setKeybindField.setText(keybindList.selection.message); + + keybindList.hasSelectionUpdated = false; + } + + if (keyListenerEnabled) { + if (((int) System.currentTimeMillis() / 500 % 2) == 0) + setKeyButton.displayString = ""; + else + setKeyButton.displayString = "\247a\247l> <"; + } else + setKeyButton.displayString = "\247a\247l" + Keyboard.getKeyName(keybindKey); + // RENDER + drawDefaultBackground(); + + keybindList.drawScreen(mouseX, mouseY, partialTicks); + + setKeyButton.drawButton(mc, mouseX, mouseY, partialTicks); + if (keybindList.selection != null) + removeKeybindButton.drawButton(mc, mouseX, mouseY, partialTicks); + + setKeybindField.drawTextBox(); + + super.drawScreen(mouseX, mouseY, partialTicks); + + drawCenteredString(fontRenderer, "\247lKeybinds", width / 2, 20, 0xffff55); + drawString(fontRenderer, Havook.NAME + " " + Havook.VERSION, 2, height - 10, 0x808080); + + drawString(fontRenderer, "\247c\247lID", width / 4 * 3 - 110 - fontRenderer.getStringWidth("\247c\247lID"), + height / 2 - 60 - (fontRenderer.FONT_HEIGHT / 2), 0xffffff); + drawString(fontRenderer, "\247c\247lKEY", width / 4 * 3 - 110 - fontRenderer.getStringWidth("\247c\247lKEY"), + height / 2 - 30 - (fontRenderer.FONT_HEIGHT / 2), 0xffffff); + drawString(fontRenderer, "\247c\247lMSG", width / 4 * 3 - 110 - fontRenderer.getStringWidth("\247c\247lMSG"), + height / 2 - (fontRenderer.FONT_HEIGHT / 2), 0xffffff); + drawCenteredString(fontRenderer, Integer.toString(keybindId), width / 4 * 3 - 50, + height / 2 - 60 - (fontRenderer.FONT_HEIGHT / 2), 0x5555ff); + } + + @Override + public void updateScreen() { + setKeybindField.updateCursorCounter(); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + keybindList.actionPerformed(button); + + if (!button.enabled) { + return; + } + + switch (button.id) { + case 0: + Minecraft.getMinecraft().displayGuiScreen(new MainMenuGui()); + break; + case 1: + KeybindManager.resetKeybinds(); + keybindList.updateEntries(); + break; + case 2: + keybindId--; + break; + case 3: + keybindId++; + break; + case 4: + Keybind existingKeybind = KeybindManager.getKeybindById(keybindId); + if (existingKeybind != null) { + existingKeybind.id = keybindId; + existingKeybind.key = keybindKey; + existingKeybind.message = setKeybindField.getText(); + KeybindManager.saveKeybinds(); + } else { + KeybindManager.addKeybind(keybindId, keybindKey, setKeybindField.getText()); + } + setKeybindField.setText(""); + keybindList.updateEntries(); + break; + default: + break; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + if (keyListenerEnabled) { + if (keyCode == Keyboard.KEY_LCONTROL && Keyboard.isKeyDown(Keyboard.KEY_RMENU)) + keybindKey = Keyboard.KEY_RMENU; + else + keybindKey = keyCode; + keyListenerEnabled = false; + return; + } + setKeybindField.textboxKeyTyped(typedChar, keyCode); + if (keyCode == Keyboard.KEY_ESCAPE) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) throws IOException { + super.mouseClicked(x, y, button); + setKeybindField.mouseClicked(x, y, button); + if (setKeyButton.mousePressed(mc, x, y)) { + keybindKey = Keyboard.KEY_NONE; + keyListenerEnabled = true; + } + if (keybindList.selection != null && removeKeybindButton.mousePressed(mc, x, y)) { + KeybindManager.removeKeybind(keybindList.selection.id); + keybindList.updateEntries(); + } + } + + @Override + public void mouseReleased(int x, int y, int button) { + super.mouseReleased(x, y, button); + setKeyButton.mouseReleased(x, y); + if (keybindList.selection != null) + removeKeybindButton.mouseReleased(x, y); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/LongMessageSenderGui.java b/src/main/java/com/rayferric/havook/gui/LongMessageSenderGui.java new file mode 100644 index 0000000..689fca8 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/LongMessageSenderGui.java @@ -0,0 +1,86 @@ +package com.rayferric.havook.gui; + +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; + +public class LongMessageSenderGui extends GuiScreen { + private GuiTextField messageField; + + @Override + public void initGui() { + buttonList.add(new GuiButton(0, 20, 20, 100, 20, "\247lBack")); + buttonList.add(new GuiButton(1, width / 2 - 100, height / 2 + 35, 200, 20, "Send")); + + messageField = new GuiTextField(0, fontRenderer, width / 2 - 200, height / 2 - 50, 400, 20); + messageField.setMaxStringLength(32768); + messageField.setFocused(true); + messageField.setText(""); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + drawCenteredString(fontRenderer, "\247lLong Message Sender", width / 2, height / 2 - 90, 0x55ff55); + drawString(fontRenderer, Havook.NAME + " " + Havook.VERSION, 2, height - 10, 0x808080); + drawCenteredString(fontRenderer, "The message you type in here will be", width / 2, height / 2 - 10, 0xa0a0a0); + drawCenteredString(fontRenderer, "sent to the chat.", width / 2, height / 2, 0xa0a0a0); + + messageField.drawTextBox(); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + if (!button.enabled) { + return; + } + + switch (button.id) { + case 0: + Minecraft.getMinecraft().displayGuiScreen(new MainMenuGui()); + break; + case 1: + Minecraft.getMinecraft().displayGuiScreen(null); + ChatUtil.sendChatMessage(messageField.getText(), false); + break; + default: + break; + } + } + + @Override + public void updateScreen() { + messageField.updateCursorCounter(); + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + messageField.textboxKeyTyped(typedChar, keyCode); + if (keyCode == Keyboard.KEY_ESCAPE) { + Minecraft.getMinecraft().displayGuiScreen(null); + } else if (keyCode == Keyboard.KEY_RETURN) { + Minecraft.getMinecraft().displayGuiScreen(null); + ChatUtil.sendChatMessage(messageField.getText(), false); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) throws IOException { + super.mouseClicked(x, y, button); + messageField.mouseClicked(x, y, button); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/MainMenuGui.java b/src/main/java/com/rayferric/havook/gui/MainMenuGui.java new file mode 100644 index 0000000..c013171 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/MainMenuGui.java @@ -0,0 +1,69 @@ +package com.rayferric.havook.gui; + +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.Havook; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; + +public class MainMenuGui extends GuiScreen { + @Override + public void initGui() { + buttonList.add(new GuiButton(0, width / 2 - 100, height / 2 - 10 - 45, 200, 20, "Mods...")); + buttonList.add(new GuiButton(1, width / 2 - 100, height / 2 - 10 - 20, 200, 20, "Keybinds...")); + buttonList.add(new GuiButton(2, width / 2 - 100, height / 2 - 10 + 5, 200, 20, "Long Message Sender...")); + buttonList.add(new GuiButton(3, width / 2 - 100, height / 2 - 10 + 45, 97, 20, "Friends...")); + buttonList.add(new GuiButton(4, width / 2 + 3, height / 2 - 10 + 45, 97, 20, "\247lExit")); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + drawCenteredString(fontRenderer, "\247lMain Menu", width / 2, height / 2 - 4 - 100, 0x5555ff); + drawString(fontRenderer, Havook.NAME + " " + Havook.VERSION, 2, height - 10, 0x808080); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + if (!button.enabled) { + return; + } + + switch (button.id) { + case 0: + Minecraft.getMinecraft().displayGuiScreen(new ModsGui()); + break; + case 1: + Minecraft.getMinecraft().displayGuiScreen(new KeybindsGui()); + break; + case 2: + Minecraft.getMinecraft().displayGuiScreen(new LongMessageSenderGui()); + break; + case 3: + Minecraft.getMinecraft().displayGuiScreen(new FriendsGui()); + break; + case 4: + Minecraft.getMinecraft().displayGuiScreen(null); + break; + default: + break; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + if (keyCode == Keyboard.KEY_ESCAPE) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/ModsGui.java b/src/main/java/com/rayferric/havook/gui/ModsGui.java new file mode 100644 index 0000000..ee3da35 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/ModsGui.java @@ -0,0 +1,219 @@ +package com.rayferric.havook.gui; + +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.gui.list.ModAttributeList; +import com.rayferric.havook.gui.list.ModList; +import com.rayferric.havook.manager.ModManager; +import com.rayferric.havook.util.GuiUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; + +public class ModsGui extends GuiScreen { + private ModList modList; + private ModAttributeList attributeList; + private GuiButton toggleButton; + private GuiTextField searchField; + private GuiButton booleanToggleButton; + private GuiButton doubleDecrementButton; + private GuiButton doubleIncrementButton; + private GuiButton stringSetButton; + private GuiTextField stringSetField; + + @Override + public void initGui() { + modList = new ModList(10, 70, width / 2 - 20, (int) (height / 1.5 - 60)); + attributeList = new ModAttributeList(width / 2 + 10, 70, width / 2 - 20, height / 2 - 60); + + buttonList.add(new GuiButton(0, 20, 20, 100, 20, "\247lBack")); + toggleButton = new GuiButton(1, width / 2 - 75, 45, 150, 20, "Toggle"); + + searchField = new GuiTextField(0, fontRenderer, width / 2 - 75, 20, 150, 20); + searchField.setMaxStringLength(8); + searchField.setText(""); + + booleanToggleButton = new GuiButton(2, (int) (width * 0.75) - 50, (int) (height * 0.75 - 10 + 30), 100, 20, + "Toggle"); + doubleDecrementButton = new GuiButton(3, (int) (width * 0.75) - 10 - 40, (int) (height * 0.75 - 10 + 30), 20, + 20, "-"); + doubleIncrementButton = new GuiButton(4, (int) (width * 0.75) - 10 + 40, (int) (height * 0.75 - 10 + 30), 20, + 20, "+"); + stringSetButton = new GuiButton(5, (int) (width * 0.75) - 75, (int) (height * 0.75) - 10 + 30, 150, 20, "Set"); + + stringSetField = new GuiTextField(0, fontRenderer, (int) (width * 0.75) - 100, + (int) (height * 0.75) - 10 - 30 + 30, 200, 20); + stringSetField.setMaxStringLength(16); + stringSetField.setText(""); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + modList.drawScreen(mouseX, mouseY, partialTicks); + if (modList.hasSelectionUpdated && modList.selection != null) { + attributeList.updateEntries(modList.selection); + modList.hasSelectionUpdated = false; + } + attributeList.drawScreen(mouseX, mouseY, partialTicks); + + searchField.drawTextBox(); + + drawString(fontRenderer, Havook.NAME + " " + Havook.VERSION, 2, height - 10, 0x808080); + drawCenteredString(fontRenderer, "\247lMods", (int) (width * 0.25), 45, 0xffaa00); + drawCenteredString(fontRenderer, "\247lSettings", (int) (width * 0.75), 45, 0xaa0000); + if (modList.selection != null) { + toggleButton.displayString = "Toggle " + modList.selection.name; + toggleButton.drawButton(mc, mouseX, mouseY, partialTicks); + drawCenteredString(fontRenderer, "\2476\247l" + modList.selection.name, (int) (width * 0.25), + (int) (height / 1.5 + 20), 0xffaa00); + GuiUtil.drawLongText(fontRenderer, modList.selection.description, 20, (int) (height / 1.5 + 40), + width / 2 - 20, 3); + } + if (attributeList.selection != null) { + String typeColor = ""; + String typeName = ""; + String valueColor = ""; + String valueString = ""; + if (attributeList.selection instanceof ModAttributeBoolean) { + typeColor = "\247d"; + typeName = "BOOLEAN"; + if (((ModAttributeBoolean) attributeList.selection).value) { + valueColor = "\247a"; + booleanToggleButton.displayString = "\247atrue"; + } else { + valueColor = "\247c"; + booleanToggleButton.displayString = "\247cfalse"; + } + valueString = Boolean.toString(((ModAttributeBoolean) attributeList.selection).value); + + booleanToggleButton.drawButton(mc, mouseX, mouseY, partialTicks); + } else if (attributeList.selection instanceof ModAttributeDouble) { + typeColor = "\2479"; + typeName = "DOUBLE"; + valueColor = "\2479"; + valueString = Double.toString(Math.round(((ModAttributeDouble) attributeList.selection).value * 100) / 100f); + + doubleDecrementButton.drawButton(mc, mouseX, mouseY, partialTicks); + doubleIncrementButton.drawButton(mc, mouseX, mouseY, partialTicks); + float displayNumber = Math.round(((ModAttributeDouble) attributeList.selection).value * 100) / 100f; + drawCenteredString(fontRenderer, Float.toString(displayNumber), (int) (width * 0.75), + (int) (height * 0.75) + 30 - (fontRenderer.FONT_HEIGHT / 2), 0x5555ff); + } else if (attributeList.selection instanceof ModAttributeString) { + typeColor = "\247a"; + typeName = "STRING"; + valueColor = "\2477"; + valueString = ((ModAttributeString) attributeList.selection).value; + + stringSetButton.drawButton(mc, mouseX, mouseY, partialTicks); + stringSetField.drawTextBox(); + } + + drawCenteredString(fontRenderer, "\2474\247l" + attributeList.selection.name, (int) (width * 0.75), + height / 2 + 20, 0xffaa00); + drawString(fontRenderer, "\2477Type: " + typeColor + "\247l" + typeName, width / 2 + 20, height / 2 + 40, + 0xaaaaaa); + drawString(fontRenderer, "\2477Value: " + valueColor + valueString, width / 2 + 20, height / 2 + 50, + 0xaaaaaa); + } + } + + @Override + public void updateScreen() { + searchField.updateCursorCounter(); + stringSetField.updateCursorCounter(); + } + + @Override + protected void actionPerformed(GuiButton button) { + modList.actionPerformed(button); + attributeList.actionPerformed(button); + + if (!button.enabled) { + return; + } + + switch (button.id) { + case 0: + Minecraft.getMinecraft().displayGuiScreen(new MainMenuGui()); + break; + default: + break; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + if (searchField.textboxKeyTyped(typedChar, keyCode)) + modList.updateEntries(searchField.getText()); + if (attributeList.selection != null && attributeList.selection instanceof ModAttributeString) + stringSetField.textboxKeyTyped(typedChar, keyCode); + if (keyCode == Keyboard.KEY_ESCAPE) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) throws IOException { + super.mouseClicked(x, y, button); + searchField.mouseClicked(x, y, button); + if (modList.selection != null && toggleButton.mousePressed(mc, x, y)) { + modList.selection.setEnabled(!modList.selection.isEnabled()); + } + if (attributeList.selection != null) { + if (attributeList.selection instanceof ModAttributeBoolean) { + if (booleanToggleButton.mousePressed(mc, x, y)) { + ((ModAttributeBoolean) attributeList.selection).value = !((ModAttributeBoolean) attributeList.selection).value; + ModManager.saveMods(); + } + } else if (attributeList.selection instanceof ModAttributeDouble) { + if (doubleDecrementButton.mousePressed(mc, x, y)) { + ((ModAttributeDouble)attributeList.selection).value -= 0.1; + ModManager.saveMods(); + } + if (doubleIncrementButton.mousePressed(mc, x, y)) { + ((ModAttributeDouble)attributeList.selection).value += 0.1; + ModManager.saveMods(); + } + } else if (attributeList.selection instanceof ModAttributeString) { + stringSetField.mouseClicked(x, y, button); + if (stringSetButton.mousePressed(mc, x, y)) { + ((ModAttributeString) attributeList.selection).value = stringSetField.getText(); + ModManager.saveMods(); + stringSetField.setText(""); + } + } + } + } + + @Override + public void mouseReleased(int x, int y, int button) { + super.mouseReleased(x, y, button); + if (modList.selection != null) + toggleButton.mouseReleased(x, y); + if (attributeList.selection != null) { + if (attributeList.selection instanceof ModAttributeBoolean) { + booleanToggleButton.mouseReleased(x, y); + } else if (attributeList.selection instanceof ModAttributeDouble) { + doubleDecrementButton.mouseReleased(x, y); + doubleIncrementButton.mouseReleased(x, y); + } else if (attributeList.selection instanceof ModAttributeString) { + stringSetButton.mouseReleased(x, y); + } + } + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/gui/list/FriendList.java b/src/main/java/com/rayferric/havook/gui/list/FriendList.java new file mode 100644 index 0000000..c39d723 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/list/FriendList.java @@ -0,0 +1,55 @@ +package com.rayferric.havook.gui.list; + +import java.util.ArrayList; +import java.util.List; + +import com.rayferric.havook.manager.FriendManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.fml.client.GuiScrollingList; + +public class FriendList extends GuiScrollingList { + private List ENTRIES = new ArrayList(); + public String selection = null; + + public FriendList(int width, int height, int left, int top) { + super(Minecraft.getMinecraft(), width, height, top, top + height, left, 25); + updateEntries(); + } + + public void updateEntries() { + selection = null; + ENTRIES.clear(); + for (String friend : FriendManager.FRIENDS) { + ENTRIES.add(friend); + } + } + + @Override + protected void drawSlot(int slotIndex, int x, int y, int arg3, Tessellator tesselator) { + String friend = ENTRIES.get(slotIndex); + + Minecraft.getMinecraft().ingameGUI.drawCenteredString(Minecraft.getMinecraft().fontRenderer, friend, + left + listWidth / 2, + slotHeight / 2 + y - (int) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 1.5), 0xffffff); + } + + @Override + protected void elementClicked(int slotIndex, boolean doubleClick) { + selection = ENTRIES.get(slotIndex); + } + + @Override + protected int getSize() { + return ENTRIES.size(); + } + + @Override + protected boolean isSelected(int slotIndex) { + return ENTRIES.get(slotIndex) == selection; + } + + @Override + protected void drawBackground() { + } +} diff --git a/src/main/java/com/rayferric/havook/gui/list/KeybindList.java b/src/main/java/com/rayferric/havook/gui/list/KeybindList.java new file mode 100644 index 0000000..f6195b6 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/list/KeybindList.java @@ -0,0 +1,66 @@ +package com.rayferric.havook.gui.list; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.input.Keyboard; + +import com.rayferric.havook.feature.Keybind; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.manager.KeybindManager; +import com.rayferric.havook.util.GuiUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.fml.client.GuiScrollingList; + +public class KeybindList extends GuiScrollingList { + private List ENTRIES = new ArrayList(); + public Keybind selection = null; + public boolean hasSelectionUpdated = false; + + public KeybindList(int width, int height, int left, int top) { + super(Minecraft.getMinecraft(), width, height, top, top + height, left, 50); + updateEntries(); + } + + public void updateEntries() { + selection = null; + ENTRIES.clear(); + for (Keybind keybind : KeybindManager.KEYBINDS) { + ENTRIES.add(keybind); + } + } + + @Override + protected void drawSlot(int slotIndex, int x, int y, int arg3, Tessellator tesselator) { + Keybind keybind = ENTRIES.get(slotIndex); + + Minecraft.getMinecraft().ingameGUI.drawCenteredString(Minecraft.getMinecraft().fontRenderer, + "\247c\247l" + Keyboard.getKeyName(keybind.key) + " \2477[\2479" + keybind.id + "\2477]", + left + listWidth / 2, + slotHeight / 3 + y - (int) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 1.5), 0xffffff); + GuiUtil.drawLongText(Minecraft.getMinecraft().fontRenderer, "\2477" + keybind.message, left + 10, + slotHeight / 3 * 2 + y - (int) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 1.5), + listWidth - 20, 1); + } + + @Override + protected void elementClicked(int slotIndex, boolean doubleClick) { + selection = ENTRIES.get(slotIndex); + hasSelectionUpdated = true; + } + + @Override + protected int getSize() { + return ENTRIES.size(); + } + + @Override + protected boolean isSelected(int slotIndex) { + return ENTRIES.get(slotIndex) == selection; + } + + @Override + protected void drawBackground() { + } +} diff --git a/src/main/java/com/rayferric/havook/gui/list/ModAttributeList.java b/src/main/java/com/rayferric/havook/gui/list/ModAttributeList.java new file mode 100644 index 0000000..3420814 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/list/ModAttributeList.java @@ -0,0 +1,68 @@ +package com.rayferric.havook.gui.list; + +import java.util.ArrayList; +import java.util.List; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttribute; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.fml.client.GuiScrollingList; + +public class ModAttributeList extends GuiScrollingList { + private List ENTRIES = new ArrayList(); + public ModAttribute selection = null; + + public ModAttributeList(int left, int top, int width, int height) { + super(Minecraft.getMinecraft(), width, height, top, top + height, left, 25); + } + + public void updateEntries(Mod mod) { + selection = null; + ENTRIES.clear(); + for (ModAttribute attribute : mod.ATTRIBUTES) { + ENTRIES.add(attribute); + } + } + + @Override + protected void drawSlot(int slotIndex, int x, int y, int arg3, Tessellator tesselator) { + ModAttribute attribute = ENTRIES.get(slotIndex); + + String type = ""; + if (attribute instanceof ModAttributeBoolean) + type = "\247d"; + else if (attribute instanceof ModAttributeDouble) + type = "\2479"; + else if (attribute instanceof ModAttributeString) + type = "\247a"; + + Minecraft.getMinecraft().ingameGUI.drawCenteredString(Minecraft.getMinecraft().fontRenderer, + type + attribute.name, left + listWidth / 2, + slotHeight / 2 + y - (int) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 1.5), 0xffffff); + } + + @Override + protected void elementClicked(int slotIndex, boolean doubleClick) { + ModAttribute entry = ENTRIES.get(slotIndex); + selection = entry; + } + + @Override + protected int getSize() { + return ENTRIES.size(); + } + + @Override + protected boolean isSelected(int slotIndex) { + return ENTRIES.get(slotIndex) == selection; + } + + @Override + protected void drawBackground() { + } +} diff --git a/src/main/java/com/rayferric/havook/gui/list/ModList.java b/src/main/java/com/rayferric/havook/gui/list/ModList.java new file mode 100644 index 0000000..839d647 --- /dev/null +++ b/src/main/java/com/rayferric/havook/gui/list/ModList.java @@ -0,0 +1,71 @@ +package com.rayferric.havook.gui.list; + +import java.util.ArrayList; +import java.util.List; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.fml.client.GuiScrollingList; + +public class ModList extends GuiScrollingList { + private List ENTRIES = new ArrayList(); + public Mod selection = null; + public boolean hasSelectionUpdated = false; + + public ModList(int left, int top, int width, int height) { + super(Minecraft.getMinecraft(), width, height, top, top + height, left, 25); + updateEntries(""); + } + + public void updateEntries(String query) { + selection = null; + ENTRIES.clear(); + for (Mod mod : ModManager.MODS) { + String compare = (mod.name + ";" + mod.description).replaceAll("\\s+", "").toLowerCase(); + if (compare.contains(query.replaceAll("\\s+", "").toLowerCase())) + ENTRIES.add(mod); + } + } + + @Override + protected void drawSlot(int slotIndex, int x, int y, int arg3, Tessellator tesselator) { + Mod mod = ENTRIES.get(slotIndex); + + String state; + if (mod.isEnabled()) + state = "\247a"; + else + state = "\247c"; + + Minecraft.getMinecraft().ingameGUI.drawCenteredString(Minecraft.getMinecraft().fontRenderer, state + mod.name, + left + listWidth / 2, + slotHeight / 2 + y - (int) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 1.5), 0xffffff); + } + + @Override + protected void elementClicked(int slotIndex, boolean doubleClick) { + Mod entry = ENTRIES.get(slotIndex); + selection = entry; + hasSelectionUpdated = true; + + if (doubleClick) + entry.setEnabled(!entry.isEnabled()); + } + + @Override + protected int getSize() { + return ENTRIES.size(); + } + + @Override + protected boolean isSelected(int slotIndex) { + return ENTRIES.get(slotIndex) == selection; + } + + @Override + protected void drawBackground() { + } +} diff --git a/src/main/java/com/rayferric/havook/handler/ChatHandler.java b/src/main/java/com/rayferric/havook/handler/ChatHandler.java new file mode 100644 index 0000000..3181289 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/ChatHandler.java @@ -0,0 +1,12 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.util.ChatUtil; +import net.minecraftforge.client.event.ClientChatEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class ChatHandler { + @SubscribeEvent + public void onChat(ClientChatEvent event) { + event.setCanceled(!ChatUtil.sendChatMessage(event.getMessage(), true)); + } +} diff --git a/src/main/java/com/rayferric/havook/handler/ClientTickHandler.java b/src/main/java/com/rayferric/havook/handler/ClientTickHandler.java new file mode 100644 index 0000000..a5dce00 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/ClientTickHandler.java @@ -0,0 +1,29 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.gui.LongMessageSenderGui; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; + +public class ClientTickHandler { + private static GuiScreen nextGui = null; + + @SubscribeEvent + public void onClientTick(ClientTickEvent event) { + if (event.phase != Phase.START) + return; + + if (nextGui != null) { + Minecraft.getMinecraft().displayGuiScreen(nextGui); + nextGui = null; + } + } + + public static void queueGui(GuiScreen gui) { + nextGui = gui; + } +} diff --git a/src/main/java/com/rayferric/havook/handler/KeyInputHandler.java b/src/main/java/com/rayferric/havook/handler/KeyInputHandler.java new file mode 100644 index 0000000..6f24c21 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/KeyInputHandler.java @@ -0,0 +1,25 @@ +package com.rayferric.havook.handler; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Keybind; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.manager.KeybindManager; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; + +public class KeyInputHandler { + @SubscribeEvent + public void onKeyInput(KeyInputEvent event) { + if (Minecraft.getMinecraft().inGameHasFocus) { + for (Keybind keybind : KeybindManager.KEYBINDS) { + keybind.process(); + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/MouseInputHandler.java b/src/main/java/com/rayferric/havook/handler/MouseInputHandler.java new file mode 100644 index 0000000..f6d1b42 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/MouseInputHandler.java @@ -0,0 +1,48 @@ +package com.rayferric.havook.handler; + +import org.lwjgl.input.Mouse; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.util.ChatUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent.MouseInputEvent; + +public class MouseInputHandler { + private boolean isFriendClickActive = false; + + @SubscribeEvent + public void onMouseInput(MouseInputEvent event) { + if (Minecraft.getMinecraft().inGameHasFocus) { + if (!isFriendClickActive && Mouse.isButtonDown(2) && Minecraft.getMinecraft().objectMouseOver != null) { + isFriendClickActive = true; + Entity entity = Minecraft.getMinecraft().objectMouseOver.entityHit; + if (entity == null) + return; + if (entity instanceof EntityPlayer) { + if (entity.isDead || ((EntityLivingBase) entity).getHealth() < 0) + return; + if (entity == Minecraft.getMinecraft().player) + return; + } else + return; + + if (!FriendManager.isFriend(entity.getName())) { + if (FriendManager.addFriend(entity.getName())) { + ChatUtil.info("Added \2477" + entity.getName() + "\247e to friends."); + } + } else { + if (FriendManager.removeFriend(entity.getName())) { + ChatUtil.info("Removed \2477" + entity.getName() + " \247efrom friends."); + } + } + } else if (!Mouse.isButtonDown(2)) { + isFriendClickActive = false; + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/PlaySoundHandler.java b/src/main/java/com/rayferric/havook/handler/PlaySoundHandler.java new file mode 100644 index 0000000..2d399d5 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/PlaySoundHandler.java @@ -0,0 +1,19 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class PlaySoundHandler { + @SubscribeEvent + public void onPlaySound(PlaySoundEvent event) { + for (Mod mod : ModManager.MODS) { + if (mod.isEnabled()) { + mod.onPlaySound(event); + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/PlayerTickHandler.java b/src/main/java/com/rayferric/havook/handler/PlayerTickHandler.java new file mode 100644 index 0000000..d5cea22 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/PlayerTickHandler.java @@ -0,0 +1,35 @@ +package com.rayferric.havook.handler; + +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.CPacketChatMessage; +import net.minecraft.network.play.client.CPacketEnchantItem; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; +import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; + +public class PlayerTickHandler { + @SubscribeEvent + public void onPlayerTick(PlayerTickEvent event) { + if (event.phase != Phase.START) + return; + + EntityPlayer player = event.player; + if (player == Minecraft.getMinecraft().player) { + for (Mod mod : ModManager.MODS) { + if (mod.isEnabled()) { + mod.onLocalPlayerUpdate(); + } + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/RenderGameOverlayHandler.java b/src/main/java/com/rayferric/havook/handler/RenderGameOverlayHandler.java new file mode 100644 index 0000000..72316dd --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/RenderGameOverlayHandler.java @@ -0,0 +1,17 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class RenderGameOverlayHandler { + @SubscribeEvent + public void onRenderGameOverlay(RenderGameOverlayEvent event) { + for (Mod mod : ModManager.MODS) { + if (mod.isEnabled()) { + mod.onRenderGameOverlay(event); + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/RenderLivingEventHandler.java b/src/main/java/com/rayferric/havook/handler/RenderLivingEventHandler.java new file mode 100644 index 0000000..1a0ec69 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/RenderLivingEventHandler.java @@ -0,0 +1,17 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class RenderLivingEventHandler { + @SubscribeEvent + public void onRenderLivingSpecialsPre(RenderLivingEvent.Specials.Pre event) { + for (Mod mod : ModManager.MODS) { + if (mod.isEnabled()) { + mod.onRenderLivingSpecialsPre(event); + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/handler/RenderWorldLastHandler.java b/src/main/java/com/rayferric/havook/handler/RenderWorldLastHandler.java new file mode 100644 index 0000000..cb7cb91 --- /dev/null +++ b/src/main/java/com/rayferric/havook/handler/RenderWorldLastHandler.java @@ -0,0 +1,18 @@ +package com.rayferric.havook.handler; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.manager.ModManager; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class RenderWorldLastHandler { + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + for (Mod mod : ModManager.MODS) { + if (mod.isEnabled()) { + mod.onRenderWorldLast(event.getPartialTicks()); + } + } + } +} diff --git a/src/main/java/com/rayferric/havook/manager/CommandManager.java b/src/main/java/com/rayferric/havook/manager/CommandManager.java new file mode 100644 index 0000000..4bc523d --- /dev/null +++ b/src/main/java/com/rayferric/havook/manager/CommandManager.java @@ -0,0 +1,53 @@ +package com.rayferric.havook.manager; + +import java.util.ArrayList; +import java.util.List; + +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.feature.command.AuthorCommand; +import com.rayferric.havook.feature.command.BindCommand; +import com.rayferric.havook.feature.command.ClearChatCommand; +import com.rayferric.havook.feature.command.CopyDataCommand; +import com.rayferric.havook.feature.command.CopyItemCommand; +import com.rayferric.havook.feature.command.ForwardCommand; +import com.rayferric.havook.feature.command.FriendCommand; +import com.rayferric.havook.feature.command.GiveCommand; +import com.rayferric.havook.feature.command.GuiCommand; +import com.rayferric.havook.feature.command.HatCommand; +import com.rayferric.havook.feature.command.HeadCommand; +import com.rayferric.havook.feature.command.HelpCommand; +import com.rayferric.havook.feature.command.LoreCommand; +import com.rayferric.havook.feature.command.ModCommand; +import com.rayferric.havook.feature.command.NbtCommand; +import com.rayferric.havook.feature.command.PanicCommand; +import com.rayferric.havook.feature.command.RenameCommand; +import com.rayferric.havook.feature.command.RepairCommand; +import com.rayferric.havook.feature.command.SayCommand; +import com.rayferric.havook.feature.command.TpCommand; + +public class CommandManager { + public static List COMMANDS = new ArrayList(); + + public static void loadCommands() { + COMMANDS.add(new AuthorCommand()); + COMMANDS.add(new BindCommand()); + COMMANDS.add(new ClearChatCommand()); + COMMANDS.add(new CopyDataCommand()); + COMMANDS.add(new CopyItemCommand()); + COMMANDS.add(new ForwardCommand()); + COMMANDS.add(new FriendCommand()); + COMMANDS.add(new GiveCommand()); + COMMANDS.add(new GuiCommand()); + COMMANDS.add(new HatCommand()); + COMMANDS.add(new HeadCommand()); + COMMANDS.add(new HelpCommand()); + COMMANDS.add(new LoreCommand()); + COMMANDS.add(new ModCommand()); + COMMANDS.add(new NbtCommand()); + COMMANDS.add(new PanicCommand()); + COMMANDS.add(new RenameCommand()); + COMMANDS.add(new RepairCommand()); + COMMANDS.add(new SayCommand()); + COMMANDS.add(new TpCommand()); + } +} diff --git a/src/main/java/com/rayferric/havook/manager/ConfigManager.java b/src/main/java/com/rayferric/havook/manager/ConfigManager.java new file mode 100644 index 0000000..da3fbfe --- /dev/null +++ b/src/main/java/com/rayferric/havook/manager/ConfigManager.java @@ -0,0 +1,46 @@ +package com.rayferric.havook.manager; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import com.rayferric.havook.Havook; + +public class ConfigManager { + private static JsonObject jsonObject; + + public static void loadConfig() { + try { + File file = new File("config/" + Havook.MODID + ".json"); + FileReader reader = new FileReader(file); + char[] charBuffer = new char[(int) file.length()]; + reader.read(charBuffer); + reader.close(); + jsonObject = new JsonParser().parse(String.valueOf(charBuffer)).getAsJsonObject(); + } catch (Exception e) { + Havook.LOGGER.warning(e.getMessage()); + jsonObject = new JsonObject(); + } + } + + public static void saveConfig() { + Gson gson = new GsonBuilder().create(); + try { + FileWriter writer = new FileWriter("config/" + Havook.MODID + ".json"); + writer.write(gson.toJson(jsonObject)); + writer.close(); + } catch (IOException e) { + Havook.LOGGER.warning(e.getMessage()); + } + } + + public static JsonObject getJsonObject() { + return jsonObject; + } +} diff --git a/src/main/java/com/rayferric/havook/manager/FriendManager.java b/src/main/java/com/rayferric/havook/manager/FriendManager.java new file mode 100644 index 0000000..601a1c3 --- /dev/null +++ b/src/main/java/com/rayferric/havook/manager/FriendManager.java @@ -0,0 +1,69 @@ +package com.rayferric.havook.manager; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +import com.rayferric.havook.Havook; + +public class FriendManager { + public static List FRIENDS = new ArrayList(); + + public static void loadFriends() { + JsonArray friendsArray = ConfigManager.getJsonObject().getAsJsonArray("friends"); + if (friendsArray == null) { + clearFriends(); + return; + } + for (int i = 0; i < friendsArray.size(); i++) { + FRIENDS.add(friendsArray.get(i).getAsString()); + } + } + + public static void saveFriends() { + Gson gson = new Gson(); + JsonElement element = gson.toJsonTree(FRIENDS, new TypeToken>() { + }.getType()); + ConfigManager.getJsonObject().add("friends", element); + ConfigManager.saveConfig(); + } + + public static void clearFriends() { + FRIENDS.clear(); + saveFriends(); + } + + public static boolean removeFriend(String nick) { + for (int i = 0; i < FRIENDS.size(); i++) { + if (FRIENDS.get(i).equalsIgnoreCase(nick)) { + FRIENDS.remove(i); + saveFriends(); + return true; + } + } + return false; + } + + public static boolean addFriend(String nick) { + for (int i = 0; i < FRIENDS.size(); i++) { + if (FRIENDS.get(i).equalsIgnoreCase(nick)) { + return false; + } + } + FRIENDS.add(nick); + saveFriends(); + return true; + } + + public static boolean isFriend(String nick) { + for (String friend : FRIENDS) { + if (friend.equalsIgnoreCase(nick)) + return true; + } + return false; + } +} diff --git a/src/main/java/com/rayferric/havook/manager/KeybindManager.java b/src/main/java/com/rayferric/havook/manager/KeybindManager.java new file mode 100644 index 0000000..2483179 --- /dev/null +++ b/src/main/java/com/rayferric/havook/manager/KeybindManager.java @@ -0,0 +1,70 @@ +package com.rayferric.havook.manager; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Keybind; + +public class KeybindManager { + public static List KEYBINDS = new ArrayList(); + + public static void loadKeybinds() { + JsonArray keybindsArray = ConfigManager.getJsonObject().getAsJsonArray("keybinds"); + if (keybindsArray == null) { + resetKeybinds(); + return; + } + for (int i = 0; i < keybindsArray.size(); i++) { + int id = keybindsArray.get(i).getAsJsonObject().get("id").getAsInt(); + int key = keybindsArray.get(i).getAsJsonObject().get("key").getAsInt(); + String message = keybindsArray.get(i).getAsJsonObject().get("message").getAsString(); + addKeybind(id, key, message); + } + } + + public static void saveKeybinds() { + Gson gson = new Gson(); + JsonElement element = gson.toJsonTree(KEYBINDS, new TypeToken>() { + }.getType()); + ConfigManager.getJsonObject().add("keybinds", element); + ConfigManager.saveConfig(); + } + + public static void resetKeybinds() { + KEYBINDS.clear(); + addKeybind(0, 54, ".gui"); + addKeybind(1, 19, ".mod t triggerbot"); + saveKeybinds(); + } + + public static boolean removeKeybind(int id) { + for (int i = 0; i < KEYBINDS.size(); i++) { + if (KEYBINDS.get(i).id == id) { + KEYBINDS.remove(i); + saveKeybinds(); + return true; + } + } + return false; + } + + public static void addKeybind(int id, int key, String message) { + KEYBINDS.add(new Keybind(id, key, message)); + saveKeybinds(); + } + + public static Keybind getKeybindById(int id) { + for (Keybind keybind : KEYBINDS) { + if (keybind.id == id) { + return keybind; + } + } + return null; + } +} diff --git a/src/main/java/com/rayferric/havook/manager/ModManager.java b/src/main/java/com/rayferric/havook/manager/ModManager.java new file mode 100644 index 0000000..f99ca41 --- /dev/null +++ b/src/main/java/com/rayferric/havook/manager/ModManager.java @@ -0,0 +1,124 @@ +package com.rayferric.havook.manager; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Mod; +import com.rayferric.havook.feature.mod.ModAttribute; +import com.rayferric.havook.feature.mod.ModAttributeBoolean; +import com.rayferric.havook.feature.mod.ModAttributeDouble; +import com.rayferric.havook.feature.mod.ModAttributeString; +import com.rayferric.havook.feature.mod.combat.TriggerBotMod; +import com.rayferric.havook.feature.mod.misc.AutoFishMod; +import com.rayferric.havook.feature.mod.misc.FastPlaceMod; +import com.rayferric.havook.feature.mod.movement.AutoSneakMod; +import com.rayferric.havook.feature.mod.movement.AutoSprintMod; +import com.rayferric.havook.feature.mod.movement.AutoWalkMod; +import com.rayferric.havook.feature.mod.movement.ElytraBoostMod; +import com.rayferric.havook.feature.mod.movement.FlyMod; +import com.rayferric.havook.feature.mod.movement.ParkourMod; +import com.rayferric.havook.feature.mod.movement.SafeWalkMod; +import com.rayferric.havook.feature.mod.render.ActiveListMod; +import com.rayferric.havook.feature.mod.render.ChestESPMod; +import com.rayferric.havook.feature.mod.render.FullBrightMod; +import com.rayferric.havook.feature.mod.render.HealthTags; +import com.rayferric.havook.feature.mod.render.ItemESPMod; +import com.rayferric.havook.feature.mod.render.MobESPMod; +import com.rayferric.havook.feature.mod.render.HitmanRadarMod; +import com.rayferric.havook.feature.mod.render.PlayerESPMod; +import com.rayferric.havook.feature.mod.render.TrajectoriesMod; +import com.rayferric.havook.util.EntityUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.Vec3d; + +public class ModManager { + public static List MODS = new ArrayList(); + + public static void loadMods() { + MODS.add(new ActiveListMod()); + MODS.add(new AutoFishMod()); + MODS.add(new AutoSneakMod()); + MODS.add(new AutoSprintMod()); + MODS.add(new AutoWalkMod()); + MODS.add(new ChestESPMod()); + MODS.add(new ElytraBoostMod()); + MODS.add(new FastPlaceMod()); + MODS.add(new FlyMod()); + MODS.add(new FullBrightMod()); + MODS.add(new HealthTags()); + MODS.add(new ItemESPMod()); + MODS.add(new MobESPMod()); + MODS.add(new HitmanRadarMod()); + MODS.add(new ParkourMod()); + MODS.add(new PlayerESPMod()); + MODS.add(new SafeWalkMod()); + MODS.add(new TrajectoriesMod()); + MODS.add(new TriggerBotMod()); + JsonArray modsArray = ConfigManager.getJsonObject().getAsJsonArray("mods"); + if(modsArray == null) { + saveMods(); + return; + } + for (int i = 0; i < modsArray.size(); i++) { + String id = modsArray.get(i).getAsJsonObject().get("id").getAsString(); + Mod targetMod = getModById(id); + if (targetMod == null)continue; + if(modsArray.get(i).getAsJsonObject().has("enabled") && modsArray.get(i).getAsJsonObject().get("enabled").getAsBoolean())if(modsArray.get(i).getAsJsonObject().get("enabled").getAsBoolean())targetMod.setEnabled(true); + for (ModAttribute targetAttribute : targetMod.ATTRIBUTES) { + String stringValue = null; + JsonArray attribsArray = modsArray.get(i).getAsJsonObject().getAsJsonArray("attributes"); + for (int j = 0; j < attribsArray.size(); j++) { + if (attribsArray.get(j).getAsJsonObject().get("name").getAsString().equals(targetAttribute.name)) { + stringValue = attribsArray.get(j).getAsJsonObject().get("value").getAsString(); + break; + } + } + if (stringValue == null)continue; + if (targetAttribute instanceof ModAttributeBoolean) { + if (stringValue.equalsIgnoreCase("true") || stringValue.equalsIgnoreCase("false")) { + Boolean value = Boolean.parseBoolean(stringValue); + ((ModAttributeBoolean) targetAttribute).value = value; + } else continue; + } else if (targetAttribute instanceof ModAttributeDouble) { + double number; + try { + number = Double.parseDouble(stringValue); + } catch (NullPointerException | NumberFormatException e) { + continue; + } + ((ModAttributeDouble) targetAttribute).value = number; + } else if (targetAttribute instanceof ModAttributeString) { + ((ModAttributeString) targetAttribute).value = stringValue; + } + } + } + saveMods(); // fix any errors in the config file + } + + public static void saveMods() { + Gson gson = new Gson(); + JsonElement element = gson.toJsonTree(MODS, new TypeToken>() { + }.getType()); + ConfigManager.getJsonObject().add("mods", element); + ConfigManager.saveConfig(); + } + + public static Mod getModById(String id) { + for (Mod mod : MODS) { + if (mod.id.equalsIgnoreCase(id)) + return mod; + } + return null; + } +} diff --git a/src/main/java/com/rayferric/havook/proxy/ClientProxy.java b/src/main/java/com/rayferric/havook/proxy/ClientProxy.java new file mode 100644 index 0000000..d9905ec --- /dev/null +++ b/src/main/java/com/rayferric/havook/proxy/ClientProxy.java @@ -0,0 +1,69 @@ +package com.rayferric.havook.proxy; + +import com.rayferric.havook.handler.ChatHandler; +import com.rayferric.havook.handler.ClientTickHandler; +import com.rayferric.havook.handler.KeyInputHandler; +import com.rayferric.havook.handler.MouseInputHandler; +import com.rayferric.havook.handler.PlaySoundHandler; +import com.rayferric.havook.handler.PlayerTickHandler; +import com.rayferric.havook.handler.RenderGameOverlayHandler; +import com.rayferric.havook.handler.RenderLivingEventHandler; +import com.rayferric.havook.handler.RenderWorldLastHandler; +import com.rayferric.havook.manager.CommandManager; +import com.rayferric.havook.manager.ConfigManager; +import com.rayferric.havook.manager.FriendManager; +import com.rayferric.havook.manager.KeybindManager; +import com.rayferric.havook.manager.ModManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import net.minecraftforge.fml.relauncher.Side; + +public class ClientProxy extends ServerProxy { + @Override + public void preInit(FMLPreInitializationEvent event) { + super.preInit(event); + if (event.getSide() == Side.CLIENT) { + ConfigManager.loadConfig(); + + CommandManager.loadCommands(); + FriendManager.loadFriends(); + KeybindManager.loadKeybinds(); + ModManager.loadMods(); + } + } + + @Override + public void init(FMLInitializationEvent event) { + super.init(event); + } + + @Override + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + if (event.getSide() == Side.CLIENT) { + MinecraftForge.EVENT_BUS.register(new ChatHandler()); + MinecraftForge.EVENT_BUS.register(new ClientTickHandler()); + MinecraftForge.EVENT_BUS.register(new KeyInputHandler()); + MinecraftForge.EVENT_BUS.register(new MouseInputHandler()); + MinecraftForge.EVENT_BUS.register(new PlayerTickHandler()); + MinecraftForge.EVENT_BUS.register(new PlaySoundHandler()); + MinecraftForge.EVENT_BUS.register(new RenderWorldLastHandler()); + MinecraftForge.EVENT_BUS.register(new RenderGameOverlayHandler()); + MinecraftForge.EVENT_BUS.register(new RenderLivingEventHandler()); + } + } + + @Override + public void serverStarting(FMLServerStartingEvent event) { + super.serverStarting(event); + } + + @Override + public void serverStopping(FMLServerStoppingEvent event) { + super.serverStopping(event); + } +} diff --git a/src/main/java/com/rayferric/havook/proxy/ServerProxy.java b/src/main/java/com/rayferric/havook/proxy/ServerProxy.java new file mode 100644 index 0000000..321ffd7 --- /dev/null +++ b/src/main/java/com/rayferric/havook/proxy/ServerProxy.java @@ -0,0 +1,24 @@ +package com.rayferric.havook.proxy; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; + +public class ServerProxy { + public void preInit(FMLPreInitializationEvent event) { + } + + public void init(FMLInitializationEvent event) { + } + + public void postInit(FMLPostInitializationEvent event) { + } + + public void serverStarting(FMLServerStartingEvent event) { + } + + public void serverStopping(FMLServerStoppingEvent event) { + } +} diff --git a/src/main/java/com/rayferric/havook/util/BlockUtil.java b/src/main/java/com/rayferric/havook/util/BlockUtil.java new file mode 100644 index 0000000..665827f --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/BlockUtil.java @@ -0,0 +1,16 @@ +package com.rayferric.havook.util; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + +public class BlockUtil { + public static boolean isCollidable(Block block) { + return block != Blocks.AIR && block != Blocks.BEETROOTS && block != Blocks.CARROTS && block != Blocks.DEADBUSH + && block != Blocks.DOUBLE_PLANT && block != Blocks.FLOWING_LAVA && block != Blocks.FLOWING_WATER + && block != Blocks.LAVA && block != Blocks.MELON_STEM && block != Blocks.NETHER_WART + && block != Blocks.POTATOES && block != Blocks.PUMPKIN_STEM && block != Blocks.RED_FLOWER + && block != Blocks.RED_MUSHROOM && block != Blocks.REDSTONE_TORCH && block != Blocks.TALLGRASS + && block != Blocks.TORCH && block != Blocks.UNLIT_REDSTONE_TORCH && block != Blocks.YELLOW_FLOWER + && block != Blocks.VINE && block != Blocks.WATER && block != Blocks.WEB && block != Blocks.WHEAT; + } +} diff --git a/src/main/java/com/rayferric/havook/util/ChatUtil.java b/src/main/java/com/rayferric/havook/util/ChatUtil.java new file mode 100644 index 0000000..ebcfbfb --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/ChatUtil.java @@ -0,0 +1,64 @@ +package com.rayferric.havook.util; + +import org.apache.commons.lang3.ArrayUtils; + +import com.rayferric.havook.Havook; +import com.rayferric.havook.feature.Command; +import com.rayferric.havook.manager.CommandManager; +import net.minecraft.client.Minecraft; +import net.minecraft.util.text.TextComponentString; + +public class ChatUtil { + public static void info(String message) { + Minecraft.getMinecraft().player + .sendMessage(new TextComponentString("\2478\247l[\2473\247l" + Havook.NAME + "\2478\247l] \247e" + message)); + } + + public static void error(String message) { + Minecraft.getMinecraft().player.sendMessage( + new TextComponentString("\2478\247l[\2473\247l" + Havook.NAME + "\2478\247l] \247c\247lERROR: \247c" + message)); + } + + public static void syntax(String message) { + Minecraft.getMinecraft().player.sendMessage( + new TextComponentString("\2478\247l[\2473\247l" + Havook.NAME + "\2478\247l] \247a\247lSYNTAX: \247a" + message)); + } + + public static void warning(String message) { + Minecraft.getMinecraft().player.sendMessage( + new TextComponentString("\2478\247l[\2473\247l" + Havook.NAME + "\2478\247l] \247b\247lWARNING: \247b" + message)); + } + + public static void clear(int lines) { + for (int i = 0; i < lines; i++) { + Minecraft.getMinecraft().player.sendMessage(new TextComponentString("")); + } + } + + public static boolean sendChatMessage(String message, boolean isFromChat) { + if(message.equalsIgnoreCase(""))return true; + String[] components = message.split("\\s+"); + if (components.length > 0) { + if (components[0].charAt(0) == '.') { + components[0] = components[0].substring(1); + executeCommand(components); + return false; + } + } + if (!isFromChat) { + Minecraft.getMinecraft().player.sendChatMessage(message); + } + return true; + } + + private static void executeCommand(String[] args) { + for (Command command : CommandManager.COMMANDS) { + if (args[0].equalsIgnoreCase(command.name)) { + command.execute(ArrayUtils.remove(args, 0)); + return; + } + } + ChatUtil.error("There's no such command with name \2477" + args[0] + + "\247c. Type .help to list all available commands."); + } +} diff --git a/src/main/java/com/rayferric/havook/util/EntityUtil.java b/src/main/java/com/rayferric/havook/util/EntityUtil.java new file mode 100644 index 0000000..11ffe8c --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/EntityUtil.java @@ -0,0 +1,22 @@ +package com.rayferric.havook.util; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.monster.EntityGolem; +import net.minecraft.entity.passive.EntityAmbientCreature; +import net.minecraft.entity.passive.EntityWaterMob; +import net.minecraft.util.math.Vec3d; + +public class EntityUtil { + public static boolean isAnimal(Entity entity) { + if (entity instanceof EntityAgeable || entity instanceof EntityAmbientCreature + || entity instanceof EntityWaterMob || entity instanceof EntityGolem) + return true; + return false; + } + + public static Vec3d getInterpolatedPos(Entity entity, float partialTicks) { + Vec3d from = new Vec3d(entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ); + return entity.getPositionVector().subtract(from).scale(partialTicks).add(from); + } +} diff --git a/src/main/java/com/rayferric/havook/util/GuiUtil.java b/src/main/java/com/rayferric/havook/util/GuiUtil.java new file mode 100644 index 0000000..1cf7f29 --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/GuiUtil.java @@ -0,0 +1,53 @@ +package com.rayferric.havook.util; + +import net.minecraft.client.gui.FontRenderer; + +public class GuiUtil { + public static void drawLongText(FontRenderer fontRenderer, String text, int x, int y, int maxWidth, + int maxLineCount) { + int lineIndex = 0; + while (!text.isEmpty()) { + String line = text; + while (fontRenderer.getStringWidth(line) > maxWidth) { + int index = line.lastIndexOf(" "); + if (index < 0) + line = ""; + else + line = line.substring(0, index); + } + text = text.substring(text.indexOf(line) + line.length()); + line = "\2477" + line.trim(); + if (lineIndex >= maxLineCount - 1 && !text.isEmpty()) { + fontRenderer.drawString(line + "...", x, y + (lineIndex * fontRenderer.FONT_HEIGHT + 4), 0xffffff); + return; + } else + fontRenderer.drawString(line, x, y + (lineIndex * fontRenderer.FONT_HEIGHT + 4), 0xffffff); + lineIndex++; + } + } + + public static void drawCenteredLongText(FontRenderer fontRenderer, String text, int x, int y, int maxWidth, + int maxLineCount) { + int lineIndex = 0; + while (!text.isEmpty()) { + String line = text; + while (fontRenderer.getStringWidth(line) > maxWidth) { + int index = line.lastIndexOf(" "); + if (index < 0) + line = ""; + else + line = line.substring(0, index); + } + text = text.substring(text.indexOf(line) + line.length()); + line = "\2477" + line.trim(); + if (lineIndex >= maxLineCount - 1 && !text.isEmpty()) { + fontRenderer.drawString(line + "...", x - fontRenderer.getStringWidth(line + "..."), + y + (lineIndex * fontRenderer.FONT_HEIGHT + 4), 0xffffff); + return; + } else + fontRenderer.drawString(line, x - fontRenderer.getStringWidth(line), + y + (lineIndex * fontRenderer.FONT_HEIGHT + 4), 0xffffff); + lineIndex++; + } + } +} diff --git a/src/main/java/com/rayferric/havook/util/InventoryUtil.java b/src/main/java/com/rayferric/havook/util/InventoryUtil.java new file mode 100644 index 0000000..f2fc933 --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/InventoryUtil.java @@ -0,0 +1,44 @@ +package com.rayferric.havook.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.CPacketCreativeInventoryAction; + +public class InventoryUtil { + public static void updateFirstEmptySlot(ItemStack stack) { + int slot = 0; + boolean slotFound = false; + for (int i = 0; i < 36; i++) { + if (Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) { + slot = i; + slotFound = true; + break; + } + } + if (!slotFound) { + ChatUtil.warning("Could not find empty slot. Operation has been aborted."); + return; + } + + int convertedSlot = slot; + if (slot < 9) + convertedSlot += 36; + + if (stack.getCount() > 64) { + ItemStack passStack = stack.copy(); + stack.setCount(64); + passStack.setCount(passStack.getCount() - 64); + Minecraft.getMinecraft().player.inventory.setInventorySlotContents(slot, stack); + Minecraft.getMinecraft().getConnection() + .sendPacket(new CPacketCreativeInventoryAction(convertedSlot, stack)); + updateFirstEmptySlot(passStack); + return; + } + + Minecraft.getMinecraft().getConnection().sendPacket(new CPacketCreativeInventoryAction(convertedSlot, stack)); + } + + public static void updateSlot(int slot, ItemStack stack) { + Minecraft.getMinecraft().getConnection().sendPacket(new CPacketCreativeInventoryAction(slot, stack)); + } +} diff --git a/src/main/java/com/rayferric/havook/util/RenderUtil.java b/src/main/java/com/rayferric/havook/util/RenderUtil.java new file mode 100644 index 0000000..1f86b2d --- /dev/null +++ b/src/main/java/com/rayferric/havook/util/RenderUtil.java @@ -0,0 +1,141 @@ +package com.rayferric.havook.util; + +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import com.rayferric.havook.manager.FriendManager; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public class RenderUtil { + public static void drawOutlinedBox(AxisAlignedBB bb) { + GL11.glBegin(GL11.GL_LINES); + { + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + } + GL11.glEnd(); + } + + public static void drawSolidBox(AxisAlignedBB bb) { + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + + GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); + GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); + GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); + + GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); + GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); + GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); + } + GL11.glEnd(); + } + + public static void drawESPBoxes(List entities, int box, float partialTicks) { + GL11.glLineWidth(2); + for (Entity entity : entities) { + GL11.glPushMatrix(); + Vec3d interpolated = EntityUtil.getInterpolatedPos(entity, partialTicks); + GL11.glTranslated(interpolated.x, interpolated.y, interpolated.z); + GL11.glScaled(entity.width + 0.1, entity.height + 0.1, entity.width + 0.1); + + if (entity instanceof EntityPlayer && FriendManager.isFriend(entity.getName())) { + GL11.glColor4f(0.9f, 0.2f, 1f, 0.5f); + } else if (entity instanceof EntityItem) { + GL11.glColor4f(0.5f, 0.5f, 1f, 0.5f); + } else { + float intensity = Minecraft.getMinecraft().player.getDistance(entity) / 20f; + GL11.glColor4f(2f - intensity, intensity, 0f, 0.5f); + } + + GL11.glCallList(box); + + GL11.glPopMatrix(); + } + } + + public static void drawESPTracers(List entities) { + Vec3d start = new Vec3d(Minecraft.getMinecraft().getRenderManager().viewerPosX, + Minecraft.getMinecraft().getRenderManager().viewerPosY + Minecraft.getMinecraft().player.getEyeHeight(), + Minecraft.getMinecraft().getRenderManager().viewerPosZ) + .add(Minecraft.getMinecraft().player.getLookVec()); + GL11.glLineWidth(2); + GL11.glBegin(GL11.GL_LINES); + for (Entity entity : entities) { + Vec3d target = entity.getEntityBoundingBox().getCenter(); + + if (entity instanceof EntityPlayer && FriendManager.isFriend(entity.getName())) { + GL11.glColor4f(0.9f, 0.2f, 1f, 0.5f); + } else if (entity instanceof EntityItem) { + GL11.glColor4f(0.5f, 0.5f, 1f, 0.5f); + } else { + float intensity = Minecraft.getMinecraft().player.getDistance(entity) / 20f; + GL11.glColor4f(2f - intensity, intensity, 0f, 0.5f); + } + + GL11.glVertex3d(start.x, start.y, start.z); + GL11.glVertex3d(target.x, target.y, target.z); + } + GL11.glEnd(); + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..9e2a3df --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,4 @@ +public net.minecraft.client.renderer.entity.RenderManager field_78725_b # renderPosX +public net.minecraft.client.renderer.entity.RenderManager field_78726_c # renderPosY +public net.minecraft.client.renderer.entity.RenderManager field_78723_d # renderPosZ +public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..33063c6 --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,15 @@ +[{ + "modid": "havook", + "name": "Havook", + "description": "Havook hacked client for Minecraft Forge 1.12.2.", + "version": "1.0.0", + "mcversion": "1.12.2", + "url": "https://github.com/rayferric/havook-1.12.2", + "updateUrl": "https://github.com/rayferric/havook-1.12.2/releases", + "authorList": ["Ray Ferric"], + "credits": "Ray Ferric", + "logoFile": "", + "screenshots": [], + "dependencies": [] +}] +