├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── CREDITS.txt ├── LICENSE-Paulscode IBXM Library.txt ├── LICENSE-Paulscode SoundSystem CodecIBXM.txt ├── LICENSE.txt ├── README.md ├── build.gradle ├── commands.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── modules.md └── src └── main ├── java └── family_fun_pack │ ├── FamilyFunPack.java │ ├── commands │ ├── BlockAtCommand.java │ ├── Command.java │ ├── Commands.java │ ├── DiffCommand.java │ ├── DisconnectCommand.java │ ├── EditSignCommand.java │ ├── FillBookCommand.java │ ├── GetCommand.java │ ├── HClipCommand.java │ ├── HelpCommand.java │ ├── IgnoreCommand.java │ ├── InfoCommand.java │ ├── ItemSizeCommand.java │ ├── KillDupeCommand.java │ ├── LoadChunkCommand.java │ ├── NearestStrongholdCommand.java │ ├── OpenDonkeyCommand.java │ ├── PacketDumpCommand.java │ ├── PeekCommand.java │ ├── PopulateCommand.java │ ├── QueueUtilsCommand.java │ ├── RaytraceCommand.java │ ├── ReOpenCommand.java │ ├── RemoteCaptureCommand.java │ ├── RemoteRideCommand.java │ ├── RespawnCommand.java │ ├── RollbackCommand.java │ ├── RollbackDupeCommand.java │ ├── SpectateCommand.java │ ├── StalkCommand.java │ ├── StealCommand.java │ ├── SyncMountCommand.java │ ├── TrackCommand.java │ ├── UnloadedRideCommand.java │ ├── UseCommand.java │ ├── VClipCommand.java │ ├── VanishCommand.java │ ├── VoidMountCommand.java │ └── WorldDownloadCommand.java │ ├── entities │ ├── EntityVoid.java │ └── GhostDonkey.java │ ├── gui │ ├── MainGui.java │ ├── MainGuiComponent.java │ ├── components │ │ ├── ActionButton.java │ │ ├── ArrowButton.java │ │ ├── ColorButton.java │ │ ├── FormatButton.java │ │ ├── GenericButton.java │ │ ├── OnOffButton.java │ │ ├── OpenGuiButton.java │ │ ├── ScrollBar.java │ │ ├── SelectButton.java │ │ ├── SliderButton.java │ │ └── actions │ │ │ ├── ColorSearch.java │ │ │ ├── NumberAction.java │ │ │ ├── NumberPumpkinAura.java │ │ │ ├── OnOffAction.java │ │ │ ├── OnOffInterception.java │ │ │ ├── OnOffPumpkinAura.java │ │ │ ├── OnOffSearch.java │ │ │ └── OnOffTracer.java │ ├── interfaces │ │ ├── AdvancedSearchGui.java │ │ ├── BookEditingGui.java │ │ ├── InfoItemGui.java │ │ ├── PacketsSelectionGui.java │ │ ├── PreviewGui.java │ │ ├── PumpkinAuraSettingsGui.java │ │ ├── RadarInterface.java │ │ ├── RightPanel.java │ │ └── SearchSelectionGui.java │ └── overlay │ │ └── OverlayGui.java │ ├── key │ └── KeyListener.java │ ├── modules │ ├── AbstractPlayersRegister.java │ ├── BookFormatModule.java │ ├── BowBombModule.java │ ├── CommandsModule.java │ ├── IgnoreModule.java │ ├── Module.java │ ├── Modules.java │ ├── NoCloseModule.java │ ├── PacketInterceptionModule.java │ ├── PigPOVModule.java │ ├── PortalInvulnerabilityModule.java │ ├── PumpkinAuraModule.java │ ├── SearchModule.java │ ├── StalkModule.java │ ├── TraceModule.java │ ├── TrueDurabilityModule.java │ └── UndeadModule.java │ ├── nbt │ └── SpecialTagCompound.java │ ├── network │ ├── InboundInterceptor.java │ ├── NetworkHandler.java │ ├── OutboundFrameEncoder.java │ ├── OutboundInterceptor.java │ └── PacketListener.java │ ├── render │ ├── CustomLayerBipedArmor.java │ ├── CustomLayerElytra.java │ ├── CustomRenderItem.java │ ├── NoRenderPig.java │ └── RenderGhostDonkey.java │ └── utils │ ├── FakeWorld.java │ ├── Timer.java │ └── WorldCapture.java └── resources ├── assets └── family_fun_pack │ └── textures │ ├── entity │ └── horse │ │ └── ghost_donkey.png │ └── gui │ ├── navigation.png │ ├── on_off.png │ └── preview.png ├── mcmod.info └── pack.mcmeta /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Gradle 2 | 3 | on: [push,pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - name: Set up JDK 1.8 12 | uses: actions/setup-java@v1 13 | with: 14 | java-version: 1.8 15 | 16 | - name: Grant execute permission for gradlew 17 | run: chmod +x gradlew 18 | 19 | - name: Decomp Workspace 20 | run: ./gradlew setupDecompWorkspace 21 | 22 | - name: Build 23 | run: ./gradlew build 24 | 25 | - uses: actions/upload-artifact@v2 26 | with: 27 | name: Package 28 | path: build/libs -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | 24 | # Apple shit 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /CREDITS.txt: -------------------------------------------------------------------------------- 1 | Minecraft Forge: Credits/Thank You 2 | 3 | Forge is a set of tools and modifications to the Minecraft base game code to assist 4 | mod developers in creating new and exciting content. It has been in development for 5 | several years now, but I would like to take this time thank a few people who have 6 | helped it along it's way. 7 | 8 | First, the people who originally created the Forge projects way back in Minecraft 9 | alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance 10 | of me taking over the project, who knows what Minecraft modding would be today. 11 | 12 | Secondly, someone who has worked with me, and developed some of the core features 13 | that allow modding to he as functional, and as simple as it is, cpw. For developing 14 | FML, which stabelized the client and server modding ecosystem. As well as the base 15 | loading system that allows us to modify Minecraft's code as elegently as possible. 16 | 17 | Mezz, who has stepped up as the issue and pull request manager. Helping to keep me 18 | sane as well as guiding the community into creating better additions to Forge. 19 | 20 | Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which 21 | I am a part}. For creating some of the core tools needed to make Minecraft modding 22 | both possible, and as stable as can be. 23 | On that note, here is some specific information of the MCP data we use: 24 | * Minecraft Coder Pack (MCP) * 25 | Forge Mod Loader and Minecraft Forge have permission to distribute and automatically 26 | download components of MCP and distribute MCP data files. This permission is not 27 | transitive and others wishing to redistribute the Minecraft Forge source independently 28 | should seek permission of MCP or remove the MCP data files and request their users 29 | to download MCP separately. 30 | 31 | And lastly, the countless community members who have spent time submitting bug reports, 32 | pull requests, and just helping out the community in general. Thank you. 33 | 34 | --LexManos 35 | 36 | ========================================================================= 37 | 38 | This is Forge Mod Loader. 39 | 40 | You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml 41 | 42 | This minecraft mod is a clean open source implementation of a mod loader for minecraft servers 43 | and minecraft clients. 44 | 45 | The code is authored by cpw. 46 | 47 | It began by partially implementing an API defined by the client side ModLoader, authored by Risugami. 48 | http://www.minecraftforum.net/topic/75440- 49 | This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader. 50 | 51 | It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge. 52 | http://www.minecraftforge.net/ 53 | 54 | Additionally, it contains an implementation of topological sort based on that 55 | published at http://keithschwarz.com/interesting/code/?dir=topological-sort 56 | 57 | It also contains code from the Maven project for performing versioned dependency 58 | resolution. http://maven.apache.org/ 59 | 60 | It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/ 61 | with credit to it's authors. 62 | 63 | Forge Mod Loader downloads components from the Minecraft Coder Pack 64 | (http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team. 65 | 66 | -------------------------------------------------------------------------------- /LICENSE-Paulscode IBXM Library.txt: -------------------------------------------------------------------------------- 1 | IBXM is copyright (c) 2007, Martin Cameron, and is licensed under the BSD License. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | Neither the name of mumart nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | 11 | -------------------------------------------------------------------------------- /LICENSE-Paulscode SoundSystem CodecIBXM.txt: -------------------------------------------------------------------------------- 1 | SoundSystem CodecIBXM Class License: 2 | 3 | You are free to use this class for any purpose, commercial or otherwise. 4 | You may modify this class or source code, and distribute it any way you 5 | like, provided the following conditions are met: 6 | 7 | 1) You may not falsely claim to be the author of this class or any 8 | unmodified portion of it. 9 | 2) You may not copyright this class or a modified version of it and then 10 | sue me for copyright infringement. 11 | 3) If you modify the source code, you must clearly document the changes 12 | made before redistributing the modified source code, so other users know 13 | it is not the original code. 14 | 4) You are not required to give me credit for this class in any derived 15 | work, but if you do, you must also mention my website: 16 | http://www.paulscode.com 17 | 5) I the author will not be responsible for any damages (physical, 18 | financial, or otherwise) caused by the use if this class or any 19 | portion of it. 20 | 6) I the author do not guarantee, warrant, or make any representations, 21 | either expressed or implied, regarding the use of this class or any 22 | portion of it. 23 | 24 | Author: Paul Lamb 25 | http://www.paulscode.com 26 | 27 | 28 | This software is based on or using the IBXM library available from 29 | http://www.geocities.com/sunet2000/ 30 | 31 | 32 | IBXM is copyright (c) 2007, Martin Cameron, and is licensed under the BSD License. 33 | All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 36 | 37 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 38 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 39 | Neither the name of mumart nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Family Fun Pack 2 | 3 | ### Summary 4 | 5 | Minecraft 1.12.2 utility mod for anarchy servers, 2b2t - 9b9t. This is not a complete anarchy utility mod, but instead offers a few features that are missing or are improved from what offer others utility mods. 6 | 7 | ### Usage 8 | Use the ```backslash``` key to open the GUI (by default). Change it from Minecraft keybinds options. 9 | 10 | ### Features 11 | [Modules list](/modules.md) 12 | 13 | [Commands list](/commands.md) 14 | 15 | ### Disclaimer 16 | Most of these features are based on Minecraft network stack and do not work on singleplayer. 17 | 18 | ### Running in a Dev Environment: 19 | ```gradle 20 | gradlew setupDecompWorkspace 21 | gradlew runClient 22 | ``` 23 | 24 | ### Compiling the client: 25 | ```gradle 26 | gradlew setupDecompWorkspace 27 | gradlew build 28 | ``` 29 | You will find your built jar in the directory `builds/libs`. 30 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url = "https://files.minecraftforge.net/maven" } 5 | } 6 | dependencies { 7 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' 8 | } 9 | } 10 | apply plugin: 'net.minecraftforge.gradle.forge' 11 | //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. 12 | 13 | 14 | version = "1.1.5" 15 | group = "com.bobeezz.family_fun_pack" // http://maven.apache.org/guides/mini/guide-naming-conventions.html 16 | archivesBaseName = "family_fun_pack" 17 | 18 | sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. 19 | compileJava { 20 | sourceCompatibility = targetCompatibility = '1.8' 21 | } 22 | 23 | minecraft { 24 | version = "1.12.2-14.23.5.2847" 25 | runDir = "run" 26 | 27 | // the mappings can be changed at any time, and must be in the following format. 28 | // snapshot_YYYYMMDD snapshot are built nightly. 29 | // stable_# stables are built at the discretion of the MCP team. 30 | // Use non-default mappings at your own risk. they may not always work. 31 | // simply re-run your setup task after changing the mappings to update your workspace. 32 | mappings = "snapshot_20171003" 33 | // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. 34 | } 35 | 36 | dependencies { 37 | // you may put jars on which you depend on in ./libs 38 | // or you may define them like so.. 39 | //compile "some.group:artifact:version:classifier" 40 | //compile "some.group:artifact:version" 41 | 42 | // real examples 43 | //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env 44 | //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env 45 | 46 | // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. 47 | //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 48 | 49 | // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided, 50 | // except that these dependencies get remapped to your current MCP mappings 51 | //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev' 52 | //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 53 | 54 | // for more info... 55 | // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html 56 | // http://www.gradle.org/docs/current/userguide/dependency_management.html 57 | 58 | } 59 | 60 | processResources { 61 | // this will ensure that this task is redone when the versions change. 62 | inputs.property "version", project.version 63 | inputs.property "mcversion", project.minecraft.version 64 | 65 | // replace stuff in mcmod.info, nothing else 66 | from(sourceSets.main.resources.srcDirs) { 67 | include 'mcmod.info' 68 | 69 | // replace version and mcversion 70 | expand 'version':project.version, 'mcversion':project.minecraft.version 71 | } 72 | 73 | // copy everything else except the mcmod.info 74 | from(sourceSets.main.resources.srcDirs) { 75 | exclude 'mcmod.info' 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anOtherAnalyse/FamilyFunPack/a5f1fcfe481ac5637fa9a740a0d79aca1da33993/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Dec 11 00:48:05 CET 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /modules.md: -------------------------------------------------------------------------------- 1 | ### Modules list 2 | 3 | ##### True Durability 4 | Display items real durability in on-hover tooltip. Can be used to know "unbreakable" items true durability. 5 | 6 | Unbreakable items are displayed in red enchant, easier to spot on other players or in chests. 7 | 8 | ##### Advanced Search 9 | Block search module with advanced options. Blocks highlight + tracers. 10 | 11 | Advanced options allow to filter by block states and specify color & tracer options for each search filter. 12 | 13 | Example: use it to search for player heads, excluding mobs heads, or spawners for specific mob. 14 | 15 | ##### Book formatting 16 | Adds a new panel to the book editing gui, to be able to add colours and special formats to book content & title. 17 | 18 | ##### Silent Close 19 | Do not notify server when closing a container - can be reopened later when trying to open player inventory (or by using ```.reopen```). 20 | 21 | ##### Packets Canceling 22 | All in title, prevent client from sending/receiving specified network packets. 23 | 24 | ##### Portal Invulnerability 25 | Be invulnerable after going through a portal, but you won't be able to move by yourself. 26 | 27 | ##### Pig POV 28 | Pig point of view - When using portal invulnerability you can use a pig to travel 1x1 tunnels without taking damage. Use this to lower your point of view and see where you are going. 29 | 30 | ##### Trace entities teleporting 31 | Print new coordinates of entities teleporting out of render distance in chat. 32 | 33 | Example: trace dogs tp. 34 | 35 | ##### Stalker 36 | Stalk a player: Notify in chat when a certain player connects / disconnects / changes gamemode / speaks in chat. 37 | 38 | Manage it with the ```.stalk``` command. 39 | 40 | ##### Undead 41 | Don't display gameover GUI when dead, so you can move around. On vanilla servers you can still interact with the environment while being dead. 42 | 43 | Use ```.respawn``` to respawn. 44 | 45 | ##### Bowbomb 46 | 47 | One-shot & ultra-fast arrows. Can only be shot horizontally though. 48 | 49 | ##### PumpkinAura 50 | 51 | Super strong pumpkin aura for pumpkin pvp on auscpvp.org & 2b2t.org.au 52 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/FamilyFunPack.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.text.ChatType; 5 | import net.minecraft.util.text.TextComponentString; 6 | import net.minecraft.util.text.TextFormatting; 7 | import net.minecraftforge.common.MinecraftForge; 8 | import net.minecraftforge.fml.common.Mod; 9 | import net.minecraftforge.fml.common.Mod.EventHandler; 10 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 11 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 12 | import net.minecraftforge.fml.relauncher.SideOnly; 13 | import net.minecraftforge.fml.relauncher.Side; 14 | 15 | import java.io.File; 16 | 17 | import family_fun_pack.gui.MainGui; 18 | import family_fun_pack.gui.overlay.OverlayGui; 19 | import family_fun_pack.key.KeyListener; 20 | import family_fun_pack.modules.Module; 21 | import family_fun_pack.modules.Modules; 22 | import family_fun_pack.network.NetworkHandler; 23 | 24 | @Mod(modid = FamilyFunPack.MODID, name = FamilyFunPack.NAME, version = FamilyFunPack.VERSION) 25 | @SideOnly(Side.CLIENT) 26 | public class FamilyFunPack 27 | { 28 | public static final String MODID = "family_fun_pack"; 29 | public static final String NAME = "Family Fun Pack"; 30 | public static final String VERSION = "1.1.5"; 31 | 32 | private static NetworkHandler networkHandler; 33 | private static Modules modules; 34 | private static OverlayGui overlay; 35 | private static KeyListener keyListener; 36 | private static MainGui mainGui; 37 | 38 | private File confFile; 39 | 40 | /* Get NetworkHandler, for registering packets listeners */ 41 | public static NetworkHandler getNetworkHandler() { 42 | return FamilyFunPack.networkHandler; 43 | } 44 | 45 | /* Get all Modules */ 46 | public static Modules getModules() { 47 | return FamilyFunPack.modules; 48 | } 49 | 50 | /* Overlay GUI */ 51 | public static OverlayGui getOverlay() { 52 | return FamilyFunPack.overlay; 53 | } 54 | 55 | /* Main GUI */ 56 | public static MainGui getMainGui() { 57 | return FamilyFunPack.mainGui; 58 | } 59 | 60 | // TODO: DELETE 61 | public static void addModuleKey(int key, Module module) { 62 | FamilyFunPack.keyListener.addModuleKey(key, module); 63 | } 64 | 65 | /* Print message in chat */ 66 | public static void printMessage(String msg, Object... args) { 67 | Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.SYSTEM, new TextComponentString(TextFormatting.BLUE + "[FFP] " + TextFormatting.RESET + String.format(msg, args))); 68 | } 69 | 70 | @EventHandler 71 | public void preInit(FMLPreInitializationEvent event) { 72 | this.confFile = event.getSuggestedConfigurationFile(); 73 | } 74 | 75 | @EventHandler 76 | public void init(FMLInitializationEvent event) 77 | { 78 | if(event.getSide() == Side.CLIENT) { 79 | 80 | // Init overlay 81 | FamilyFunPack.overlay = new OverlayGui(); 82 | 83 | // Init network handler 84 | FamilyFunPack.networkHandler = new NetworkHandler(); 85 | 86 | // Init key listener 87 | FamilyFunPack.keyListener = new KeyListener(); 88 | 89 | // load modules configuration 90 | FamilyFunPack.modules = new Modules(this.confFile); 91 | 92 | // register overlay 93 | MinecraftForge.EVENT_BUS.register(FamilyFunPack.overlay); 94 | 95 | // register network 96 | MinecraftForge.EVENT_BUS.register(FamilyFunPack.networkHandler); 97 | 98 | // Init Main GUI 99 | FamilyFunPack.mainGui = new MainGui(FamilyFunPack.modules); 100 | FamilyFunPack.keyListener.setGui(FamilyFunPack.mainGui); 101 | 102 | // Register key listener 103 | MinecraftForge.EVENT_BUS.register(FamilyFunPack.keyListener); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/Command.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import family_fun_pack.FamilyFunPack; 7 | 8 | /* A Command */ 9 | 10 | @SideOnly(Side.CLIENT) 11 | public abstract class Command { 12 | 13 | private final String name; 14 | 15 | public Command(String name) { 16 | this.name = name; 17 | } 18 | 19 | public String getName() { 20 | return this.name; 21 | } 22 | 23 | /* When disconnecting from server */ 24 | public void onDisconnect() {} 25 | 26 | public abstract String usage(); 27 | 28 | public String getUsage() { 29 | return "Usage: " + this.usage(); 30 | } 31 | 32 | // should some commands leak your coords 33 | protected boolean showDebugInfo() { 34 | return FamilyFunPack.getModules().getConfiguration().get("commands", "showDebugInfo", true).getBoolean(); 35 | } 36 | 37 | // Execute a command 38 | // First argument is always command name 39 | public abstract String execute(String[] args); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/Commands.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /* Commands record */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class Commands { 14 | private final Map commands; 15 | 16 | /* I'm too lazy to develop interfaces so let's add a lot of commands */ 17 | 18 | public Commands() { 19 | this.commands = new HashMap(); 20 | this.registerCommand(new DiffCommand()); 21 | this.registerCommand(new GetCommand()); 22 | this.registerCommand(new UseCommand()); 23 | this.registerCommand(new VanishCommand()); 24 | this.registerCommand(new VClipCommand()); 25 | this.registerCommand(new HClipCommand()); 26 | this.registerCommand(new HelpCommand()); 27 | this.registerCommand(new RaytraceCommand()); 28 | this.registerCommand(new UnloadedRideCommand()); 29 | this.registerCommand(new StalkCommand()); 30 | this.registerCommand(new OpenDonkeyCommand()); 31 | this.registerCommand(new DisconnectCommand()); 32 | this.registerCommand(new SyncMountCommand()); 33 | this.registerCommand(new PacketDumpCommand()); 34 | this.registerCommand(new InfoCommand()); 35 | this.registerCommand(new SpectateCommand()); 36 | this.registerCommand(new RespawnCommand()); 37 | this.registerCommand(new VoidMountCommand()); 38 | this.registerCommand(new PeekCommand()); 39 | this.registerCommand(new QueueUtilsCommand()); 40 | this.registerCommand(new ItemSizeCommand()); 41 | this.registerCommand(new FillBookCommand()); 42 | this.registerCommand(new EditSignCommand()); 43 | this.registerCommand(new RollbackCommand()); 44 | this.registerCommand(new StealCommand()); 45 | this.registerCommand(new KillDupeCommand()); 46 | this.registerCommand(new RemoteRideCommand()); 47 | this.registerCommand(new BlockAtCommand()); 48 | this.registerCommand(new RemoteCaptureCommand()); 49 | this.registerCommand(new LoadChunkCommand()); 50 | this.registerCommand(new PopulateCommand()); 51 | this.registerCommand(new WorldDownloadCommand()); 52 | this.registerCommand(new TrackCommand()); 53 | this.registerCommand(new IgnoreCommand()); 54 | this.registerCommand(new ReOpenCommand()); 55 | this.registerCommand(new NearestStrongholdCommand()); 56 | this.registerCommand(new RollbackDupeCommand()); 57 | } 58 | 59 | public void registerCommand(Command cmd) { 60 | this.commands.put(cmd.getName(), cmd); 61 | } 62 | 63 | public Command getCommand(String name) { 64 | return this.commands.get(name); 65 | } 66 | 67 | public Collection getCommands() { 68 | return this.commands.values(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/DiffCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.network.NetHandlerPlayClient; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketTabComplete; 8 | import net.minecraft.network.play.server.SPacketTabComplete; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import io.netty.buffer.ByteBuf; 13 | 14 | import family_fun_pack.FamilyFunPack; 15 | import family_fun_pack.network.PacketListener; 16 | 17 | /* Get vanished players (not shown in player list, available in chat auto-completion) */ 18 | 19 | @SideOnly(Side.CLIENT) 20 | public class DiffCommand extends Command implements PacketListener { 21 | 22 | public DiffCommand() { 23 | super("diff"); 24 | } 25 | 26 | public String usage() { 27 | return this.getName(); 28 | } 29 | 30 | public String execute(String[] args) { 31 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 14); 32 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketTabComplete("", null, false)); 33 | return null; 34 | } 35 | 36 | public void onDisconnect() { 37 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 14); 38 | } 39 | 40 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 41 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 14); 42 | 43 | SPacketTabComplete completion = (SPacketTabComplete) packet; 44 | NetHandlerPlayClient handler = (NetHandlerPlayClient)(FamilyFunPack.getNetworkHandler().getNetHandler()); 45 | if(handler != null) { 46 | Minecraft client = Minecraft.getMinecraft(); 47 | boolean add = true; 48 | for(String name : completion.getMatches()) { 49 | if(handler.getPlayerInfo(name) == null) { 50 | FamilyFunPack.printMessage("Addtional player: " + name); 51 | add = false; 52 | } 53 | } 54 | if(add) { 55 | FamilyFunPack.printMessage("No additional players over " + completion.getMatches().length + " players"); 56 | } else { 57 | int total_tab = handler.getPlayerInfoMap().size(); 58 | FamilyFunPack.printMessage("Board contains [" + total_tab + "/" + completion.getMatches().length + "] players"); 59 | } 60 | } 61 | return null; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/DisconnectCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import family_fun_pack.FamilyFunPack; 7 | 8 | /* Disconnect from server, close the socket */ 9 | 10 | @SideOnly(Side.CLIENT) 11 | public class DisconnectCommand extends Command { 12 | 13 | public DisconnectCommand() { 14 | super("disconnect"); 15 | } 16 | 17 | public String usage() { 18 | return this.getName(); 19 | } 20 | 21 | public String execute(String[] args) { 22 | FamilyFunPack.getNetworkHandler().disconnect(); 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/EditSignCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.network.play.client.CPacketUpdateSign; 5 | import net.minecraft.tileentity.TileEntity; 6 | import net.minecraft.tileentity.TileEntitySign; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.util.math.RayTraceResult; 9 | import net.minecraft.util.text.ITextComponent; 10 | import net.minecraft.util.text.TextComponentString; 11 | import net.minecraftforge.fml.relauncher.SideOnly; 12 | import net.minecraftforge.fml.relauncher.Side; 13 | 14 | import java.lang.StringBuilder; 15 | 16 | import family_fun_pack.FamilyFunPack; 17 | 18 | /* Edit a sign, read a sign, hide data in a sign... */ 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class EditSignCommand extends Command { 22 | 23 | public EditSignCommand() { 24 | super("sign"); 25 | } 26 | 27 | public String usage() { 28 | return this.getName() + " "; 29 | } 30 | 31 | public String execute(String[] args) { 32 | Minecraft mc = Minecraft.getMinecraft(); 33 | RayTraceResult target_ray = mc.objectMouseOver; 34 | if(target_ray != null) { 35 | if(target_ray.typeOfHit == RayTraceResult.Type.BLOCK) { 36 | BlockPos pos = target_ray.getBlockPos(); 37 | 38 | if(args.length > 1) { // Edit sign 39 | TextComponentString[] str = new TextComponentString[4]; 40 | StringBuilder build = new StringBuilder(); 41 | int i = 0; 42 | for(int j = 1; j < args.length; j ++) { 43 | if(args[j].equals("+")) { 44 | str[i] = new TextComponentString(build.toString()); 45 | if(++i >= 4) break; 46 | build = new StringBuilder(); 47 | } else { 48 | if(build.length() > 0) build.append(' '); 49 | build.append(args[j]); 50 | } 51 | } 52 | 53 | for(; i < 4; i ++) { 54 | str[i] = new TextComponentString(build.toString()); 55 | build = new StringBuilder(); 56 | } 57 | 58 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketUpdateSign(pos, str)); 59 | } else { // Read sign 60 | TileEntity tile = mc.world.getTileEntity(pos); 61 | if(tile instanceof TileEntitySign) { 62 | TileEntitySign sign = (TileEntitySign) tile; 63 | for(int i = 0; i < 4; i ++) { 64 | FamilyFunPack.printMessage(String.format("#%d §8%s§r", i, sign.signText[i].getUnformattedText())); 65 | } 66 | } else return "No sign data"; 67 | } 68 | return null; 69 | } 70 | } 71 | return "Look at a sign"; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/FillBookCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.init.Items; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.Packet; 8 | import net.minecraft.network.PacketBuffer; 9 | import net.minecraft.network.play.client.CPacketCustomPayload; 10 | import net.minecraft.network.play.server.SPacketSetSlot; 11 | import net.minecraft.nbt.NBTTagCompound; 12 | import net.minecraft.nbt.NBTTagList; 13 | import net.minecraft.nbt.NBTTagString; 14 | import net.minecraftforge.fml.relauncher.SideOnly; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | 17 | import io.netty.buffer.ByteBuf; 18 | import io.netty.buffer.Unpooled; 19 | import java.io.IOException; 20 | import java.lang.StringBuilder; 21 | 22 | import family_fun_pack.FamilyFunPack; 23 | import family_fun_pack.network.PacketListener; 24 | 25 | /* Fill a book to its max size (32767 bytes) */ 26 | 27 | @SideOnly(Side.CLIENT) 28 | public class FillBookCommand extends Command implements PacketListener { 29 | 30 | public FillBookCommand() { 31 | super("fill"); 32 | } 33 | 34 | public String usage() { 35 | return this.getName() + " [sign]"; 36 | } 37 | 38 | public String execute(String[] args) { 39 | Minecraft mc = Minecraft.getMinecraft(); 40 | 41 | boolean sign = (args.length > 1 && args[1].equals("sign")); 42 | 43 | if(mc.player.getHeldItemMainhand().getItem() == Items.WRITABLE_BOOK) { 44 | ItemStack stack = mc.player.getHeldItemMainhand().copy(); 45 | NBTTagCompound tag = new NBTTagCompound(); 46 | 47 | // Pages 48 | NBTTagList pages = new NBTTagList(); 49 | for(int i = 0; i < 50; i ++) { 50 | StringBuilder build = new StringBuilder(String.format("§cFILLED_BOOK_LINE_%d_§r", (i+1))); 51 | for(int j = 0; j < 34; j ++) build.append("§§§§§§§§§"); 52 | pages.appendTag(new NBTTagString(build.toString())); 53 | } 54 | tag.setTag("pages", pages); 55 | 56 | if(sign) { 57 | // Title 58 | tag.setString("title", "32kb book"); 59 | tag.setString("author", "unused"); 60 | } 61 | 62 | stack.setTagCompound(tag); 63 | 64 | PacketBuffer data = new PacketBuffer(Unpooled.buffer()); 65 | data.writeItemStack(stack); 66 | 67 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 22); 68 | 69 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketCustomPayload(sign ? "MC|BSign" : "MC|BEdit", data)); 70 | return data.writerIndex() + " bytes written to book"; 71 | } 72 | return "Please hold a writable book"; 73 | } 74 | 75 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 76 | SPacketSetSlot setSlot = (SPacketSetSlot) packet; 77 | if(setSlot.getStack().getItem() == Items.WRITABLE_BOOK || setSlot.getStack().getItem() == Items.WRITTEN_BOOK) { 78 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 22); 79 | PacketBuffer buff = new PacketBuffer(in); 80 | buff.readerIndex(buff.readerIndex() + 4); 81 | int size = buff.readerIndex(); 82 | try { 83 | buff.readItemStack(); 84 | } catch (IOException e) { 85 | return packet; 86 | } 87 | size = buff.readerIndex() - size; 88 | FamilyFunPack.printMessage("Server recorded " + size + " bytes"); 89 | } 90 | return packet; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/GetCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.network.EnumPacketDirection; 5 | import net.minecraft.network.Packet; 6 | import net.minecraft.network.play.client.CPacketTabComplete; 7 | import net.minecraft.network.play.server.SPacketTabComplete; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.util.math.RayTraceResult; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | 13 | import io.netty.buffer.ByteBuf; 14 | 15 | import family_fun_pack.FamilyFunPack; 16 | import family_fun_pack.network.PacketListener; 17 | 18 | /* Try to fetch all available commands on server */ 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class GetCommand extends Command implements PacketListener { 22 | 23 | public GetCommand() { 24 | super("commands"); 25 | } 26 | 27 | public String usage() { 28 | return this.getName(); 29 | } 30 | 31 | public String execute(String[] args) { 32 | RayTraceResult target_ray = Minecraft.getMinecraft().objectMouseOver; 33 | BlockPos target = null; 34 | if(target_ray != null && target_ray.typeOfHit == RayTraceResult.Type.BLOCK) { 35 | target = target_ray.getBlockPos(); 36 | } 37 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 14); 38 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketTabComplete("/", target, (target != null))); 39 | return null; 40 | } 41 | 42 | public void onDisconnect() { 43 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 14); 44 | } 45 | 46 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 47 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 14); 48 | SPacketTabComplete completion = (SPacketTabComplete) packet; 49 | FamilyFunPack.printMessage("Available commands:"); 50 | for(String cmd : completion.getMatches()) { 51 | FamilyFunPack.printMessage(cmd); 52 | } 53 | return null; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/HClipCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketPlayer; 8 | import net.minecraft.network.play.client.CPacketVehicleMove; 9 | import net.minecraft.util.math.Vec3d; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | 13 | import family_fun_pack.FamilyFunPack; 14 | import family_fun_pack.modules.PacketInterceptionModule; 15 | 16 | /* Horizontal client-side teleport */ 17 | 18 | @SideOnly(Side.CLIENT) 19 | public class HClipCommand extends Command { 20 | 21 | public HClipCommand() { 22 | super("hclip"); 23 | } 24 | 25 | public String usage() { 26 | return this.getName() + " [vertical]"; 27 | } 28 | 29 | public String execute(String[] args) { 30 | if(args.length > 1) { 31 | Minecraft mc = Minecraft.getMinecraft(); 32 | try { 33 | double weight = Double.parseDouble(args[1]); 34 | double vert = 0d; 35 | if(args.length > 2) vert = Double.parseDouble(args[2]); 36 | 37 | // Client side 38 | Vec3d direction = new Vec3d(Math.cos((mc.player.rotationYaw + 90f) * (float) (Math.PI / 180.0f)), 0, Math.sin((mc.player.rotationYaw + 90f) * (float) (Math.PI / 180.0f))); 39 | Entity target = mc.player.isRiding() ? mc.player.getRidingEntity() : mc.player; 40 | target.setPosition(target.posX + direction.x*weight, target.posY + vert, target.posZ + direction.z*weight); 41 | 42 | // Send move packet 43 | Packet packet = null; 44 | if(mc.player.isRiding()) packet = new CPacketVehicleMove(target); 45 | else packet = new CPacketPlayer.Position(target.posX, target.posY, target.posZ, true); 46 | 47 | PacketInterceptionModule intercept = (PacketInterceptionModule) FamilyFunPack.getModules().getByClass(PacketInterceptionModule.class); 48 | intercept.addException(EnumPacketDirection.SERVERBOUND, packet); 49 | 50 | FamilyFunPack.getNetworkHandler().sendPacket(packet); 51 | 52 | return String.format("Teleported you %s blocks forward", weight); 53 | } catch(NumberFormatException e) { 54 | return "This is not a real number"; 55 | } 56 | } 57 | return "Specify a number"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/HelpCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import family_fun_pack.FamilyFunPack; 4 | import family_fun_pack.modules.CommandsModule; 5 | import family_fun_pack.network.PacketListener; 6 | import io.netty.buffer.ByteBuf; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.client.entity.EntityPlayerSP; 9 | import net.minecraft.client.network.NetHandlerPlayClient; 10 | import net.minecraft.network.EnumPacketDirection; 11 | import net.minecraft.network.Packet; 12 | import net.minecraft.network.PacketBuffer; 13 | import net.minecraft.network.play.server.SPacketCustomPayload; 14 | import net.minecraft.world.storage.WorldInfo; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | import net.minecraftforge.fml.relauncher.SideOnly; 17 | 18 | import java.nio.charset.StandardCharsets; 19 | import java.util.ArrayList; 20 | import java.util.Collection; 21 | import java.util.Comparator; 22 | import java.util.List; 23 | 24 | /* Dump all commands usage */ 25 | 26 | @SideOnly(Side.CLIENT) 27 | public class HelpCommand extends Command { 28 | 29 | public HelpCommand() { 30 | super("help"); 31 | } 32 | 33 | public String usage() { 34 | return this.getName(); 35 | } 36 | 37 | public String execute(String[] args) { 38 | final StringBuilder sb = new StringBuilder(); 39 | final List list = new ArrayList<>(CommandsModule.getCommands().getCommands()); 40 | 41 | list.sort(Comparator.comparing(Command::getName)); 42 | 43 | for (Command command : list) { 44 | sb.append("\n").append(CommandsModule.ESCAPE_CHARACTER).append(command.usage()); 45 | } 46 | 47 | return sb.toString().replaceFirst("\n", ""); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/IgnoreCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import family_fun_pack.FamilyFunPack; 7 | import family_fun_pack.modules.Module; 8 | import family_fun_pack.modules.IgnoreModule; 9 | 10 | /* Manage ignored players list */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class IgnoreCommand extends Command { 14 | 15 | public IgnoreCommand() { 16 | super("ignore"); 17 | } 18 | 19 | public String usage() { 20 | return this.getName() + " "; 21 | } 22 | 23 | public String execute(String[] args) { 24 | if(args.length > 1) { 25 | IgnoreModule module = (IgnoreModule) FamilyFunPack.getModules().getByClass(IgnoreModule.class); 26 | module.togglePlayer(args[1]); 27 | return null; 28 | } 29 | return this.getUsage(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/InfoCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.entity.EntityPlayerSP; 5 | import net.minecraft.client.network.NetHandlerPlayClient; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.Packet; 8 | import net.minecraft.network.PacketBuffer; 9 | import net.minecraft.network.play.server.SPacketCustomPayload; 10 | import net.minecraft.world.storage.WorldInfo; 11 | import net.minecraftforge.fml.relauncher.SideOnly; 12 | import net.minecraftforge.fml.relauncher.Side; 13 | 14 | import io.netty.buffer.ByteBuf; 15 | import java.nio.charset.StandardCharsets; 16 | 17 | import family_fun_pack.FamilyFunPack; 18 | import family_fun_pack.network.PacketListener; 19 | 20 | /* Get information about player, world, plugins, ... */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class InfoCommand extends Command implements PacketListener { 24 | 25 | private String[] plugins; 26 | private boolean rcv_plugins; 27 | 28 | public InfoCommand() { 29 | super("info"); 30 | this.plugins = null; 31 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 24); 32 | } 33 | 34 | public String usage() { 35 | return this.getName() + " [plugins]"; 36 | } 37 | 38 | public String execute(String[] args) { 39 | if(args.length > 1) { // Plugins listening for custom messages 40 | 41 | if(args[1].startsWith("plugin")) { 42 | 43 | if(! this.rcv_plugins) return "No info received about listening plugins"; 44 | 45 | if(this.plugins == null || this.plugins.length == 0) return "No listening plugins"; 46 | 47 | return "Listening plugins: [" + String.join(", ", this.plugins) + "]"; 48 | 49 | } else return this.getUsage(); 50 | 51 | } else { // Get basic info 52 | Minecraft mc = Minecraft.getMinecraft(); 53 | EntityPlayerSP player = mc.player; 54 | WorldInfo info = mc.world.getWorldInfo(); 55 | 56 | String game_type = mc.playerController.getCurrentGameType().toString(); 57 | boolean hardcore = info.isHardcoreModeEnabled(); 58 | boolean reduce_debug = player.hasReducedDebug(); 59 | String world_type = info.getTerrainType().getName(); 60 | String difficulty = info.getDifficulty().toString(); 61 | String entity_id = Integer.toString(player.getEntityId()); 62 | String max_players = Integer.toString(((NetHandlerPlayClient) FamilyFunPack.getNetworkHandler().getNetHandler()).currentServerMaxPlayers); 63 | 64 | String dimension = null; 65 | switch(player.dimension) { 66 | case 0: dimension = "overworld"; break; 67 | case -1: dimension = "nether"; break; 68 | case 1: dimension = "end"; break; 69 | default: dimension = "unknown"; 70 | } 71 | 72 | String stat = player.getGameProfile().getName() + "id[" + entity_id + "] (" + game_type + ") in " + dimension + "[" + world_type + "], " + difficulty; 73 | if(hardcore) stat += " [hardcore]"; 74 | if(reduce_debug) stat += " [reduce debug info]"; 75 | stat += " max players: " + max_players; 76 | 77 | if(mc.player.isRiding()) { 78 | stat += ", riding: " + mc.player.getRidingEntity().getEntityId(); 79 | } 80 | 81 | return stat; 82 | } 83 | } 84 | 85 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 86 | SPacketCustomPayload custom = (SPacketCustomPayload) packet; 87 | if(custom.getChannelName().equals("REGISTER")) { 88 | 89 | // FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 24); 90 | 91 | PacketBuffer buff = custom.getBufferData(); 92 | byte[] data = new byte[buff.readableBytes()]; 93 | buff.readBytes(data); 94 | 95 | this.rcv_plugins = true; 96 | this.plugins = (new String(data, StandardCharsets.UTF_8)).split("\0"); 97 | } 98 | return packet; 99 | } 100 | 101 | public void onDisconnect() { 102 | this.plugins = null; 103 | this.rcv_plugins = false; 104 | // FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 24); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/ItemSizeCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.item.ItemStack; 5 | import net.minecraft.network.PacketBuffer; 6 | import net.minecraftforge.fml.relauncher.SideOnly; 7 | import net.minecraftforge.fml.relauncher.Side; 8 | 9 | import io.netty.buffer.Unpooled; 10 | 11 | /* Get currently hold ItemStack size in bytes (network size) */ 12 | 13 | @SideOnly(Side.CLIENT) 14 | public class ItemSizeCommand extends Command { 15 | 16 | public static int getItemSize(ItemStack stack) { 17 | PacketBuffer buff = new PacketBuffer(Unpooled.buffer()); 18 | buff.writeItemStack(stack); 19 | int size = buff.writerIndex(); 20 | buff.release(); 21 | return size; 22 | } 23 | 24 | public ItemSizeCommand() { 25 | super("size"); 26 | } 27 | 28 | public String usage() { 29 | return this.getName(); 30 | } 31 | 32 | public String execute(String[] args) { 33 | ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand(); 34 | if(stack.isEmpty()) return "You are not holding any item"; 35 | return "Item weights " + ItemSizeCommand.getItemSize(stack) + " bytes"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/KillDupeCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.inventory.ClickType; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.Packet; 8 | import net.minecraft.network.play.client.CPacketEntityAction; 9 | import net.minecraft.network.play.client.CPacketUseEntity; 10 | import net.minecraft.network.play.client.CPacketClickWindow; 11 | import net.minecraft.network.play.server.SPacketConfirmTransaction; 12 | import net.minecraft.util.EnumHand; 13 | import net.minecraft.util.text.TextFormatting; 14 | import net.minecraftforge.fml.relauncher.SideOnly; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | 17 | import io.netty.buffer.ByteBuf; 18 | 19 | import family_fun_pack.FamilyFunPack; 20 | import family_fun_pack.commands.StealCommand; 21 | import family_fun_pack.modules.CommandsModule; 22 | import family_fun_pack.modules.NoCloseModule; 23 | import family_fun_pack.network.PacketListener; 24 | 25 | /* Vanilla entity kill dupe 26 | * Works with horses, does not with minecart w/ chest 27 | */ 28 | 29 | @SideOnly(Side.CLIENT) 30 | public class KillDupeCommand extends Command implements PacketListener { 31 | 32 | private int window_id, slot; 33 | private boolean op; 34 | 35 | public KillDupeCommand() { 36 | super("kdupe"); 37 | } 38 | 39 | public String usage() { 40 | return this.getName() + " [op]"; 41 | } 42 | 43 | public String execute(String[] args) { 44 | if(args.length > 1) { 45 | try { 46 | this.slot = Integer.parseInt(args[1]); 47 | } catch(NumberFormatException e) { 48 | return this.getUsage(); 49 | } 50 | 51 | this.op = false; 52 | if(args.length > 2) { 53 | if(args[2].equals("op")) { 54 | this.op = true; 55 | } else return this.getUsage(); 56 | } 57 | 58 | if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(0).isEmpty()) return "Keep your first hotbar slot clear"; 59 | 60 | if(this.op) { 61 | this.window_id = ((StealCommand)((CommandsModule) FamilyFunPack.getModules().getByClass(CommandsModule.class)).getCommand("steal")).getNextId(); 62 | } else { 63 | this.window_id = ((NoCloseModule) FamilyFunPack.getModules().getByClass(NoCloseModule.class)).getWindowId(); 64 | } 65 | 66 | if(this.window_id != -1) { 67 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, 10); 68 | } else return (this.op ? "Please open & close one container first" : "First keep entity inventory open"); 69 | } else return this.getUsage(); 70 | return "kdupe ready"; 71 | } 72 | 73 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 74 | if(id == 10) { // CPacketUseEntity 75 | CPacketUseEntity use = (CPacketUseEntity) packet; 76 | if(use.getAction() == CPacketUseEntity.Action.ATTACK) { 77 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 10); 78 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 17); 79 | 80 | Minecraft mc = Minecraft.getMinecraft(); 81 | CPacketClickWindow get = new CPacketClickWindow(this.window_id, this.slot, 0, ClickType.SWAP, ItemStack.EMPTY, (short) -42); 82 | 83 | if(this.op) { 84 | CPacketEntityAction sneak = new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING); 85 | CPacketUseEntity open = new CPacketUseEntity(use.getEntityFromWorld(mc.world), EnumHand.MAIN_HAND); 86 | FamilyFunPack.getNetworkHandler().sendPacket(sneak); 87 | FamilyFunPack.getNetworkHandler().sendPacket(use); 88 | FamilyFunPack.getNetworkHandler().sendPacket(open); 89 | FamilyFunPack.getNetworkHandler().sendPacket(get); 90 | } else { 91 | FamilyFunPack.getNetworkHandler().sendPacket(use); 92 | FamilyFunPack.getNetworkHandler().sendPacket(get); 93 | } 94 | 95 | return null; 96 | } 97 | } else { // SPacketConfirmTransaction 98 | SPacketConfirmTransaction confirm = (SPacketConfirmTransaction) packet; 99 | if(confirm.getWindowId() == this.window_id && confirm.getActionNumber() == -42) { 100 | if(confirm.wasAccepted()) { 101 | FamilyFunPack.printMessage("Swap " + slot + TextFormatting.GREEN + " succeeded"); 102 | } else { 103 | FamilyFunPack.printMessage("Swap " + slot + TextFormatting.RED + " failed"); 104 | } 105 | } 106 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 17); 107 | } 108 | return packet; 109 | } 110 | 111 | public void onDisconnect() { 112 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 10); 113 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 17); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/NearestStrongholdCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import family_fun_pack.FamilyFunPack; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.multiplayer.ServerData; 6 | import net.minecraft.util.math.BlockPos; 7 | import net.minecraft.world.GameType; 8 | import net.minecraft.world.WorldProvider; 9 | import net.minecraft.world.WorldProviderSurface; 10 | import net.minecraft.world.WorldSettings; 11 | import net.minecraft.world.WorldType; 12 | import net.minecraft.world.gen.structure.MapGenStronghold; 13 | import net.minecraft.world.storage.WorldInfo; 14 | import net.minecraftforge.fml.relauncher.SideOnly; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | 17 | import family_fun_pack.utils.FakeWorld; 18 | 19 | /* 9b9t - get nearest stronghold (based on 9b seed) */ 20 | /* 2b2t - get nearest stronghold (based on 2b know portal locations) */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class NearestStrongholdCommand extends Command { 24 | 25 | public NearestStrongholdCommand() { 26 | super("nearest"); 27 | } 28 | 29 | public String usage() { 30 | return this.getName(); 31 | } 32 | 33 | public String execute(String[] args) { 34 | Minecraft mc = Minecraft.getMinecraft(); 35 | ServerData data = mc.getCurrentServerData(); 36 | 37 | if (data == null) return "server is null"; 38 | if (mc.player.dimension == 1) return "Why ?"; 39 | 40 | //check if server is 2b2t.org using Minecraft.getCurrentServerData() 41 | if (data.serverIP.equalsIgnoreCase("connect.2b2t.org")) { 42 | //get stronghold location nearest to player on 2b2t.org 43 | int[][] endPortalCoords = {{1888, -32}, {-560, 1504}, {2064, -4400}, {-4992, -512}, {2960, 4208}, {-3200, 4480}, {-5568, 608}, {-2496, 5296}}; 44 | 45 | int closestX = endPortalCoords[0][0]; 46 | int closestZ = endPortalCoords[0][1]; 47 | int shortestDistance = (int) mc.player.getDistanceSq(endPortalCoords[0][0], 0, endPortalCoords[0][1]); 48 | for (int i = 1; i < endPortalCoords.length; i++) { 49 | int d = (int) mc.player.getDistanceSq(endPortalCoords[i][0], 0, endPortalCoords[i][1]); 50 | if (d < shortestDistance) { 51 | closestX = endPortalCoords[i][0]; 52 | closestZ = endPortalCoords[i][1]; 53 | shortestDistance = d; 54 | } 55 | } 56 | 57 | return String.format("Nearest stronghold around (%d, %d) overworld", closestX, closestZ); 58 | } else if (is9b9t(data.serverIP)) { 59 | WorldProvider provider = new WorldProviderSurface(); 60 | 61 | WorldInfo info = new WorldInfo(new WorldSettings(-8076723744225505211L, GameType.SURVIVAL, true, false, WorldType.DEFAULT), "tmp"); 62 | 63 | FakeWorld fake = new FakeWorld(null, info, provider); 64 | provider.setWorld(fake); 65 | 66 | MapGenStronghold generation = new MapGenStronghold(); 67 | generation.generate(fake, 0, 0, null); 68 | 69 | BlockPos nearest = null; 70 | if (mc.player.dimension == 0) nearest = generation.getNearestStructurePos(fake, mc.player.getPosition(), false); 71 | else nearest = generation.getNearestStructurePos(fake, new BlockPos((int) mc.player.posX * 8, 70, (int) mc.player.posZ * 8), false); 72 | 73 | return String.format("Nearest stronghold around (%d, %d) overworld", nearest.getX(), nearest.getZ()); 74 | } 75 | 76 | return String.format("this command does not support '%s' supported server(s): 2b2t, 9b9t", data.serverIP); 77 | } 78 | 79 | private boolean is9b9t(String serverIP) { 80 | return serverIP.equalsIgnoreCase("9b9t.org") 81 | || serverIP.equalsIgnoreCase("9b9t.com") 82 | || serverIP.equalsIgnoreCase("2b2t.com"); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/OpenDonkeyCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.passive.AbstractHorse; 6 | import net.minecraft.entity.passive.EntityDonkey; 7 | import net.minecraft.inventory.ContainerHorseChest; 8 | import net.minecraft.network.EnumPacketDirection; 9 | import net.minecraft.network.Packet; 10 | import net.minecraft.network.play.client.CPacketEntityAction; 11 | import net.minecraft.network.play.server.SPacketOpenWindow; 12 | import net.minecraft.util.text.TextFormatting; 13 | import net.minecraftforge.fml.relauncher.SideOnly; 14 | import net.minecraftforge.fml.relauncher.Side; 15 | 16 | import io.netty.buffer.ByteBuf; 17 | 18 | import family_fun_pack.FamilyFunPack; 19 | import family_fun_pack.entities.EntityVoid; 20 | import family_fun_pack.entities.GhostDonkey; 21 | import family_fun_pack.network.PacketListener; 22 | 23 | import family_fun_pack.modules.CommandsModule; 24 | 25 | /* Open donkey inventory, usefull when there is a desync and the client is not aware of the mount */ 26 | 27 | @SideOnly(Side.CLIENT) 28 | public class OpenDonkeyCommand extends Command implements PacketListener { 29 | 30 | public OpenDonkeyCommand() { 31 | super("open"); 32 | } 33 | 34 | public String usage() { 35 | return this.getName(); 36 | } 37 | 38 | public String execute(String[] args) { 39 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 19); 40 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(new EntityVoid(Minecraft.getMinecraft().world, 0), CPacketEntityAction.Action.OPEN_INVENTORY)); 41 | return null; 42 | } 43 | 44 | public void onDisconnect() { 45 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 19); 46 | } 47 | 48 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 49 | SPacketOpenWindow open = (SPacketOpenWindow) packet; 50 | 51 | // Unregister in any case, don't keep listening 52 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 19); 53 | 54 | if("EntityHorse".equals(open.getGuiId())) { 55 | Minecraft mc = Minecraft.getMinecraft(); 56 | 57 | int entity_id = open.getEntityId(); 58 | Entity entity = mc.world.getEntityByID(entity_id); 59 | 60 | if(entity == null) { // desync between client & server, let's assume we are mounting a donkey 61 | GhostDonkey fake = new GhostDonkey(mc.world); 62 | // fake.setEntityId(entity_id); // performed in addEntityToWorld 63 | fake.setHorseSaddled(true); 64 | fake.setChested(true); // everything we need 65 | fake.setPosition(mc.player.posX, mc.player.posY, mc.player.posZ); 66 | 67 | // Spawn & ride 68 | mc.world.addEntityToWorld(entity_id, fake); 69 | mc.player.startRiding(fake, true); 70 | 71 | // Sync vehicle position 72 | ((CommandsModule)FamilyFunPack.getModules().getByClass(CommandsModule.class)).getCommand("sync").execute(new String[0]); 73 | 74 | mc.player.openGuiHorseInventory(fake, new ContainerHorseChest(open.getWindowTitle().appendText(" [" + entity_id + "]"), open.getSlotCount())); 75 | mc.player.openContainer.windowId = open.getWindowId(); 76 | } else if(entity instanceof AbstractHorse) { 77 | AbstractHorse horse = (AbstractHorse) entity; 78 | 79 | mc.player.openGuiHorseInventory(horse, new ContainerHorseChest(open.getWindowTitle(), open.getSlotCount())); 80 | mc.player.openContainer.windowId = open.getWindowId(); 81 | } else FamilyFunPack.printMessage(TextFormatting.DARK_RED + "Error:" + TextFormatting.RESET + " Server gave us the inventory of an entity which is not an AbstractHorse"); 82 | 83 | return null; 84 | } 85 | return packet; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/PacketDumpCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.network.EnumPacketDirection; 4 | import net.minecraft.network.Packet; 5 | import net.minecraft.network.play.server.SPacketCustomSound; 6 | import net.minecraft.network.play.server.SPacketEntityTeleport; 7 | import net.minecraft.network.play.server.SPacketExplosion; 8 | import net.minecraft.network.play.server.SPacketSpawnGlobalEntity; 9 | import net.minecraft.network.play.server.SPacketSoundEffect; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | 13 | import io.netty.buffer.ByteBuf; 14 | 15 | import java.lang.Class; 16 | 17 | import family_fun_pack.FamilyFunPack; 18 | import family_fun_pack.network.PacketListener; 19 | 20 | /* Dump received packets in chat */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class PacketDumpCommand extends Command implements PacketListener { 24 | 25 | private String last_packet; 26 | private int last_id; 27 | private int count; 28 | 29 | public PacketDumpCommand() { 30 | super("pckdump"); 31 | this.count = 0; 32 | this.last_id = -1; 33 | this.last_packet = null; 34 | } 35 | 36 | public String usage() { 37 | return this.getName() + " "; 38 | } 39 | 40 | public String execute(String[] args) { 41 | if(args.length > 1) { 42 | if(args[1].equals("on")) { 43 | this.last_id = -1; 44 | this.last_packet = null; 45 | for(int i = 0; i < 80; i ++) { 46 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, i); 47 | } 48 | return "pckdump on"; 49 | } else if(args[1].equals("client")) { 50 | this.last_id = -1; 51 | this.last_packet = null; 52 | for(int i = 0; i < 33; i ++) { 53 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, i); 54 | } 55 | return "pckcltdump on"; 56 | } else { 57 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this); 58 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this); 59 | return "pckdump off"; 60 | } 61 | } 62 | return this.getUsage(); 63 | } 64 | 65 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 66 | 67 | if(id != this.last_id) { 68 | if(this.last_packet != null) { 69 | FamilyFunPack.printMessage("Received packet [" + this.last_packet + "] x " + this.count); 70 | } 71 | 72 | if(packet instanceof SPacketEntityTeleport) { 73 | SPacketEntityTeleport teleport = (SPacketEntityTeleport) packet; 74 | FamilyFunPack.printMessage(String.format("Received SPacketEntityTeleport for (%.2f, %.2f, %.2f) id: %d", teleport.getX(), teleport.getY(), teleport.getZ(), teleport.getEntityId())); 75 | this.last_packet = null; 76 | this.last_id = -1; 77 | } else if(packet instanceof SPacketCustomSound) { 78 | SPacketCustomSound sound = (SPacketCustomSound) packet; 79 | FamilyFunPack.printMessage(String.format("Received SPacketCustomSound at (%.2f, %.2f, %.2f)", sound.getX(), sound.getY(), sound.getZ())); 80 | this.last_packet = null; 81 | this.last_id = -1; 82 | } else if(packet instanceof SPacketExplosion) { 83 | SPacketExplosion expl = (SPacketExplosion) packet; 84 | FamilyFunPack.printMessage(String.format("Received SPacketExplosion at (%.2f, %.2f, %.2f)", expl.getX(), expl.getY(), expl.getZ())); 85 | this.last_packet = null; 86 | this.last_id = -1; 87 | } else if(packet instanceof SPacketSoundEffect) { 88 | SPacketSoundEffect sound = (SPacketSoundEffect) packet; 89 | FamilyFunPack.printMessage(String.format("Received SPacketSoundEffect at (%.2f, %.2f, %.2f)", sound.getX(), sound.getY(), sound.getZ())); 90 | this.last_packet = null; 91 | this.last_id = -1; 92 | } else if(packet instanceof SPacketSpawnGlobalEntity) { 93 | SPacketSpawnGlobalEntity glb = (SPacketSpawnGlobalEntity) packet; 94 | FamilyFunPack.printMessage(String.format("Received SPacketSpawnGlobalEntity at (%.2f, %.2f, %.2f)", glb.getX(), glb.getY(), glb.getZ())); 95 | this.last_packet = null; 96 | this.last_id = -1; 97 | } else { 98 | this.last_packet = packet.getClass().getSimpleName(); 99 | this.last_id = id; 100 | this.count = 1; 101 | } 102 | } else this.count += 1; 103 | 104 | return packet; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/PeekCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiScreen; 5 | import net.minecraft.client.gui.GuiScreenBook; 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.item.Item; 8 | import net.minecraft.item.ItemShulkerBox; 9 | import net.minecraft.item.ItemWritableBook; 10 | import net.minecraft.item.ItemWrittenBook; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraft.network.datasync.EntityDataManager; 13 | import net.minecraft.nbt.NBTTagCompound; 14 | import net.minecraftforge.common.MinecraftForge; 15 | import net.minecraftforge.client.event.GuiOpenEvent; 16 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 17 | import net.minecraftforge.fml.relauncher.SideOnly; 18 | import net.minecraftforge.fml.relauncher.Side; 19 | 20 | import family_fun_pack.FamilyFunPack; 21 | import family_fun_pack.commands.ItemSizeCommand; 22 | import family_fun_pack.gui.interfaces.PreviewGui; 23 | 24 | /* Shulker/book peek, but for shulker/book dropped on the floor or hold by other entities */ 25 | 26 | @SideOnly(Side.CLIENT) 27 | public class PeekCommand extends Command { 28 | 29 | private GuiScreen screen; 30 | 31 | public PeekCommand() { 32 | super("stare"); 33 | this.screen = null; 34 | } 35 | 36 | public String usage() { 37 | return this.getName(); 38 | } 39 | 40 | public String execute(String[] args) { 41 | Minecraft mc = Minecraft.getMinecraft(); 42 | 43 | boolean book = args.length > 1 && args[1].equals("book"); 44 | 45 | double distance = 0; 46 | ItemStack stack = null; 47 | for(Entity entity : mc.world.getEntitiesWithinAABB(Entity.class, mc.player.getEntityBoundingBox().grow(12.0D, 4.0D, 12.0D))) { 48 | if(entity == mc.player) continue; 49 | 50 | ItemStack current = null; 51 | 52 | // Search through entities metadata 53 | for(EntityDataManager.DataEntry entry : entity.getDataManager().getAll()) { 54 | if(entry.getValue() instanceof ItemStack && ((book && (((ItemStack) entry.getValue()).getItem() instanceof ItemWritableBook || ((ItemStack) entry.getValue()).getItem() instanceof ItemWrittenBook)) || (!book && ((ItemStack) entry.getValue()).getItem() instanceof ItemShulkerBox))) { 55 | current = (ItemStack) entry.getValue(); 56 | break; 57 | } 58 | } 59 | 60 | if(current == null) { // Search through entity equipment 61 | for(ItemStack item : entity.getEquipmentAndArmor()) { 62 | if((!book && item.getItem() instanceof ItemShulkerBox) || (book && (item.getItem() instanceof ItemWritableBook || item.getItem() instanceof ItemWrittenBook))) { 63 | current = item; 64 | break; 65 | } 66 | } 67 | } 68 | 69 | double sqDist = mc.player.getDistanceSq(entity); 70 | if(current != null && (stack == null || sqDist < distance)) { 71 | stack = current; 72 | distance = sqDist; 73 | } 74 | } 75 | 76 | if(stack == null) return "No " + (book ? "book" : "shulker") + " item close to you"; 77 | 78 | if(book) { 79 | 80 | if(stack.getItem() instanceof ItemWritableBook) { 81 | stack = stack.copy(); 82 | stack.getTagCompound().setString("title", "Writable book"); 83 | stack.getTagCompound().setString("author", "No author"); 84 | } 85 | 86 | if(! stack.getTagCompound().hasKey("pages", 9)) return "Book has no data"; 87 | 88 | FamilyFunPack.printMessage("Book size: " + ItemSizeCommand.getItemSize(stack) + " bytes"); 89 | 90 | this.screen = new GuiScreenBook(mc.player, stack, false); 91 | MinecraftForge.EVENT_BUS.register(this); 92 | } else { 93 | NBTTagCompound tag = stack.getTagCompound(); 94 | if(tag != null && tag.hasKey("BlockEntityTag") && tag.getTagId("BlockEntityTag") == 10) { 95 | NBTTagCompound blockTag = tag.getCompoundTag("BlockEntityTag"); 96 | if(blockTag.hasKey("Items") && blockTag.getTagId("Items") == 9) { 97 | this.screen = new PreviewGui(blockTag.getTagList("Items", 10), false); 98 | MinecraftForge.EVENT_BUS.register(this); 99 | return null; 100 | } 101 | } 102 | 103 | return "Shulker is empty, or the server did not communicate its content"; 104 | } 105 | return null; 106 | } 107 | 108 | @SubscribeEvent 109 | public void onGuiOpened(GuiOpenEvent event) { 110 | if(event.getGui() == null) { 111 | event.setGui(this.screen); 112 | this.screen = null; 113 | } 114 | MinecraftForge.EVENT_BUS.unregister(this); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/QueueUtilsCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.network.EnumPacketDirection; 5 | import net.minecraft.network.Packet; 6 | import net.minecraft.network.play.server.SPacketTeams; 7 | import net.minecraft.scoreboard.Scoreboard; 8 | import net.minecraft.scoreboard.ScorePlayerTeam; 9 | import net.minecraft.util.text.TextFormatting; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | 13 | import io.netty.buffer.ByteBuf; 14 | 15 | import java.util.Collection; 16 | import java.util.List; 17 | import java.util.LinkedList; 18 | import java.util.concurrent.locks.ReadWriteLock; 19 | import java.util.concurrent.locks.ReentrantReadWriteLock; 20 | 21 | import family_fun_pack.FamilyFunPack; 22 | import family_fun_pack.network.PacketListener; 23 | 24 | /* Inspect 2b2t queue, who is in, can not know position */ 25 | 26 | @SideOnly(Side.CLIENT) 27 | public class QueueUtilsCommand extends Command implements PacketListener { 28 | 29 | public QueueUtilsCommand() { 30 | super("queue"); 31 | } 32 | 33 | public String usage() { 34 | return this.getName() + " show|hide|"; 35 | } 36 | 37 | public String execute(String[] args) { 38 | if(args.length > 1) { 39 | switch(args[1]) { 40 | case "show": 41 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 68); 42 | break; 43 | case "hide": 44 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 68); 45 | break; 46 | default: 47 | { 48 | ScorePlayerTeam queue = this.getQueueTeam(); 49 | if(queue == null) return "No queue"; 50 | if(queue.getMembershipCollection().contains(args[1])) return args[1] + " is in queue"; 51 | return args[1] + " not in queue"; 52 | } 53 | } 54 | return null; 55 | } 56 | return this.getUsage(); 57 | } 58 | 59 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 60 | SPacketTeams teams = (SPacketTeams) packet; 61 | if(teams.getName().startsWith("collideRule_")) { 62 | switch(teams.getAction()) { 63 | case 3: 64 | for(String player : teams.getPlayers()) { 65 | FamilyFunPack.printMessage(TextFormatting.GREEN + "Player " + player + " added to queue"); 66 | } 67 | break; 68 | case 4: 69 | for(String player : teams.getPlayers()) { 70 | FamilyFunPack.printMessage(TextFormatting.RED + "Player " + player + " removed from queue"); 71 | } 72 | break; 73 | } 74 | } 75 | return packet; 76 | } 77 | 78 | private ScorePlayerTeam getQueueTeam() { 79 | Scoreboard board = Minecraft.getMinecraft().world.getScoreboard(); 80 | for(ScorePlayerTeam t : board.getTeams()) { 81 | if(t.getName().startsWith("collideRule_")) return t; 82 | } 83 | return null; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/RaytraceCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.util.math.RayTraceResult; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | /* Get entity id / position of entity / block we are staring at */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class RaytraceCommand extends Command { 14 | 15 | public RaytraceCommand() { 16 | super("raytrace"); 17 | } 18 | 19 | public String usage() { 20 | return this.getName(); 21 | } 22 | 23 | public String execute(String[] args) { 24 | RayTraceResult target_ray = Minecraft.getMinecraft().objectMouseOver; 25 | if(target_ray != null) { 26 | if(target_ray.typeOfHit == RayTraceResult.Type.BLOCK) { 27 | BlockPos pos = target_ray.getBlockPos(); 28 | return String.format("Block at (%d, %d, %d)", pos.getX(), pos.getY(), pos.getZ()); 29 | } else if(target_ray.typeOfHit == RayTraceResult.Type.ENTITY) { 30 | Entity entity = target_ray.entityHit; 31 | return String.format("Entity id is %d%s%s", entity.getEntityId(), (args.length > 1 && args[1].equals("+") ? " [" + entity.getUniqueID() + "]" : ""), (entity.isRiding() ? String.format(" riding %d", entity.getRidingEntity().getEntityId()) : "")); 32 | } 33 | return "No target"; 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/ReOpenCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.gui.GuiScreen; 4 | import net.minecraftforge.common.MinecraftForge; 5 | import net.minecraftforge.client.event.GuiOpenEvent; 6 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.FamilyFunPack; 11 | import family_fun_pack.modules.NoCloseModule; 12 | 13 | /* Re-open closed inventory client-side */ 14 | 15 | @SideOnly(Side.CLIENT) 16 | public class ReOpenCommand extends Command { 17 | 18 | public ReOpenCommand() { 19 | super("reopen"); 20 | } 21 | 22 | public String usage() { 23 | return this.getName(); 24 | } 25 | 26 | public String execute(String[] args) { 27 | NoCloseModule module = (NoCloseModule) FamilyFunPack.getModules().getByClass(NoCloseModule.class); 28 | GuiScreen screen = module.getOpenedContainer(); 29 | if(screen == null) return "No container is currently opened"; 30 | MinecraftForge.EVENT_BUS.register(new GuiOpener(screen)); 31 | return null; 32 | } 33 | 34 | // Forge event listener used to open GUI 35 | private static class GuiOpener { 36 | 37 | private final GuiScreen gui; 38 | 39 | public GuiOpener(GuiScreen gui) { 40 | this.gui = gui; 41 | } 42 | 43 | @SubscribeEvent 44 | public void onGuiOpened(GuiOpenEvent event) { 45 | if(event.getGui() == null) { 46 | event.setGui(this.gui); 47 | } 48 | MinecraftForge.EVENT_BUS.unregister(this); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/RespawnCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.network.play.client.CPacketClientStatus; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.FamilyFunPack; 8 | 9 | /* Send a respawn packet */ 10 | 11 | @SideOnly(Side.CLIENT) 12 | public class RespawnCommand extends Command { 13 | 14 | public RespawnCommand() { 15 | super("respawn"); 16 | } 17 | 18 | public String usage() { 19 | return this.getName(); 20 | } 21 | 22 | public String execute(String[] args) { 23 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN)); 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/RollbackDupeCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.passive.AbstractChestHorse; 6 | import net.minecraft.entity.passive.AbstractHorse; 7 | import net.minecraft.network.EnumPacketDirection; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import java.util.List; 12 | 13 | import family_fun_pack.FamilyFunPack; 14 | import family_fun_pack.modules.CommandsModule; 15 | import family_fun_pack.modules.PacketInterceptionModule; 16 | 17 | // rollback dupe automation 18 | // faster way of doing this https://www.youtube.com/watch?v=o3aMoQTOZGs 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class RollbackDupeCommand extends Command { 22 | 23 | private boolean on; 24 | 25 | public RollbackDupeCommand() { 26 | super("rdupe"); 27 | } 28 | 29 | public String usage() { 30 | return this.getName() + " [reset]"; 31 | } 32 | 33 | public String execute(String[] args) { 34 | Minecraft mc = Minecraft.getMinecraft(); 35 | 36 | if(args.length > 1 && args[1].equals("reset")) { 37 | this.on = false; 38 | } else { 39 | PacketInterceptionModule intercept = (PacketInterceptionModule) FamilyFunPack.getModules().getByClass(PacketInterceptionModule.class); 40 | CommandsModule cmd = (CommandsModule) FamilyFunPack.getModules().getByClass(CommandsModule.class); 41 | 42 | if(! on) { // init 43 | 44 | List horses = mc.player.world.getEntitiesWithinAABB(AbstractHorse.class, mc.player.getEntityBoundingBox().grow(6.0D, 2.0D, 6.0D)); 45 | if(horses.size() == 0) return "where's your ride ?"; 46 | 47 | Entity ride = horses.get(0); 48 | 49 | cmd.handleCommand("rollback"); 50 | 51 | intercept.addIntercept(EnumPacketDirection.SERVERBOUND, 12); 52 | intercept.addIntercept(EnumPacketDirection.SERVERBOUND, 13); 53 | intercept.addIntercept(EnumPacketDirection.SERVERBOUND, 14); 54 | intercept.addIntercept(EnumPacketDirection.SERVERBOUND, 15); 55 | intercept.removeIntercept(EnumPacketDirection.SERVERBOUND, 16); 56 | intercept.toggle(true); 57 | 58 | cmd.handleCommand(String.format("use %d", ride.getEntityId())); 59 | 60 | this.on = true; 61 | } else { // exec 62 | 63 | List donkeys = mc.player.world.getEntitiesWithinAABB(AbstractChestHorse.class, mc.player.getEntityBoundingBox().grow(6.0D, 2.0D, 6.0D)); 64 | 65 | Entity ddonkey = null; 66 | for(AbstractChestHorse c : donkeys) { 67 | if(c != mc.player.getRidingEntity()) { 68 | ddonkey = c; 69 | break; 70 | } 71 | } 72 | 73 | if(ddonkey == null) return "where's donkey ?"; 74 | 75 | cmd.handleCommand(String.format("use sneak %d", ddonkey.getEntityId())); 76 | 77 | intercept.addIntercept(EnumPacketDirection.SERVERBOUND, 16); 78 | 79 | cmd.handleCommand("rollback double"); 80 | 81 | this.on = false; 82 | } 83 | } 84 | 85 | return null; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/SpectateCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.network.play.client.CPacketSpectate; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import java.lang.IllegalArgumentException; 8 | import java.util.UUID; 9 | 10 | import family_fun_pack.FamilyFunPack; 11 | 12 | /* Send a spectate packet */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class SpectateCommand extends Command { 16 | 17 | public SpectateCommand() { 18 | super("spectate"); 19 | } 20 | 21 | public String usage() { 22 | return this.getName() + " "; 23 | } 24 | 25 | public String execute(String[] args) { 26 | if(args.length > 1) { 27 | UUID uuid = null; 28 | try { 29 | uuid = UUID.fromString(args[1]); 30 | } catch(IllegalArgumentException e) { 31 | return "Wrong UUID format"; 32 | } 33 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketSpectate(uuid)); 34 | return "trying to spectate " + uuid; 35 | } 36 | return this.getUsage(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/StalkCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import family_fun_pack.FamilyFunPack; 7 | import family_fun_pack.modules.Module; 8 | import family_fun_pack.modules.StalkModule; 9 | 10 | /* Manage stalked players list */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class StalkCommand extends Command { 14 | 15 | public StalkCommand() { 16 | super("stalk"); 17 | } 18 | 19 | public String usage() { 20 | return this.getName() + " "; 21 | } 22 | 23 | public String execute(String[] args) { 24 | if(args.length > 1) { 25 | StalkModule module = (StalkModule) FamilyFunPack.getModules().getByClass(StalkModule.class); 26 | module.togglePlayer(args[1]); 27 | return null; 28 | } 29 | return this.getUsage(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/SyncMountCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketPlayer; 8 | import net.minecraft.network.play.client.CPacketVehicleMove; 9 | import net.minecraft.network.play.server.SPacketMoveVehicle; 10 | import net.minecraft.network.play.server.SPacketPlayerPosLook; 11 | import net.minecraft.util.math.Vec3d; 12 | import net.minecraftforge.fml.relauncher.SideOnly; 13 | import net.minecraftforge.fml.relauncher.Side; 14 | 15 | import io.netty.buffer.ByteBuf; 16 | 17 | import family_fun_pack.FamilyFunPack; 18 | import family_fun_pack.entities.EntityVoid; 19 | import family_fun_pack.entities.GhostDonkey; 20 | import family_fun_pack.network.PacketListener; 21 | 22 | /* Sync our position with server */ 23 | 24 | @SideOnly(Side.CLIENT) 25 | public class SyncMountCommand extends Command implements PacketListener { 26 | 27 | public SyncMountCommand() { 28 | super("sync"); 29 | } 30 | 31 | public String usage() { 32 | return this.getName(); 33 | } 34 | 35 | public String execute(String[] args) { 36 | Minecraft mc = Minecraft.getMinecraft(); 37 | 38 | double x = mc.player.posX + 1000d; 39 | double y = mc.player.posY; 40 | double z = mc.player.posZ + 1000d; 41 | 42 | if(args.length > 3) { 43 | try { 44 | x = Integer.parseInt(args[1]); 45 | y = Integer.parseInt(args[2]); 46 | z = Integer.parseInt(args[3]); 47 | } catch(NumberFormatException e) { 48 | return this.getUsage(); 49 | } 50 | } 51 | 52 | if(mc.player.isRiding()) { 53 | Entity ride = new EntityVoid(mc.world, 0); 54 | ride.setPosition(x, y, z); // Don't use this near world border, or get kicked 55 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 41); 56 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketVehicleMove(ride)); 57 | } else { 58 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 47); 59 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayer.Position(x, y, z, true)); 60 | } 61 | return null; 62 | } 63 | 64 | public void onDisconnect() { 65 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 41, 47); 66 | } 67 | 68 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 69 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 41, 47); 70 | 71 | Minecraft mc = Minecraft.getMinecraft(); 72 | Vec3d loc; 73 | 74 | if(id == 41) { 75 | SPacketMoveVehicle move = (SPacketMoveVehicle) packet; 76 | loc = new Vec3d(move.getX(), move.getY(), move.getZ()); 77 | } else { 78 | SPacketPlayerPosLook move = (SPacketPlayerPosLook) packet; 79 | loc = new Vec3d(move.getX(), move.getY(), move.getZ()); 80 | } 81 | 82 | if(! this.showDebugInfo()) { 83 | loc = loc.subtract(mc.player.posX, mc.player.posY, mc.player.posZ); 84 | } 85 | 86 | FamilyFunPack.printMessage(String.format("%s sync -> (%.2f, %.2f, %.2f)", (id == 41 ? "Vehicle" : "Player"), loc.x, loc.y, loc.z)); 87 | 88 | return packet; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/UseCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.play.client.CPacketEntityAction; 6 | import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; 7 | import net.minecraft.network.play.client.CPacketUseEntity; 8 | import net.minecraft.util.EnumFacing; 9 | import net.minecraft.util.EnumHand; 10 | import net.minecraft.util.math.BlockPos; 11 | import net.minecraft.util.math.RayTraceResult; 12 | import net.minecraft.util.math.Vec3d; 13 | import net.minecraftforge.fml.relauncher.SideOnly; 14 | import net.minecraftforge.fml.relauncher.Side; 15 | 16 | import family_fun_pack.FamilyFunPack; 17 | import family_fun_pack.entities.EntityVoid; 18 | 19 | /* Use entity / block */ 20 | 21 | /* .use [sneak|attack] [entity_id] 22 | * .use [ ] */ 23 | 24 | @SideOnly(Side.CLIENT) 25 | public class UseCommand extends Command { 26 | 27 | public UseCommand() { 28 | super("use"); 29 | } 30 | 31 | public String usage() { 32 | return this.getName() + " ([sneak|attack] | )"; 33 | } 34 | 35 | public String execute(String[] args) { 36 | Minecraft mc = Minecraft.getMinecraft(); 37 | 38 | int x = 0, y = 0, z = 0, cursor = 1; 39 | boolean sneak = false, attack = false; 40 | Mode mode = null; 41 | 42 | /* Parse arguments */ 43 | while(cursor < args.length) { 44 | if(args[cursor].equals("sneak")) { 45 | sneak = true; 46 | cursor += 1; 47 | } else if(args[cursor].equals("attack")) { 48 | attack = true; 49 | cursor += 1; 50 | } else break; 51 | } 52 | 53 | if(args.length - cursor >= 3) { // Block position 54 | try { 55 | x = Integer.parseInt(args[cursor++]); 56 | y = Integer.parseInt(args[cursor++]); 57 | z = Integer.parseInt(args[cursor]); 58 | } catch(NumberFormatException e) { 59 | return this.getUsage(); 60 | } 61 | mode = Mode.BLOCK; 62 | } else if(args.length - cursor >= 1) { // Entity id 63 | try { 64 | x = Integer.parseInt(args[cursor]); 65 | } catch(NumberFormatException e) { 66 | return this.getUsage(); 67 | } 68 | mode = Mode.ENTITY; 69 | } else { // Raytrace 70 | RayTraceResult target_ray = mc.objectMouseOver; 71 | if(target_ray == null) return "No target"; 72 | 73 | if(target_ray.typeOfHit == RayTraceResult.Type.BLOCK) { 74 | BlockPos pos = target_ray.getBlockPos(); 75 | x = pos.getX(); 76 | y = pos.getY(); 77 | z = pos.getZ(); 78 | mode = Mode.BLOCK; 79 | } else if(target_ray.typeOfHit == RayTraceResult.Type.ENTITY) { 80 | x = target_ray.entityHit.getEntityId(); 81 | mode = Mode.ENTITY; 82 | } else return "No target"; 83 | } 84 | 85 | /* Execute command */ 86 | 87 | String ret = null; 88 | 89 | if(sneak) 90 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(new EntityVoid(mc.world, mc.player.getEntityId()), CPacketEntityAction.Action.START_SNEAKING)); 91 | 92 | switch(mode) { 93 | case BLOCK: 94 | { 95 | Vec3d look = mc.player.getLookVec(); 96 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayerTryUseItemOnBlock(new BlockPos(x, y, z), EnumFacing.UP, EnumHand.MAIN_HAND, (float)look.x, (float)look.y, (float)look.z)); 97 | ret = String.format("Using block (%d, %d, %d)", x, y, z); 98 | } 99 | break; 100 | case ENTITY: 101 | { 102 | if(attack) FamilyFunPack.getNetworkHandler().sendPacket(new CPacketUseEntity(new EntityVoid(mc.world, x))); 103 | else FamilyFunPack.getNetworkHandler().sendPacket(new CPacketUseEntity(new EntityVoid(mc.world, x), EnumHand.MAIN_HAND)); 104 | ret = String.format("Using entity [%d]", x); 105 | } 106 | break; 107 | } 108 | 109 | if(sneak) // Stop sneaking, so we don't dismount on next update 110 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(new EntityVoid(mc.world, mc.player.getEntityId()), CPacketEntityAction.Action.STOP_SNEAKING)); 111 | 112 | return ret; 113 | } 114 | 115 | public enum Mode {BLOCK, ENTITY} 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/VClipCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketPlayer; 8 | import net.minecraft.network.play.client.CPacketVehicleMove; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import family_fun_pack.FamilyFunPack; 13 | import family_fun_pack.modules.PacketInterceptionModule; 14 | 15 | /* Vertical client-side teleport */ 16 | 17 | @SideOnly(Side.CLIENT) 18 | public class VClipCommand extends Command { 19 | 20 | public VClipCommand() { 21 | super("vclip"); 22 | } 23 | 24 | public String usage() { 25 | return this.getName() + " "; 26 | } 27 | 28 | public String execute(String[] args) { 29 | if(args.length > 1) { 30 | Minecraft mc = Minecraft.getMinecraft(); 31 | try { 32 | double weight = Double.parseDouble(args[1]); 33 | 34 | // Client side 35 | Entity target = mc.player.isRiding() ? mc.player.getRidingEntity() : mc.player; 36 | target.setPosition(target.posX, target.posY + weight, target.posZ); 37 | 38 | // Send move packet 39 | Packet packet = null; 40 | if(mc.player.isRiding()) packet = new CPacketVehicleMove(target); 41 | else packet = new CPacketPlayer.Position(target.posX, target.posY, target.posZ, true); 42 | 43 | PacketInterceptionModule intercept = (PacketInterceptionModule) FamilyFunPack.getModules().getByClass(PacketInterceptionModule.class); 44 | intercept.addException(EnumPacketDirection.SERVERBOUND, packet); 45 | 46 | FamilyFunPack.getNetworkHandler().sendPacket(packet); 47 | 48 | return String.format("Teleported you %s blocks up", weight); 49 | } catch(NumberFormatException e) { 50 | return "This is not a real number"; 51 | } 52 | } 53 | return "Specify a number"; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/VanishCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketVehicleMove; 8 | import net.minecraft.network.play.server.SPacketDestroyEntities; 9 | import net.minecraft.network.play.server.SPacketSetPassengers; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import net.minecraftforge.fml.relauncher.Side; 12 | 13 | import io.netty.buffer.ByteBuf; 14 | 15 | import family_fun_pack.FamilyFunPack; 16 | import family_fun_pack.network.PacketListener; 17 | 18 | /* Entity desync */ 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class VanishCommand extends Command implements PacketListener { 22 | 23 | private Entity ride; 24 | 25 | public VanishCommand() { 26 | super("vanish"); 27 | this.ride = null; 28 | } 29 | 30 | public String usage() { 31 | return this.getName() + " "; 32 | } 33 | 34 | public String execute(String[] args) { 35 | if(args.length > 1) { 36 | Minecraft mc = Minecraft.getMinecraft(); 37 | String ret = null; 38 | switch(args[1]) { 39 | case "dismount": 40 | { 41 | if(mc.player.isRiding()) { 42 | this.ride = mc.player.getRidingEntity(); 43 | mc.player.dismountRidingEntity(); 44 | mc.world.removeEntity(this.ride); 45 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 50, 67); 46 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, 12, 13, 14); 47 | } else ret = "You are not riding anything"; 48 | } 49 | break; 50 | case "remount": 51 | { 52 | if(this.ride != null) { 53 | if(! mc.player.isRiding()) { 54 | this.ride.isDead = false; 55 | mc.world.spawnEntity(this.ride); 56 | mc.player.startRiding(this.ride, true); 57 | if(mc.player.isRiding()) 58 | ret = "Entity " + this.ride.hashCode() + " remounted"; 59 | else 60 | ret = "Could not remount"; 61 | } 62 | this.onDisconnect(); 63 | } else ret = "Nothing to remount"; 64 | } 65 | break; 66 | default: 67 | ret = "Unknown argument " + args[1]; 68 | } 69 | return ret; 70 | } 71 | return "dismount or remount ?"; 72 | } 73 | 74 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 75 | if(direction == EnumPacketDirection.CLIENTBOUND) { 76 | if(id == 50) { // SPacketDestroyEntities 77 | SPacketDestroyEntities destroy = (SPacketDestroyEntities) packet; 78 | for(int i : destroy.getEntityIDs()) { 79 | if(i == this.ride.hashCode()) { 80 | FamilyFunPack.printMessage("Server destroyed our ride. We dismounted."); 81 | this.onDisconnect(); 82 | } 83 | } 84 | } else { // SPacketSetPassengers 85 | Minecraft mc = Minecraft.getMinecraft(); 86 | SPacketSetPassengers passengers = (SPacketSetPassengers) packet; 87 | boolean dismount = (passengers.getEntityId() == this.ride.hashCode()); 88 | for(int i : passengers.getPassengerIds()) { 89 | if(i == mc.player.hashCode()) { 90 | dismount = !dismount; 91 | break; 92 | } 93 | } 94 | if(dismount) { 95 | FamilyFunPack.printMessage("Server dismounted you from your (vanished) ride."); 96 | this.ride.isDead = false; 97 | mc.world.spawnEntity(this.ride); 98 | this.onDisconnect(); 99 | } 100 | } 101 | } else { // CPacketPlayer 102 | Minecraft mc = Minecraft.getMinecraft(); 103 | if(! mc.player.isRiding()) { 104 | mc.player.onGround = true; 105 | this.ride.setPosition(mc.player.posX, mc.player.posY, mc.player.posZ); 106 | return new CPacketVehicleMove(this.ride); 107 | } else this.onDisconnect(); 108 | } 109 | return packet; 110 | } 111 | 112 | public void onDisconnect() { 113 | if(this.ride != null) { 114 | this.ride = null; 115 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 50, 67); 116 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 12, 13, 14); 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/VoidMountCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.EntityList; 6 | import net.minecraft.entity.passive.AbstractChestHorse; 7 | import net.minecraft.entity.passive.AbstractHorse; 8 | import net.minecraft.entity.passive.EntityLlama; 9 | import net.minecraft.network.datasync.DataParameter; 10 | import net.minecraft.network.datasync.DataSerializers; 11 | import net.minecraft.util.ResourceLocation; 12 | import net.minecraftforge.fml.relauncher.SideOnly; 13 | import net.minecraftforge.fml.relauncher.Side; 14 | 15 | /* Create entity and mount it, only for client side */ 16 | /* For example: use it while riding a llama to replace it by a horse */ 17 | 18 | @SideOnly(Side.CLIENT) 19 | public class VoidMountCommand extends Command { 20 | 21 | public static void setSaddled(Entity entity) { 22 | if(entity instanceof AbstractHorse) { 23 | ((AbstractHorse) entity).setHorseSaddled(true); 24 | ((AbstractHorse) entity).setHorseTamed(true); 25 | 26 | if(entity instanceof AbstractChestHorse) { 27 | ((AbstractChestHorse) entity).setChested(true); 28 | 29 | if(entity instanceof EntityLlama) { 30 | entity.getDataManager().set(new DataParameter(16, DataSerializers.VARINT), Integer.valueOf(3)); 31 | } 32 | } 33 | } 34 | } 35 | 36 | private int last_id; 37 | 38 | public VoidMountCommand() { 39 | super("mount"); 40 | this.last_id = 42; 41 | } 42 | 43 | public String usage() { 44 | return this.getName() + " [entity_id]"; 45 | } 46 | 47 | public String execute(String[] args) { 48 | if(args.length > 1) { 49 | Minecraft mc = Minecraft.getMinecraft(); 50 | 51 | if(args[1].equals("null")) { 52 | Entity entity = mc.player.getRidingEntity(); 53 | if(entity == null) return "You are not riding anything"; 54 | mc.player.dismountRidingEntity(); 55 | mc.world.removeEntityFromWorld(entity.getEntityId()); 56 | this.last_id = entity.getEntityId(); 57 | return "Removed void mount"; 58 | } else { 59 | 60 | int id = this.last_id; 61 | if(args.length > 2) { 62 | try { 63 | id = Integer.parseInt(args[2]); 64 | } catch(NumberFormatException e) { 65 | return "entity_id should be a number"; 66 | } 67 | } 68 | 69 | if(mc.player.isRiding()) { 70 | if(args.length <= 2) id = mc.player.getRidingEntity().getEntityId(); 71 | mc.player.dismountRidingEntity(); 72 | } 73 | 74 | ResourceLocation resource = new ResourceLocation(args[1]); 75 | Entity entity = EntityList.createEntityByIDFromName(resource, mc.world); 76 | if(entity == null) return "Invalid entity class"; 77 | 78 | VoidMountCommand.setSaddled(entity); 79 | 80 | entity.setPosition(mc.player.posX, mc.player.posY, mc.player.posZ); 81 | 82 | mc.world.addEntityToWorld(id, entity); 83 | mc.player.startRiding(entity, true); 84 | 85 | return "Mounted " + args[1]; 86 | } 87 | } 88 | return this.getUsage(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/commands/WorldDownloadCommand.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.commands; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.chunk.Chunk; 6 | import net.minecraftforge.common.MinecraftForge; 7 | import net.minecraftforge.event.world.ChunkEvent; 8 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import family_fun_pack.utils.WorldCapture; 13 | 14 | /* World download */ 15 | 16 | @SideOnly(Side.CLIENT) 17 | public class WorldDownloadCommand extends Command { 18 | 19 | private WorldCapture capture; 20 | 21 | public WorldDownloadCommand() { 22 | super("download"); 23 | this.capture = null; 24 | } 25 | 26 | public String usage() { 27 | return this.getName() + " start | stop"; 28 | } 29 | 30 | public String execute(String[] args) { 31 | Minecraft mc = Minecraft.getMinecraft(); 32 | if(args.length > 1) { 33 | if(args[1].equals("start") && args.length > 2) { 34 | if(this.capture != null) return "A download is currently on"; 35 | 36 | this.capture = new WorldCapture(args[2], mc.world.provider.getDimensionType(), new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ)); 37 | MinecraftForge.EVENT_BUS.register(this); 38 | 39 | return "World download on, go walk around.."; 40 | } else if(args[1].equals("stop")) { 41 | if(this.capture == null) return "No current download"; 42 | 43 | String name = this.capture.getName(); 44 | this.onDisconnect(); 45 | 46 | return "World download saved under name \"" + name + "\""; 47 | } 48 | } 49 | return this.getUsage(); 50 | } 51 | 52 | @SubscribeEvent 53 | public void onUnLoad(ChunkEvent.Unload event) { 54 | Chunk c = event.getChunk(); 55 | c.setLightPopulated(false); 56 | this.capture.captureChunk(c); 57 | } 58 | 59 | public void onDisconnect() { 60 | if(this.capture != null) { 61 | MinecraftForge.EVENT_BUS.unregister(this); 62 | this.saveSurroundings(); 63 | this.capture = null; 64 | } 65 | } 66 | 67 | private void saveSurroundings() { 68 | Minecraft mc = Minecraft.getMinecraft(); 69 | 70 | int x = (int)mc.getRenderViewEntity().posX >> 4, z = (int)mc.getRenderViewEntity().posZ >> 4; 71 | for(int i = x - mc.gameSettings.renderDistanceChunks; i <= x + mc.gameSettings.renderDistanceChunks; i ++) { 72 | for(int j = z - mc.gameSettings.renderDistanceChunks; j <= z + mc.gameSettings.renderDistanceChunks; j ++) { 73 | Chunk c = mc.world.getChunkProvider().getLoadedChunk(i, j); 74 | if(c != null) { 75 | c.setLightPopulated(false); 76 | this.capture.captureChunk(c); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/entities/EntityVoid.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.entities; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.nbt.NBTTagCompound; 8 | import net.minecraft.world.World; 9 | 10 | @SideOnly(Side.CLIENT) 11 | public class EntityVoid extends Entity { 12 | 13 | public EntityVoid(World world, int id) { 14 | super(world); 15 | super.setEntityId(id); 16 | } 17 | 18 | protected void entityInit() { 19 | 20 | } 21 | 22 | protected void readEntityFromNBT(NBTTagCompound paramNBTTagCompound) { 23 | 24 | } 25 | 26 | protected void writeEntityToNBT(NBTTagCompound paramNBTTagCompound) { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/entities/GhostDonkey.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.entities; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.passive.EntityDonkey; 6 | import net.minecraft.world.World; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.render.RenderGhostDonkey; 11 | 12 | /* Ghost donkey, will appear when using .open command while mounting an entity that does not exist client-side 13 | * For example after mounting an entity from unloaded chunk, and then using .open to open its inventory 14 | */ 15 | 16 | @SideOnly(Side.CLIENT) 17 | public class GhostDonkey extends EntityDonkey { 18 | 19 | static { 20 | Minecraft.getMinecraft().getRenderManager().entityRenderMap.put(GhostDonkey.class, new RenderGhostDonkey(Minecraft.getMinecraft().getRenderManager())); 21 | } 22 | 23 | public GhostDonkey(World world) { 24 | super(world); 25 | } 26 | 27 | public void onLivingUpdate() { 28 | super.onLivingUpdate(); 29 | if(!this.isBeingRidden()) Minecraft.getMinecraft().world.removeEntityFromWorld(this.getEntityId()); 30 | } 31 | 32 | // On dismount 33 | protected void removePassenger(Entity player) { 34 | super.removePassenger(player); 35 | Minecraft.getMinecraft().world.removeEntityFromWorld(this.getEntityId()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/MainGuiComponent.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import java.util.Collection; 7 | import java.util.List; 8 | import java.util.LinkedList; 9 | 10 | import family_fun_pack.gui.components.ActionButton; 11 | 12 | /* A line in the main GUI, a label & a button */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public interface MainGuiComponent { 16 | 17 | // Get Label of the line 18 | String getLabel(); 19 | 20 | // Get action button to be displayed after label 21 | ActionButton getAction(); 22 | 23 | /* Get child component, a component depending on this one 24 | Returns null if component has no child */ 25 | MainGuiComponent getChild(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/ActionButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.gui.GuiButton; 4 | import net.minecraft.client.gui.GuiScreen; 5 | import net.minecraftforge.fml.relauncher.SideOnly; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | 8 | @SideOnly(Side.CLIENT) 9 | public abstract class ActionButton extends GuiButton { 10 | 11 | public ActionButton(int id, int x, int y, int width, int height, String text) { 12 | super(id, x, y, width, height, text); 13 | } 14 | 15 | public abstract void onClick(GuiScreen parent); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/ArrowButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.gui.interfaces.AdvancedSearchGui; 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class ArrowButton extends ActionButton { 14 | 15 | private final boolean left; 16 | 17 | public ArrowButton(int x, int y, boolean left) { 18 | super(0, x, y, 8, 8, null); 19 | this.left = left; 20 | } 21 | 22 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 23 | if(this.enabled) { 24 | GlStateManager.enableAlpha(); 25 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 26 | 27 | GlStateManager.pushMatrix(); 28 | GlStateManager.scale(0.5f, 0.5f, 0.5f); 29 | 30 | int x = (int)((float)this.x / 0.5f); 31 | int y = (int)((float)this.y / 0.5f); 32 | 33 | client.getTextureManager().bindTexture(SelectButton.NAVIGATION); 34 | Gui.drawModalRectWithCustomSizedTexture(x, y, (this.left ? 0 : 16), 0, 16, 16, 16 * 2, 16); 35 | 36 | GlStateManager.popMatrix(); 37 | } 38 | } 39 | 40 | public void onClick(GuiScreen parent) { 41 | ((AdvancedSearchGui)parent).nextPreset((this.left ? -1 : 1)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/ColorButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiButton; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.gui.components.actions.NumberAction; 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class ColorButton extends ActionButton { 14 | 15 | private static final int BORDER = 0xffcccccc; 16 | 17 | public static int DEFAULT_COLOR = 0xffff0000; 18 | 19 | private int color; 20 | private boolean drag; 21 | 22 | private final NumberAction action; 23 | 24 | public ColorButton(int id, int x, int y, NumberAction action) { 25 | super(id, x, y, 32, 7, null); 26 | this.color = ColorButton.DEFAULT_COLOR; 27 | this.action = action; 28 | this.drag = false; 29 | } 30 | 31 | public ColorButton(int x, int y, NumberAction action) { 32 | this(0, x, y, action); 33 | } 34 | 35 | public ColorButton setColor(int color) { 36 | this.color = color; 37 | return this; 38 | } 39 | 40 | public int getColor() { 41 | return this.color; 42 | } 43 | 44 | public void reset() { 45 | this.color = ColorButton.DEFAULT_COLOR; 46 | this.drag = false; 47 | } 48 | 49 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 50 | int x_end = this.x + this.width; 51 | int y_end = this.y + this.height; 52 | 53 | if(this.drag) this.dragged(mouseX, mouseY); 54 | 55 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 56 | drawRect(this.x, this.y, x_end, y_end, this.getColor()); 57 | drawRect(this.x, this.y, x_end, this.y + 1, ColorButton.BORDER); 58 | drawRect(this.x, this.y, this.x + 1, y_end, ColorButton.BORDER); 59 | drawRect(this.x, y_end - 1, x_end, y_end, ColorButton.BORDER); 60 | drawRect(x_end - 1, this.y, x_end, y_end, ColorButton.BORDER); 61 | 62 | int index = (((this.color & 0xff) / 85) + ((((this.color >> 8) & 0xff) / 85) * 4) + ((((this.color >> 16) & 0xff) / 85) * 16)) / (64 / this.width); 63 | drawRect(this.x + index, this.y - 2, this.x + index + 1, y_end + 2, ColorButton.BORDER); 64 | drawRect(this.x + index - 1, this.y, this.x + index + 2, y_end, ColorButton.BORDER); 65 | 66 | if(! this.enabled) drawRect(this.x, this.y, this.x + this.width, this.y + this.height, 0x99333333); 67 | } 68 | 69 | public void dragged(int mouseX, int mouseY) { 70 | int cursor = (mouseX < this.x ? this.x : (mouseX >= this.x + this.width ? this.x + this.width - 1 : mouseX)); 71 | int index = (cursor - this.x) * (64 / this.width); 72 | if(index > 32) index += (64 / this.width) - 1; 73 | this.color = ((index & 3) * 85) + ((((index >> 2) & 3) * 85) * 256) + (((index >> 4) * 85) * 65536) + 0xff000000; 74 | if(this.action != null) this.action.setNumber(this.color); 75 | } 76 | 77 | public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { 78 | if (super.mousePressed(mc, mouseX, mouseY)) { 79 | this.dragged(mouseX, mouseY); 80 | this.drag = true; 81 | return true; 82 | } 83 | return false; 84 | } 85 | 86 | public void mouseReleased(int mouseX, int mouseY) { 87 | this.drag = false; 88 | } 89 | 90 | @Override 91 | public void onClick(GuiScreen parent) {} 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/FormatButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.FontRenderer; 5 | import net.minecraft.client.gui.Gui; 6 | import net.minecraft.client.gui.GuiScreen; 7 | import net.minecraft.client.renderer.GlStateManager; 8 | import net.minecraft.util.text.TextFormatting; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import family_fun_pack.gui.MainGui; 13 | import family_fun_pack.gui.interfaces.BookEditingGui; 14 | 15 | /* Button describing a text format */ 16 | 17 | @SideOnly(Side.CLIENT) 18 | public class FormatButton extends ActionButton { 19 | 20 | private final TextFormatting format; 21 | 22 | private final FontRenderer fontRenderer; 23 | 24 | public FormatButton(int id, int x, int y, FontRenderer fontRenderer, TextFormatting format) { 25 | super(id, x, y, 0, 0, null); 26 | this.fontRenderer = fontRenderer; 27 | this.format = format; 28 | this.width = 7; 29 | this.height = 7; 30 | } 31 | 32 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 33 | GlStateManager.pushMatrix(); 34 | float scale = 0.7f; 35 | GlStateManager.scale(scale, scale, scale); 36 | 37 | int x = (int)((float)this.x / scale); 38 | int y = (int)((float)this.y / scale); 39 | int x_end = (int)((float)(this.x + this.width) / scale); 40 | int y_end = (int)((float)(this.y + this.height) / scale); 41 | 42 | if(this.format.isColor()) { 43 | drawRect(x, y, x_end, y_end, 0xff000000 | this.fontRenderer.getColorCode(this.format.toString().charAt(1))); 44 | } else { 45 | this.fontRenderer.drawString(this.format.toString().substring(1), x + 2, y + 1, 0xffffffff); 46 | } 47 | 48 | // Borders 49 | drawRect(x, y, x_end, y + 1, 0xffffffff); 50 | drawRect(x, y, x + 1, y_end, 0xffffffff); 51 | drawRect(x, y_end - 1, x_end, y_end, 0xffffffff); 52 | drawRect(x_end - 1, y, x_end, y_end, 0xffffffff); 53 | 54 | GlStateManager.popMatrix(); 55 | } 56 | 57 | public void onClick(GuiScreen parent) { 58 | ((BookEditingGui) parent).appendFormat(this.format.toString()); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/GenericButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.FontRenderer; 5 | import net.minecraft.client.gui.Gui; 6 | import net.minecraft.client.gui.GuiButton; 7 | import net.minecraft.client.gui.GuiScreen; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | @SideOnly(Side.CLIENT) 12 | public class GenericButton extends ActionButton { 13 | 14 | public FontRenderer fontRenderer; 15 | 16 | public GenericButton(int id, int x, int y, String text) { 17 | super(id, x, y, 0, 0, text); 18 | this.fontRenderer = Minecraft.getMinecraft().fontRenderer; 19 | this.width = this.fontRenderer.getStringWidth(this.displayString) + 4; 20 | this.height = this.fontRenderer.FONT_HEIGHT + 4; 21 | } 22 | 23 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 24 | if(this.enabled) { 25 | int x_end = this.x + this.width; 26 | int y_end = this.y + this.height; 27 | 28 | drawRect(this.x, this.y, x_end, y_end, OpenGuiButton.BACKGROUND); 29 | drawRect(this.x, this.y, x_end, this.y + 1, OpenGuiButton.COLOR); 30 | drawRect(this.x, this.y, this.x + 1, y_end, OpenGuiButton.COLOR); 31 | drawRect(this.x, y_end - 1, x_end, y_end, OpenGuiButton.COLOR); 32 | drawRect(x_end - 1, this.y, x_end, y_end, OpenGuiButton.COLOR); 33 | this.fontRenderer.drawString(this.displayString, this.x + 2, this.y + 2, OpenGuiButton.COLOR); 34 | } 35 | } 36 | 37 | public void onClick(GuiScreen parent) {} 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/OnOffButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | import net.minecraft.util.ResourceLocation; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import family_fun_pack.FamilyFunPack; 12 | import family_fun_pack.gui.components.actions.OnOffAction; 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class OnOffButton extends ActionButton { 16 | 17 | private static final ResourceLocation ON_OFF = new ResourceLocation(FamilyFunPack.MODID, "textures/gui/on_off.png"); 18 | 19 | private boolean state; 20 | private final OnOffAction action; 21 | 22 | public OnOffButton(int id, int x, int y, OnOffAction action) { 23 | super(id, x, y, 16, 7, null); 24 | this.state = false; 25 | this.action = action; 26 | } 27 | 28 | public OnOffButton(int x, int y, OnOffAction action) { 29 | this(0, x, y, action); 30 | } 31 | 32 | public OnOffButton setState(boolean state) { 33 | this.state = state; 34 | return this; 35 | } 36 | 37 | public boolean getState() { 38 | return this.state; 39 | } 40 | 41 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 42 | GlStateManager.enableAlpha(); 43 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 44 | 45 | client.getTextureManager().bindTexture(OnOffButton.ON_OFF); 46 | int i = 0; 47 | if(! this.state) i = this.height; 48 | 49 | Gui.drawModalRectWithCustomSizedTexture(this.x, this.y, 0, i, this.width, this.height, this.width, this.height * 2); 50 | 51 | if(! this.enabled) drawRect(this.x, this.y, this.x + this.width, this.y + this.height, 0x99333333); 52 | } 53 | 54 | public void onClick(GuiScreen parent) { 55 | if(! this.enabled) return; 56 | this.state = !this.state; 57 | if(this.action != null) this.action.toggle(this.state); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/OpenGuiButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.gui.FontRenderer; 7 | import net.minecraft.client.renderer.GlStateManager; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import java.lang.Class; 12 | import java.lang.IllegalAccessException; 13 | import java.lang.InstantiationException; 14 | 15 | import family_fun_pack.FamilyFunPack; 16 | import family_fun_pack.gui.MainGui; 17 | import family_fun_pack.gui.interfaces.RightPanel; 18 | import family_fun_pack.modules.Module; 19 | 20 | /* Button used to open a GUI */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class OpenGuiButton extends ActionButton { 24 | 25 | public static final int BACKGROUND = (216 << 24); 26 | public static final int COLOR = 0xffbbbbbb; 27 | public static final int ACTIVE_BACKGROUND = 0xffbbbbbb; 28 | public static final int ACTIVE_COLOR = 0xff000000; 29 | 30 | private final FontRenderer fontRenderer; 31 | private boolean clicked; 32 | private Class panel; // GUI to be opened 33 | private final Module dependsOn; // GUI dependence 34 | private final float scale; // Button scale 35 | 36 | public OpenGuiButton(int id, int x, int y, String text, Class panel, Module dependsOn, float scale) { 37 | super(id, x, y, 0, 0, text); 38 | this.fontRenderer = Minecraft.getMinecraft().fontRenderer; 39 | this.width = (int)((float)(this.fontRenderer.getStringWidth(this.displayString) + 4) * scale); 40 | this.height = (int)((float)(this.fontRenderer.FONT_HEIGHT + 4) * scale); 41 | this.panel = panel; 42 | this.dependsOn = dependsOn; 43 | this.clicked = false; 44 | this.scale = scale; 45 | } 46 | 47 | public OpenGuiButton(int x, int y, String text, Class panel, Module dependsOn) { 48 | this(0, x, y, text, panel, dependsOn, 1f); 49 | } 50 | 51 | public OpenGuiButton(int x, int y, String text, Class panel, Module dependsOn, float scale) { 52 | this(0, x, y, text, panel, dependsOn, scale); 53 | } 54 | 55 | public void setTarget(Class panel) { 56 | this.panel = panel; 57 | } 58 | 59 | public boolean isClicked() { 60 | return this.clicked; 61 | } 62 | 63 | public void resetState() { 64 | this.clicked = false; 65 | } 66 | 67 | public void setClicked() { 68 | this.clicked = true; 69 | } 70 | 71 | public Class getPanel() { 72 | return this.panel; 73 | } 74 | 75 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 76 | if(this.visible) { 77 | int background = (this.clicked ? OpenGuiButton.ACTIVE_BACKGROUND : OpenGuiButton.BACKGROUND); 78 | int border = (this.clicked ? OpenGuiButton.ACTIVE_COLOR : OpenGuiButton.COLOR); 79 | 80 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 81 | 82 | int width = (int)((float)this.width / this.scale); 83 | int height = (int)((float)this.height / this.scale); 84 | 85 | if(this.scale == 1f) { 86 | int x_end = this.x + width; 87 | int y_end = this.y + height; 88 | 89 | drawRect(this.x, this.y, x_end, y_end, background); 90 | drawRect(this.x, this.y, x_end, this.y + 1, border); 91 | drawRect(this.x, this.y, this.x + 1, y_end, border); 92 | drawRect(this.x, y_end - 1, x_end, y_end, border); 93 | drawRect(x_end - 1, this.y, x_end, y_end, border); 94 | this.fontRenderer.drawString(this.displayString, this.x + 2, this.y + 2, border); 95 | } else { 96 | int x = (int)((float)this.x / this.scale); 97 | int y = (int)((float)this.y / this.scale); 98 | int x_end = (int)((float)(this.x) / this.scale) + width; 99 | int y_end = (int)((float)(this.y) / this.scale) + height; 100 | 101 | GlStateManager.pushMatrix(); 102 | GlStateManager.scale(this.scale, this.scale, this.scale); 103 | drawRect(x, y, x_end, y_end, background); 104 | drawRect(x, y, x_end, y + 1, border); 105 | drawRect(x, y, x + 1, y_end, border); 106 | drawRect(x, y_end - 1, x_end, y_end, border); 107 | drawRect(x_end - 1, y, x_end, y_end, border); 108 | this.fontRenderer.drawString(this.displayString, (int)((float)(this.x + 2) / this.scale), (int)((float)(this.y + 2) / this.scale), border); 109 | GlStateManager.popMatrix(); 110 | } 111 | } 112 | } 113 | 114 | public void onClick(GuiScreen parent) { 115 | MainGui main = FamilyFunPack.getMainGui(); 116 | this.clicked = !this.clicked; 117 | if(this.clicked) { 118 | RightPanel panel = null; 119 | try { 120 | panel = this.panel.newInstance(); 121 | } catch (InstantiationException e) { 122 | throw new RuntimeException("FFP error while initializing instance of " + this.panel.toString() + ": " + e.getMessage()); 123 | } catch (IllegalAccessException e) { 124 | throw new RuntimeException("FFP can not initialize instance of " + this.panel.toString() + ": " + e.getMessage()); 125 | } 126 | panel.dependsOn(this.dependsOn); 127 | panel.setParent(parent); 128 | main.setRightPanel(panel); 129 | } else main.setRightPanel(null); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/ScrollBar.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.audio.SoundHandler; 5 | import net.minecraft.client.gui.Gui; 6 | import net.minecraft.client.gui.GuiButton; 7 | 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | @SideOnly(Side.CLIENT) 12 | public class ScrollBar extends GuiButton { 13 | 14 | static final int COLOR = 0xffbbbbbb; 15 | 16 | public int current_scroll; 17 | public boolean clicked; 18 | 19 | private int max_scroll; 20 | private final int min_y; 21 | private final int max_y; 22 | 23 | private int offset_y; 24 | 25 | public ScrollBar(int id, int x, int y, int max_scroll, int max_y) { 26 | super(id, x, y, 6, 16, null); 27 | this.max_scroll = max_scroll; 28 | this.min_y = this.y; 29 | this.max_y = max_y - this.height; 30 | this.current_scroll = 0; 31 | this.clicked = false; 32 | } 33 | 34 | // Set max scroll, reset scroll bar at start 35 | public void resetMaxScroll(int max_scroll) { 36 | this.y = this.min_y; 37 | this.current_scroll = 0; 38 | this.max_scroll = max_scroll; 39 | this.clicked = false; 40 | } 41 | 42 | // Set max scroll, set current scroll at max scroll 43 | public void resetMaxScrollAndScroll(int max_scroll) { 44 | if(this.clicked) { 45 | this.maxScrollUpdate(max_scroll); 46 | } else { 47 | this.y = this.max_y; 48 | this.max_scroll = max_scroll; 49 | this.current_scroll = max_scroll; 50 | } 51 | } 52 | 53 | // Set max scroll, keep current scroll position 54 | public void maxScrollUpdate(int max_scroll) { 55 | this.max_scroll = max_scroll; 56 | int old_y = this.y; 57 | if(max_scroll == 0) this.y = 0; 58 | else this.y = this.min_y + (int)(((float)this.current_scroll / (float)this.max_scroll) * (float)(this.max_y - this.min_y)); 59 | if(this.clicked) { 60 | this.offset_y -= (this.y - old_y); 61 | } 62 | } 63 | 64 | public void scroll(int count) { 65 | this.current_scroll += count; 66 | if(this.current_scroll < 0) this.current_scroll = 0; 67 | else if(this.current_scroll > this.max_scroll) this.current_scroll = this.max_scroll; 68 | this.y = this.min_y + (int)(((float)this.current_scroll / (float)this.max_scroll) * (float)(this.max_y - this.min_y)); 69 | this.clicked = false; 70 | } 71 | 72 | public void drawButton(Minecraft client, int mouseX, int mouseY, float partialTicks) { 73 | drawRect(this.x, this.y, this.x + this.width, this.y + this.height, ScrollBar.COLOR); 74 | } 75 | 76 | public void dragged(int mouseX, int mouseY) { 77 | this.y = mouseY - this.offset_y; 78 | if(this.y < this.min_y) this.y = this.min_y; 79 | else if(this.y > this.max_y) this.y = this.max_y; 80 | 81 | this.current_scroll = (int)(((float)(this.y - this.min_y) / (float)(this.max_y - this.min_y)) * (float)this.max_scroll); 82 | } 83 | 84 | public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { 85 | if(super.mousePressed(mc, mouseX, mouseY)) { 86 | this.clicked = true; 87 | this.offset_y = mouseY - this.y; 88 | return true; 89 | } 90 | return false; 91 | } 92 | 93 | public void mouseReleased(int mouseX, int mouseY) { 94 | this.clicked = false; 95 | } 96 | 97 | public void playPressSound(SoundHandler handler) {} 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/SliderButton.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components; 2 | 3 | import family_fun_pack.gui.components.actions.NumberAction; 4 | import family_fun_pack.gui.components.actions.NumberPumpkinAura; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.GuiScreen; 7 | import net.minecraft.client.renderer.GlStateManager; 8 | import net.minecraft.util.math.MathHelper; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | 12 | import java.awt.*; 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class SliderButton extends ActionButton { 16 | 17 | private static final int BORDER = 0xffcccccc; 18 | private boolean drag; 19 | private float max, min, number; 20 | 21 | private int index; 22 | 23 | private final NumberAction action; 24 | 25 | public SliderButton(int id, int x, int y, NumberAction action) { 26 | super(id, x, y, 32, 7, null); 27 | this.action = action; 28 | this.drag = false; 29 | } 30 | 31 | public SliderButton(int x, int y, NumberAction action) { 32 | this(0, x, y, action); 33 | } 34 | 35 | public SliderButton setIndex(int index) { 36 | this.index = index; 37 | return this; 38 | } 39 | 40 | public SliderButton setValue(int value) { 41 | this.number = value; 42 | return this; 43 | } 44 | 45 | public SliderButton setMax(int max) { 46 | this.max = max; 47 | return this; 48 | } 49 | 50 | public SliderButton setMin(int min) { 51 | this.min = min; 52 | return this; 53 | } 54 | 55 | public void reset() { 56 | this.drag = false; 57 | } 58 | 59 | public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { 60 | int x_end = this.x + this.width; 61 | int y_end = this.y + this.height; 62 | 63 | if(this.drag) this.dragged(mouseX, mouseY); 64 | 65 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 66 | this.drawString( 67 | mc.fontRenderer, 68 | String.valueOf(Math.round(number)), 69 | this.x - (mc.fontRenderer.getStringWidth(String.valueOf(Math.round(number))) + 8), 70 | this.y, 71 | Color.WHITE.getRGB()); 72 | drawRect(this.x, this.y, x_end, y_end, Color.DARK_GRAY.getRGB()); 73 | drawRect(this.x, this.y, x_end, this.y + 1, SliderButton.BORDER); 74 | drawRect(this.x, this.y, this.x + 1, y_end, SliderButton.BORDER); 75 | drawRect(this.x, y_end - 1, x_end, y_end, SliderButton.BORDER); 76 | drawRect(x_end - 1, this.y, x_end, y_end, SliderButton.BORDER); 77 | 78 | drawRect(this.x + index, this.y - 2, this.x + index + 1, y_end + 2, SliderButton.BORDER); 79 | drawRect(this.x + index - 1, this.y, this.x + index + 2, y_end, SliderButton.BORDER); 80 | 81 | if(!this.enabled) drawRect(this.x, this.y, this.x + this.width, this.y + this.height, 0x99333333); 82 | } 83 | 84 | public void dragged(int mouseX, int mouseY) { 85 | // If it works it works ¯\_(ツ)_/¯ - TODO fix 86 | int cursor = (mouseX < this.x ? this.x : (mouseX >= this.x + this.width ? this.x + this.width - 1 : mouseX)); 87 | int index = (cursor - this.x) * (64 / this.width); 88 | if (index > 32) index += (64 / this.width) - 1; 89 | index = ((index & 3) * 85) + ((((index >> 2) & 3) * 85) * 256) + (((index >> 4) * 85) * 65536) + 0xff000000; 90 | this.index = (((index & 0xff) / 85) + ((((index >> 8) & 0xff) / 85) * 4) + ((((index >> 16) & 0xff) / 85) * 16)) / (64 / this.width); 91 | // If it works it works ¯\_(ツ)_/¯ - end 92 | float value = (mouseX - (x + 5f)) * (max - min) / (width - 10f) + min; 93 | this.number = MathHelper.clamp(value, min, max); 94 | if (this.action != null) { 95 | if (this.action instanceof NumberPumpkinAura) { 96 | ((NumberPumpkinAura) this.action).setIndex(this.index); // If it works it works ¯\_(ツ)_/¯ 97 | } 98 | this.action.setNumber(Math.round(this.number)); 99 | } 100 | } 101 | 102 | public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { 103 | if (super.mousePressed(mc, mouseX, mouseY)) { 104 | this.dragged(mouseX, mouseY); 105 | this.drag = true; 106 | return true; 107 | } 108 | return false; 109 | } 110 | 111 | public void mouseReleased(int mouseX, int mouseY) { 112 | this.drag = false; 113 | } 114 | 115 | public void onClick(GuiScreen parent) { } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/ColorSearch.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.modules.SearchModule; 8 | 9 | @SideOnly(Side.CLIENT) 10 | public class ColorSearch implements NumberAction { 11 | 12 | private final SearchModule module; 13 | 14 | private final Block block; 15 | 16 | public ColorSearch(SearchModule module, Block block) { 17 | this.module = module; 18 | this.block = block; 19 | } 20 | 21 | public void setNumber(int color) { 22 | this.module.setSearchColor(this.block, color); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/NumberAction.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | /* Action of a color button */ 7 | 8 | @SideOnly(Side.CLIENT) 9 | public interface NumberAction { 10 | 11 | void setNumber(int number); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/NumberPumpkinAura.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import family_fun_pack.modules.PumpkinAuraModule; 4 | import family_fun_pack.modules.SearchModule; 5 | import net.minecraft.block.Block; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | 9 | @SideOnly(Side.CLIENT) 10 | public class NumberPumpkinAura implements NumberAction { 11 | 12 | private final PumpkinAuraModule module; 13 | 14 | private final int id; 15 | 16 | public NumberPumpkinAura(PumpkinAuraModule module, int id) { 17 | this.module = module; 18 | this.id = id; 19 | } 20 | 21 | public void setNumber(int number) { 22 | switch (id) { 23 | case 2: { 24 | module.placeRange = number; 25 | break; 26 | } 27 | case 3: { 28 | module.minDamage = number; 29 | break; 30 | } 31 | case 4: { 32 | module.maxDamage = number; 33 | break; 34 | } 35 | case 6: { 36 | module.renderColor = number; 37 | break; 38 | } 39 | } 40 | module.save(); 41 | } 42 | 43 | public void setIndex(int index) { 44 | switch (id) { 45 | case 2: { 46 | module.placeRange_index = index; 47 | break; 48 | } 49 | case 3: { 50 | module.minDamage_index = index; 51 | break; 52 | } 53 | case 4: { 54 | module.maxDamage_index = index; 55 | break; 56 | } 57 | } 58 | module.save(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/OnOffAction.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | /* Action of an OnOff button */ 7 | 8 | @SideOnly(Side.CLIENT) 9 | public interface OnOffAction { 10 | 11 | void toggle(boolean state); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/OnOffInterception.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraft.network.EnumPacketDirection; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.modules.PacketInterceptionModule; 8 | 9 | @SideOnly(Side.CLIENT) 10 | public class OnOffInterception implements OnOffAction { 11 | 12 | private final PacketInterceptionModule module; 13 | private final EnumPacketDirection direction; 14 | private final int id; 15 | 16 | public OnOffInterception(PacketInterceptionModule module, EnumPacketDirection direction, int id) { 17 | this.module = module; 18 | this.direction = direction; 19 | this.id = id; 20 | } 21 | 22 | public void toggle(boolean state) { 23 | if(state) this.module.addIntercept(this.direction, this.id); 24 | else this.module.removeIntercept(this.direction, this.id); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/OnOffPumpkinAura.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import family_fun_pack.modules.PumpkinAuraModule; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | import net.minecraftforge.fml.relauncher.SideOnly; 6 | 7 | @SideOnly(Side.CLIENT) 8 | public class OnOffPumpkinAura implements OnOffAction { 9 | 10 | private final PumpkinAuraModule module; 11 | 12 | private final int id; 13 | 14 | public OnOffPumpkinAura(final PumpkinAuraModule module, final int id) { 15 | this.module = module; 16 | this.id = id; 17 | } 18 | 19 | @Override 20 | public void toggle(boolean state) { 21 | switch (id) { 22 | case -2: { 23 | module.ignoreTerrain = state; 24 | break; 25 | } 26 | case -1: { 27 | module.antiTotem = state; 28 | break; 29 | } 30 | case 0: { 31 | module.autoSwitch = state; 32 | break; 33 | } 34 | case 1: { 35 | module.sequential = state; 36 | break; 37 | } 38 | case 5: { 39 | module.render = state; 40 | break; 41 | } 42 | case 7: { 43 | module.bedwars = state; 44 | break; 45 | } 46 | } 47 | module.save(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/OnOffSearch.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.gui.components.ColorButton; 8 | import family_fun_pack.gui.components.OnOffButton; 9 | import family_fun_pack.modules.SearchModule; 10 | 11 | @SideOnly(Side.CLIENT) 12 | public class OnOffSearch implements OnOffAction { 13 | 14 | private final SearchModule module; 15 | private final Block block; 16 | 17 | private final OnOffButton tracer; 18 | private final ColorButton color; 19 | 20 | public OnOffSearch(Block block, SearchModule module, OnOffButton tracer, ColorButton color) { 21 | this.block = block; 22 | this.module = module; 23 | this.tracer = tracer; 24 | this.color = color; 25 | } 26 | 27 | public void toggle(boolean state) { 28 | this.tracer.enabled = state; 29 | this.color.enabled = state; 30 | module.setSearchState(this.block, state); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/components/actions/OnOffTracer.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.components.actions; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.modules.SearchModule; 8 | 9 | @SideOnly(Side.CLIENT) 10 | public class OnOffTracer implements OnOffAction { 11 | 12 | private final SearchModule module; 13 | private final Block block; 14 | 15 | public OnOffTracer(Block block, SearchModule module) { 16 | this.block = block; 17 | this.module = module; 18 | } 19 | 20 | public void toggle(boolean state) { 21 | module.setTracerState(this.block, state); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/interfaces/PreviewGui.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.interfaces; 2 | 3 | import net.minecraft.client.gui.Gui; 4 | import net.minecraft.client.gui.GuiScreen; 5 | import net.minecraft.client.renderer.GlStateManager; 6 | import net.minecraft.client.renderer.RenderHelper; 7 | import net.minecraft.util.ResourceLocation; 8 | import net.minecraft.nbt.NBTBase; 9 | import net.minecraft.nbt.NBTTagCompound; 10 | import net.minecraft.nbt.NBTTagList; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraft.inventory.InventoryBasic; 13 | import net.minecraft.inventory.Slot; 14 | import net.minecraftforge.fml.relauncher.SideOnly; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | 17 | import java.io.IOException; 18 | import java.util.List; 19 | import java.util.LinkedList; 20 | 21 | import org.lwjgl.input.Keyboard; 22 | 23 | import family_fun_pack.FamilyFunPack; 24 | import family_fun_pack.gui.MainGui; 25 | import family_fun_pack.gui.components.GenericButton; 26 | import family_fun_pack.nbt.SpecialTagCompound; 27 | 28 | /* Shulker peek GUI */ 29 | 30 | @SideOnly(Side.CLIENT) 31 | public class PreviewGui extends RightPanel { 32 | 33 | private static final ResourceLocation GUI_TEXTURE = new ResourceLocation(FamilyFunPack.MODID, "textures/gui/preview.png"); 34 | 35 | private static final int INNER_BORDER = PreviewGui.INNER_BORDER; 36 | 37 | private static final int guiWidth = 176; 38 | private static final int guiHeight = 80; 39 | 40 | private final int x; 41 | private final int y; 42 | private final int x_end; 43 | private final int y_end; 44 | 45 | private final InventoryBasic inventory; 46 | private final List slots; 47 | 48 | private final boolean hasParent; 49 | 50 | public PreviewGui(NBTTagList list) { 51 | this(list, true); 52 | } 53 | 54 | public PreviewGui(NBTTagList list, boolean hasParent) { 55 | this.hasParent = hasParent; 56 | 57 | this.inventory = new InventoryBasic(null, false, 27); 58 | this.slots = new LinkedList(); 59 | for(NBTBase i_base : list) { 60 | NBTTagCompound i = (NBTTagCompound) i_base; 61 | ItemStack stack = new ItemStack(i); 62 | if(!stack.isEmpty()) { 63 | int index = i.getByte("Slot") & 0xFF; 64 | if(i.getShort("Damage") < 0) { 65 | stack.setTagCompound(new SpecialTagCompound(stack.getTagCompound(), i.getShort("Damage"))); 66 | } 67 | this.inventory.setInventorySlotContents(index, stack); 68 | this.slots.add(new Slot(this.inventory, index, 8 + (index % 9) * 18, 26 + (index / 9) * 18)); 69 | } 70 | } 71 | 72 | if(! this.hasParent) { 73 | this.x = (this.width - PreviewGui.guiWidth) / 2; 74 | this.y = (this.height - PreviewGui.guiHeight) / 2; 75 | } else { 76 | this.x = (this.width - MainGui.guiWidth - 12 - PreviewGui.guiWidth) / 2 + MainGui.guiWidth + 12; 77 | this.y = (MainGui.guiHeight - PreviewGui.guiHeight) / 2 + 12; 78 | 79 | this.buttonList.add(new GenericButton(0, this.x + 3, this.y + 3, "Back") { 80 | public void onClick(GuiScreen parent) { 81 | ((PreviewGui) parent).close(); 82 | } 83 | }); 84 | } 85 | 86 | this.x_end = this.x + PreviewGui.guiWidth; 87 | this.y_end = this.y + PreviewGui.guiHeight; 88 | 89 | for(Slot s : this.slots) { 90 | s.xPos += this.x; 91 | s.yPos += this.y; 92 | } 93 | } 94 | 95 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 96 | 97 | if(this.hasParent) { 98 | // Gui background 99 | Gui.drawRect(this.x, this.y, this.x_end, this.y_end, MainGui.BACKGROUND_COLOR); // GUI background 100 | 101 | // borders 102 | Gui.drawRect(this.x, this.y, this.x_end, this.y + 1, PreviewGui.INNER_BORDER); 103 | Gui.drawRect(this.x, this.y, this.x + 1, this.y_end, PreviewGui.INNER_BORDER); 104 | Gui.drawRect(this.x_end - 1, this.y, this.x_end, this.y_end, PreviewGui.INNER_BORDER); 105 | Gui.drawRect(this.x, this.y_end - 1, this.x_end, this.y_end, PreviewGui.INNER_BORDER); 106 | } 107 | 108 | // items background 109 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 110 | this.mc.getTextureManager().bindTexture(PreviewGui.GUI_TEXTURE); 111 | drawTexturedModalRect(this.x, this.y + 18, 0, 0, PreviewGui.guiWidth, PreviewGui.guiHeight); 112 | 113 | // Draw items 114 | RenderHelper.enableGUIStandardItemLighting(); 115 | GlStateManager.enableDepth(); 116 | for(Slot s : this.slots) { 117 | this.itemRender.renderItemAndEffectIntoGUI(this.mc.player, s.getStack(), s.xPos, s.yPos); 118 | this.itemRender.renderItemOverlayIntoGUI(this.fontRenderer, s.getStack(), s.xPos, s.yPos, null); 119 | } 120 | 121 | // Draw button 122 | super.drawScreen(mouseX, mouseY, partialTicks); 123 | 124 | // Draw tooltip 125 | if(mouseX >= this.x + 8 && mouseY >= this.y + 26) { 126 | int x = (mouseX - this.x - 8) / 18; 127 | int y = (mouseY - this.y - 26) / 18; 128 | if(x >= 0 && x < 9 && y >= 0 && y < 3) { 129 | ItemStack stack = this.inventory.getStackInSlot(y * 9 + x); 130 | if(! stack.isEmpty()) { 131 | this.renderToolTip(stack, mouseX, mouseY); 132 | } 133 | } 134 | } 135 | } 136 | 137 | public void keyTyped(char typedChar, int keyCode) throws IOException { 138 | if(keyCode == Keyboard.KEY_ESCAPE) { 139 | this.mc.displayGuiScreen(null); 140 | if (this.mc.currentScreen == null) { 141 | this.mc.setIngameFocus(); 142 | } 143 | } 144 | } 145 | 146 | public void close() { 147 | this.transition((RightPanel) this.parent); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/interfaces/RightPanel.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.interfaces; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiButton; 5 | import net.minecraft.client.gui.GuiScreen; 6 | import net.minecraft.client.gui.ScaledResolution; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import java.io.IOException; 11 | 12 | import family_fun_pack.FamilyFunPack; 13 | import family_fun_pack.gui.components.ActionButton; 14 | import family_fun_pack.modules.Module; 15 | 16 | /* Right panel, special module configuration GUI displayed next to Main GUI */ 17 | 18 | @SideOnly(Side.CLIENT) 19 | public abstract class RightPanel extends GuiScreen { 20 | 21 | protected Module dependence; // Module dependence 22 | 23 | protected GuiScreen parent; // GUI parent that generated this one 24 | 25 | public RightPanel() { 26 | ScaledResolution scale = new ScaledResolution(Minecraft.getMinecraft()); 27 | this.setWorldAndResolution(Minecraft.getMinecraft(), scale.getScaledWidth(), scale.getScaledHeight()); 28 | this.parent = null; 29 | this.dependence = null; 30 | } 31 | 32 | public void setParent(GuiScreen parent) { 33 | this.parent = parent; 34 | } 35 | 36 | public void transition(RightPanel next) { 37 | FamilyFunPack.getMainGui().setRightPanel(next); 38 | } 39 | 40 | public void dependsOn(Module dependence) { 41 | this.dependence = dependence; 42 | } 43 | 44 | protected void actionPerformed(GuiButton btn) throws IOException { 45 | if(btn instanceof ActionButton) { 46 | ((ActionButton) btn).onClick(this); 47 | } 48 | } 49 | 50 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 51 | super.mouseClicked(mouseX, mouseY, mouseButton); 52 | } 53 | 54 | public void mouseReleased(int mouseX, int mouseY, int state) { 55 | super.mouseReleased(mouseX, mouseY, state); 56 | } 57 | 58 | public void mouseWheel(int wheel) { 59 | } 60 | 61 | public void keyTyped(char keyChar, int keyCode) throws IOException { 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/gui/overlay/OverlayGui.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.gui.overlay; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.gui.FontRenderer; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | import net.minecraftforge.client.event.RenderGameOverlayEvent; 8 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import java.util.Map; 13 | import java.util.HashMap; 14 | import java.util.concurrent.locks.ReadWriteLock; 15 | import java.util.concurrent.locks.ReentrantReadWriteLock; 16 | 17 | import family_fun_pack.gui.MainGui; 18 | 19 | /* In game overlay, just labels of current states */ 20 | 21 | @SideOnly(Side.CLIENT) 22 | public class OverlayGui extends Gui { 23 | 24 | private static final int BORDER = 0xff000000; 25 | private static final float OVERLAY_SCALE = 0.7f; 26 | private static int counter = 0; 27 | 28 | private final FontRenderer fontRenderer; 29 | 30 | private final Map labels; 31 | private final ReadWriteLock labels_lock; 32 | 33 | private final int height; 34 | 35 | public OverlayGui() { 36 | this.zLevel = 1; 37 | this.fontRenderer = Minecraft.getMinecraft().fontRenderer; 38 | this.labels = new HashMap(); 39 | this.labels_lock = new ReentrantReadWriteLock(); 40 | this.height = this.fontRenderer.FONT_HEIGHT + 4; 41 | } 42 | 43 | public void drawOverlay() { 44 | int y = 4; 45 | this.labels_lock.readLock().lock(); 46 | for(String l : this.labels.values()) { 47 | int width = this.fontRenderer.getStringWidth(l) + 4; 48 | int x1 = (int)(4f / OverlayGui.OVERLAY_SCALE); 49 | int y1 = (int)((float)y / OverlayGui.OVERLAY_SCALE); 50 | int x_end = (int)(4f / OverlayGui.OVERLAY_SCALE) + width; 51 | int y_end = (int)((float)y / OverlayGui.OVERLAY_SCALE) + this.height; 52 | 53 | GlStateManager.pushMatrix(); 54 | GlStateManager.scale(OverlayGui.OVERLAY_SCALE, OverlayGui.OVERLAY_SCALE, OverlayGui.OVERLAY_SCALE); 55 | 56 | drawRect(x1, y1, x_end, y_end, MainGui.BACKGROUND_COLOR); 57 | drawRect(x1, y1, x_end, y1 + 1, OverlayGui.BORDER); 58 | drawRect(x1, y1, x1 + 1, y_end, OverlayGui.BORDER); 59 | drawRect(x1, y_end - 1, x_end, y_end, OverlayGui.BORDER); 60 | drawRect(x_end - 1, y1, x_end, y_end, OverlayGui.BORDER); 61 | this.drawString(this.fontRenderer, l, x1 + 2, y1 + 2, 0xffffffff); 62 | 63 | GlStateManager.popMatrix(); 64 | 65 | y = y_end + 2; 66 | } 67 | this.labels_lock.readLock().unlock(); 68 | } 69 | 70 | @SubscribeEvent 71 | public void drawOverlay(RenderGameOverlayEvent.Text event) { 72 | this.drawOverlay(); 73 | } 74 | 75 | public int addLabel(String label) { 76 | OverlayGui.counter++; 77 | if(OverlayGui.counter < 0) OverlayGui.counter = 0; 78 | int id = OverlayGui.counter; 79 | this.labels_lock.writeLock().lock(); 80 | this.labels.put(id, label); 81 | this.labels_lock.writeLock().unlock(); 82 | return id; 83 | } 84 | 85 | public void removeLabel(int id) { 86 | this.labels_lock.writeLock().lock(); 87 | this.labels.remove(id); 88 | this.labels_lock.writeLock().unlock(); 89 | } 90 | 91 | public void modifyLabel(int id, String label) { 92 | this.labels_lock.writeLock().lock(); 93 | this.labels.put(id, label); 94 | this.labels_lock.writeLock().unlock(); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/key/KeyListener.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.key; 2 | 3 | import family_fun_pack.modules.PumpkinAuraModule; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.settings.KeyBinding; 6 | import net.minecraftforge.fml.client.registry.ClientRegistry; 7 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 8 | import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import org.lwjgl.input.Keyboard; 13 | 14 | import java.util.List; 15 | import java.util.LinkedList; 16 | 17 | import family_fun_pack.FamilyFunPack; 18 | import family_fun_pack.gui.MainGui; 19 | import family_fun_pack.modules.Module; 20 | 21 | /* Key listener */ 22 | 23 | @SideOnly(Side.CLIENT) 24 | public class KeyListener { 25 | 26 | private final KeyBinding gui_key; 27 | private MainGui gui; 28 | 29 | private final List keys; 30 | private final List actions; 31 | 32 | public KeyListener() { 33 | this.gui_key = new KeyBinding("Open GUI", Keyboard.KEY_BACKSLASH, FamilyFunPack.NAME); 34 | ClientRegistry.registerKeyBinding(this.gui_key); 35 | this.gui = null; 36 | this.keys = new LinkedList(); 37 | this.actions = new LinkedList(); 38 | } 39 | 40 | public void setGui(MainGui gui) { 41 | this.gui = gui; 42 | this.gui.setExitKey(this.gui_key.getKeyCode()); 43 | } 44 | 45 | public void addModuleKey(int key, Module module) { 46 | KeyBinding bind = new KeyBinding(module.getLabel(), key, FamilyFunPack.NAME); 47 | ClientRegistry.registerKeyBinding(bind); 48 | this.keys.add(bind); 49 | this.actions.add(module); 50 | } 51 | 52 | @SubscribeEvent 53 | public void onKey(KeyInputEvent event) { 54 | if(this.gui_key.isPressed()) { 55 | Minecraft mc = Minecraft.getMinecraft(); 56 | if(mc.currentScreen != this.gui) { 57 | mc.displayGuiScreen(this.gui); 58 | } 59 | } else { 60 | int length = this.keys.size(); 61 | for(int i = 0; i < length; i ++) { 62 | if(this.keys.get(i).isPressed()) { 63 | Module m = this.actions.get(i); 64 | m.toggle(); 65 | m.save_state(FamilyFunPack.getModules().getConfiguration()); 66 | FamilyFunPack.getModules().getConfiguration().save(); 67 | return; 68 | } 69 | } 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/BookFormatModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiScreenBook; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraftforge.client.event.GuiOpenEvent; 7 | import net.minecraftforge.common.MinecraftForge; 8 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import java.lang.Class; 13 | import java.lang.IllegalAccessException; 14 | import java.lang.NoSuchFieldException; 15 | import java.lang.reflect.Field; 16 | 17 | import family_fun_pack.gui.interfaces.BookEditingGui; 18 | 19 | /* Special book editing gui allowing text formatting */ 20 | 21 | @SideOnly(Side.CLIENT) 22 | public class BookFormatModule extends Module { 23 | 24 | private Field book_edited; 25 | private Field book_signed; 26 | 27 | public BookFormatModule() { 28 | super("Book Format", "Special book editing gui"); 29 | 30 | // Get access to book field of GuiScreenBook 31 | Class screenBook = GuiScreenBook.class; 32 | try { 33 | this.book_edited = screenBook.getDeclaredField("field_146474_h"); 34 | } catch (NoSuchFieldException e) { 35 | try { 36 | this.book_edited = screenBook.getDeclaredField("book"); 37 | } catch (NoSuchFieldException e2) { 38 | throw new RuntimeException("FamilyFunPack error: no such field " + e2.getMessage() + " in class GuiScreenBook"); 39 | } 40 | } 41 | this.book_edited.setAccessible(true); 42 | 43 | // Get access to bookIsUnsigned field of GuiScreenBook 44 | try { 45 | this.book_signed = screenBook.getDeclaredField("field_146475_i"); 46 | } catch (NoSuchFieldException e) { 47 | try { 48 | this.book_signed = screenBook.getDeclaredField("bookIsUnsigned"); 49 | } catch (NoSuchFieldException e2) { 50 | throw new RuntimeException("FamilyFunPack error: no such field " + e2.getMessage() + " in class GuiScreenBook"); 51 | } 52 | } 53 | this.book_signed.setAccessible(true); 54 | } 55 | 56 | protected void enable() { 57 | MinecraftForge.EVENT_BUS.register(this); 58 | } 59 | 60 | protected void disable() { 61 | MinecraftForge.EVENT_BUS.unregister(this); 62 | } 63 | 64 | public boolean displayInGui() { 65 | return false; 66 | } 67 | 68 | @SubscribeEvent 69 | public void onGuiOpened(GuiOpenEvent event) { 70 | if(event.getGui() instanceof GuiScreenBook) { 71 | GuiScreenBook gui = (GuiScreenBook) event.getGui(); 72 | 73 | if(gui instanceof BookEditingGui) return; 74 | 75 | try { 76 | if((boolean) this.book_signed.get(gui)) { // Book is editable 77 | ItemStack book = (ItemStack) this.book_edited.get(gui); 78 | event.setGui(new BookEditingGui(Minecraft.getMinecraft().player, book)); 79 | } 80 | } catch (IllegalAccessException e) { 81 | throw new RuntimeException("FamilyFunPack error: " + e.getMessage()); 82 | } 83 | } 84 | } 85 | 86 | public boolean defaultState() { 87 | return true; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/BowBombModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.init.Items; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.client.CPacketPlayer; 8 | import net.minecraft.network.play.client.CPacketPlayerDigging; 9 | import net.minecraft.network.play.client.CPacketEntityAction; 10 | import net.minecraft.util.EnumHand; 11 | import net.minecraftforge.fml.relauncher.SideOnly; 12 | import net.minecraftforge.fml.relauncher.Side; 13 | 14 | import io.netty.buffer.ByteBuf; 15 | 16 | import family_fun_pack.FamilyFunPack; 17 | import family_fun_pack.network.PacketListener; 18 | 19 | /* Bow bomb hack - credits goes to Bjot for the intelligence */ 20 | 21 | @SideOnly(Side.CLIENT) 22 | public class BowBombModule extends Module implements PacketListener { 23 | 24 | private static final int REPEAT_COUNT = 125; 25 | 26 | public BowBombModule() { 27 | super("Bow Bomb", "Arrow goes brrrr"); 28 | } 29 | 30 | protected void enable() { 31 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, 20); 32 | } 33 | 34 | protected void disable() { 35 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 20); 36 | } 37 | 38 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 39 | CPacketPlayerDigging dig = (CPacketPlayerDigging) packet; 40 | 41 | Minecraft mc = Minecraft.getMinecraft(); 42 | if(dig.getAction() == CPacketPlayerDigging.Action.RELEASE_USE_ITEM && (mc.player.getHeldItem(EnumHand.MAIN_HAND).getItem() == Items.BOW || mc.player.getHeldItem(EnumHand.OFF_HAND).getItem() == Items.BOW)) { 43 | 44 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SPRINTING)); 45 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.01d, mc.player.posZ, false)); 46 | 47 | for(int i = 0; i < BowBombModule.REPEAT_COUNT; i ++) { 48 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY, mc.player.posZ, true)); 49 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.01d, mc.player.posZ, false)); 50 | } 51 | 52 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX, mc.player.posY, mc.player.posZ, mc.player.rotationYaw, 90f, true)); 53 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SPRINTING)); 54 | } 55 | 56 | return packet; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/CommandsModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraftforge.client.event.ClientChatEvent; 5 | import net.minecraftforge.common.MinecraftForge; 6 | import net.minecraftforge.common.config.Configuration; 7 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import family_fun_pack.FamilyFunPack; 12 | import family_fun_pack.commands.Command; 13 | import family_fun_pack.commands.Commands; 14 | 15 | /* Get commands from chat & find associated FFP command */ 16 | 17 | @SideOnly(Side.CLIENT) 18 | public class CommandsModule extends Module { 19 | 20 | public static String ESCAPE_CHARACTER = "."; 21 | 22 | private static Commands commands; 23 | 24 | public CommandsModule() { 25 | super("FFP Commands", "Enable Family Fun Pack commands"); 26 | commands = new Commands(); 27 | } 28 | 29 | public Command getCommand(String name) { 30 | return commands.getCommand(name); 31 | } 32 | 33 | protected void enable() { 34 | MinecraftForge.EVENT_BUS.register(this); 35 | } 36 | 37 | protected void disable() { 38 | MinecraftForge.EVENT_BUS.unregister(this); 39 | } 40 | 41 | public void onDisconnect() { 42 | for(Command c : commands.getCommands()) { 43 | c.onDisconnect(); 44 | } 45 | } 46 | 47 | public boolean displayInGui() { 48 | return false; 49 | } 50 | 51 | public void save(Configuration configuration) { 52 | configuration.get(this.name, "escape", ".").set(CommandsModule.ESCAPE_CHARACTER); 53 | super.save(configuration); 54 | } 55 | 56 | public void load(Configuration configuration) { 57 | CommandsModule.ESCAPE_CHARACTER = configuration.get(this.name, "escape", ".").getString().substring(0, 1); 58 | super.load(configuration); 59 | } 60 | 61 | @SubscribeEvent 62 | public void onChat(ClientChatEvent event) { 63 | String message = event.getMessage(); 64 | if(message.startsWith(CommandsModule.ESCAPE_CHARACTER) && this.handleCommand(message.substring(1))) { 65 | event.setCanceled(true); 66 | Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(message); 67 | } 68 | } 69 | 70 | public boolean handleCommand(String command) { 71 | String[] args = command.split(" +"); 72 | if (args.length == 0) return false; 73 | 74 | Command cmd = commands.getCommand(args[0]); 75 | if (cmd == null) return false; 76 | 77 | final String lines = cmd.execute(args); 78 | if(lines != null) { 79 | for (String line : lines.split("\\r?\\n")) { 80 | FamilyFunPack.printMessage(line); 81 | } 82 | } 83 | 84 | return true; 85 | } 86 | 87 | public boolean defaultState() { 88 | return true; 89 | } 90 | 91 | public static Commands getCommands() { 92 | return commands; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/IgnoreModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.server.SPacketChat; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import io.netty.buffer.ByteBuf; 12 | 13 | import java.util.UUID; 14 | 15 | import family_fun_pack.FamilyFunPack; 16 | import family_fun_pack.network.PacketListener; 17 | 18 | /* Client-side player ignore - persistent, not like 9b current /ignore */ 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class IgnoreModule extends AbstractPlayersRegister implements PacketListener { 22 | 23 | public IgnoreModule() { 24 | super("Ignore Players", "Client-side /ignore", "ignore"); 25 | } 26 | 27 | protected void enable() { 28 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 15); 29 | } 30 | 31 | protected void disable() { 32 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 15); 33 | } 34 | 35 | public boolean addUUID(UUID uuid) { 36 | this.toggle(true); // Enable module when at least one player is to be ignored 37 | return super.addUUID(uuid); 38 | } 39 | 40 | public boolean delUUID(UUID uuid) { 41 | boolean flag = super.delUUID(uuid); 42 | this.uuids_lock.readLock().lock(); 43 | if(this.uuids.size() == 0) this.toggle(false); // Disable module when empty 44 | this.uuids_lock.readLock().unlock(); 45 | return flag; 46 | } 47 | 48 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 49 | SPacketChat chat = (SPacketChat) packet; 50 | 51 | GameProfile sender = StalkModule.getSender(chat.getChatComponent()); 52 | if(sender != null) { 53 | this.uuids_lock.readLock().lock(); 54 | boolean flag = this.uuids.contains(sender.getId()); 55 | this.uuids_lock.readLock().unlock(); 56 | 57 | if(flag) return null; 58 | } 59 | 60 | return packet; 61 | } 62 | 63 | public boolean displayInGui() { 64 | return false; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/Module.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraftforge.common.config.Configuration; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import family_fun_pack.gui.MainGuiComponent; 8 | import family_fun_pack.gui.components.ActionButton; 9 | import family_fun_pack.gui.components.OnOffButton; 10 | import family_fun_pack.gui.components.actions.OnOffAction; 11 | 12 | /* An abstract Module */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public abstract class Module implements OnOffAction, MainGuiComponent { 16 | 17 | private boolean enabled; 18 | 19 | protected String name; 20 | protected String description; 21 | 22 | public Module(String name, String description) { 23 | this.name = name; 24 | this.description = description; 25 | this.enabled = false; 26 | } 27 | 28 | /* On Module enabled */ 29 | protected abstract void enable(); 30 | 31 | /* On Module disabled */ 32 | protected abstract void disable(); 33 | 34 | public void toggle() { 35 | this.toggle(! this.enabled); 36 | } 37 | 38 | public void toggle(boolean state) { 39 | if(state) { 40 | if(!this.enabled) { 41 | this.enable(); 42 | this.enabled = true; 43 | } 44 | } else { 45 | if(this.enabled) { 46 | this.disable(); 47 | this.enabled = false; 48 | } 49 | } 50 | } 51 | 52 | /* Is the Module enabled by default (first use) */ 53 | public boolean defaultState() { 54 | return false; 55 | } 56 | 57 | /* Display this module in Gui */ 58 | public boolean displayInGui() { 59 | return true; 60 | } 61 | 62 | /* Save basic Module state (enable / disabled) */ 63 | public void save_state(Configuration configuration) { 64 | configuration.get(this.name, "state", false).set(this.isEnabled()); 65 | } 66 | 67 | /* Save all Module configurations */ 68 | public void save(Configuration configuration) { 69 | this.save_state(configuration); 70 | } 71 | 72 | /* Load all Module configuration */ 73 | public void load(Configuration configuration) { 74 | boolean state = configuration.get(this.name, "state", this.defaultState()).getBoolean(); 75 | this.toggle(state); 76 | } 77 | 78 | /* Called when disconnecting from server */ 79 | public void onDisconnect() {} 80 | 81 | public boolean isEnabled() { 82 | return this.enabled; 83 | } 84 | 85 | public String getLabel() { 86 | return this.name; 87 | } 88 | 89 | /* ActionButton to be displayed on gui next to Module label */ 90 | public ActionButton getAction() { 91 | OnOffButton ret = new OnOffButton(0, 0, this); 92 | ret.setState(this.isEnabled()); 93 | return ret; 94 | } 95 | 96 | // Get dependent GuiComponent, i.e components used to open the configuration GUI associated to this Module 97 | public MainGuiComponent getChild() { 98 | return null; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/Modules.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraftforge.common.config.Configuration; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import java.io.File; 8 | import java.util.List; 9 | import java.util.ArrayList; 10 | 11 | /* All Modules record */ 12 | 13 | @SideOnly(Side.CLIENT) 14 | public class Modules { 15 | 16 | private final List modules; 17 | 18 | private final Configuration configuration; 19 | 20 | public Modules(File configuration_file) { 21 | 22 | this.configuration = new Configuration(configuration_file); 23 | 24 | this.modules = new ArrayList(); 25 | this.modules.add(new BookFormatModule()); 26 | this.modules.add(new CommandsModule()); 27 | this.modules.add(new IgnoreModule()); 28 | this.modules.add(new PacketInterceptionModule()); 29 | this.modules.add(new PigPOVModule()); 30 | this.modules.add(new PortalInvulnerabilityModule()); 31 | this.modules.add(new PumpkinAuraModule()); 32 | this.modules.add(new SearchModule()); 33 | this.modules.add(new NoCloseModule()); 34 | this.modules.add(new StalkModule()); 35 | this.modules.add(new TraceModule()); 36 | this.modules.add(new TrueDurabilityModule()); 37 | this.modules.add(new UndeadModule()); 38 | this.modules.add(new BowBombModule()); 39 | this.load(); 40 | } 41 | 42 | public List getModules() { 43 | return this.modules; 44 | } 45 | 46 | public void onDisconnect() { 47 | for(Module i : this.modules) { 48 | i.onDisconnect(); 49 | } 50 | } 51 | 52 | public Configuration getConfiguration() { 53 | return this.configuration; 54 | } 55 | 56 | public Module getByClass(Class clazz) { 57 | for (Module m : this.modules) { 58 | if (m.getClass() == clazz) return m; 59 | } 60 | return null; 61 | } 62 | 63 | private void load() { 64 | for(Module i : this.modules) { 65 | i.load(this.configuration); 66 | } 67 | } 68 | 69 | public void save() { 70 | for(Module i : this.modules) { 71 | i.save(this.configuration); 72 | } 73 | this.configuration.save(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/NoCloseModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.gui.GuiScreen; 4 | import net.minecraft.client.gui.inventory.GuiContainer; 5 | import net.minecraft.client.renderer.InventoryEffectRenderer; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.Packet; 8 | import net.minecraft.network.play.client.CPacketCloseWindow; 9 | import net.minecraftforge.client.event.GuiOpenEvent; 10 | import net.minecraftforge.common.MinecraftForge; 11 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 12 | import net.minecraftforge.fml.relauncher.SideOnly; 13 | import net.minecraftforge.fml.relauncher.Side; 14 | 15 | import io.netty.buffer.ByteBuf; 16 | 17 | import family_fun_pack.FamilyFunPack; 18 | import family_fun_pack.network.PacketListener; 19 | 20 | /* Silent close, keep containers open and access them with the inventory key bind */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class NoCloseModule extends Module implements PacketListener { 24 | 25 | private GuiContainer last_gui; 26 | 27 | public NoCloseModule() { 28 | super("Silent Close", "Don't tell the server when closing container, be able to re-open it"); 29 | this.last_gui = null; 30 | } 31 | 32 | protected void enable() { 33 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, 8); 34 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 18); 35 | MinecraftForge.EVENT_BUS.register(this); 36 | } 37 | 38 | protected void disable() { 39 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 8); 40 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 18); 41 | MinecraftForge.EVENT_BUS.unregister(this); 42 | if(this.last_gui != null) { 43 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketCloseWindow(this.last_gui.inventorySlots.windowId)); 44 | this.last_gui = null; 45 | } 46 | } 47 | 48 | public void onDisconnect() { 49 | this.last_gui = null; 50 | } 51 | 52 | @SubscribeEvent 53 | public void onGuiOpened(GuiOpenEvent event) { 54 | GuiScreen opened = event.getGui(); 55 | if(opened instanceof InventoryEffectRenderer) { 56 | if(this.last_gui != null) { 57 | event.setGui(this.last_gui); 58 | } 59 | } else if(opened instanceof GuiContainer) { 60 | this.last_gui = (GuiContainer) opened; 61 | } 62 | } 63 | 64 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 65 | if(direction == EnumPacketDirection.CLIENTBOUND) { 66 | FamilyFunPack.printMessage("Container closed by server"); 67 | this.last_gui = null; 68 | return packet; 69 | } 70 | return null; 71 | } 72 | 73 | public int getWindowId() { 74 | if(this.last_gui != null) return this.last_gui.inventorySlots.windowId; 75 | return -1; 76 | } 77 | 78 | public GuiScreen getOpenedContainer() { 79 | return this.last_gui; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/PigPOVModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.renderer.entity.RenderPig; 5 | import net.minecraft.entity.passive.EntityPig; 6 | import net.minecraftforge.common.config.Configuration; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.render.NoRenderPig; 11 | 12 | /* Lower player height, be able to see when travelling 1 by 1 tunnels on pig */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class PigPOVModule extends Module { 16 | 17 | public PigPOVModule() { 18 | super("Pig POV", "Pig Point Of View"); 19 | } 20 | 21 | protected void enable() { 22 | Minecraft mc = Minecraft.getMinecraft(); 23 | mc.player.eyeHeight = 0.6f; 24 | mc.getRenderManager().entityRenderMap.put(EntityPig.class, new NoRenderPig(mc.getRenderManager(), mc)); 25 | } 26 | 27 | protected void disable() { 28 | Minecraft mc = Minecraft.getMinecraft(); 29 | mc.player.eyeHeight = mc.player.getDefaultEyeHeight(); 30 | mc.getRenderManager().entityRenderMap.put(EntityPig.class, new RenderPig(mc.getRenderManager())); 31 | } 32 | 33 | public void save(Configuration configuration) {} 34 | 35 | public void load(Configuration configuration) {} 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/PortalInvulnerabilityModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.network.EnumPacketDirection; 5 | import net.minecraft.network.Packet; 6 | import net.minecraft.network.play.client.CPacketConfirmTeleport; 7 | import net.minecraft.network.play.server.SPacketPlayerPosLook; 8 | import net.minecraft.network.play.server.SPacketRespawn; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import io.netty.buffer.ByteBuf; 13 | 14 | import family_fun_pack.FamilyFunPack; 15 | import family_fun_pack.network.NetworkHandler; 16 | import family_fun_pack.network.PacketListener; 17 | 18 | import java.util.Set; 19 | 20 | /* Stay invulnerable after going through portals, ignore facing direction reset from server 21 | * You won't be able to move though */ 22 | 23 | @SideOnly(Side.CLIENT) 24 | public class PortalInvulnerabilityModule extends Module implements PacketListener { 25 | 26 | private boolean currently_invulnerable; 27 | private int label_id; 28 | private int last_teleport_id; 29 | 30 | public PortalInvulnerabilityModule() { 31 | super("Portal God Mode", "Be invulnerable after going through a portal"); 32 | this.currently_invulnerable = false; 33 | this.last_teleport_id = -1; 34 | this.label_id = -1; 35 | } 36 | 37 | public void onDisconnect() { 38 | this.currently_invulnerable = false; 39 | this.last_teleport_id = -1; 40 | if(this.label_id >= 0) FamilyFunPack.getOverlay().removeLabel(this.label_id); 41 | this.label_id = -1; 42 | } 43 | 44 | protected void enable() { 45 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 47, 53); 46 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.SERVERBOUND, this, 0); 47 | } 48 | 49 | protected void disable() { 50 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 47, 53); 51 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.SERVERBOUND, this, 0); 52 | if(this.last_teleport_id != -1) { 53 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketConfirmTeleport(this.last_teleport_id)); 54 | } 55 | this.onDisconnect(); 56 | } 57 | 58 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 59 | if(direction == EnumPacketDirection.CLIENTBOUND) { 60 | switch(id) { 61 | case 47: // SPacketPlayerPosLook 62 | { 63 | if(this.currently_invulnerable) { 64 | if(! Minecraft.getMinecraft().player.isRiding()) { // don't disturb while riding 65 | SPacketPlayerPosLook old = (SPacketPlayerPosLook) packet; 66 | Set flags = old.getFlags(); 67 | flags.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); 68 | flags.add(SPacketPlayerPosLook.EnumFlags.X_ROT); 69 | this.last_teleport_id = old.getTeleportId(); 70 | return new SPacketPlayerPosLook(old.getX(), old.getY(), old.getZ(), 0, 0, flags, this.last_teleport_id); 71 | } 72 | return null; 73 | } 74 | } 75 | break; 76 | case 53: // SPacketRespawn 77 | { 78 | if(! this.currently_invulnerable) { 79 | SPacketRespawn respawn = (SPacketRespawn) packet; 80 | this.currently_invulnerable = (respawn.getDimensionID() != Minecraft.getMinecraft().player.dimension); 81 | if(this.currently_invulnerable) { 82 | this.label_id = FamilyFunPack.getOverlay().addLabel("Invulnerable"); 83 | } 84 | } 85 | } 86 | break; 87 | } 88 | } else if(id == 0 && this.currently_invulnerable) return null; 89 | 90 | return packet; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/StalkModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | 5 | import net.minecraft.client.network.NetHandlerPlayClient; 6 | import net.minecraft.client.network.NetworkPlayerInfo; 7 | import net.minecraft.network.EnumPacketDirection; 8 | import net.minecraft.network.Packet; 9 | import net.minecraft.network.play.server.SPacketChat; 10 | import net.minecraft.network.play.server.SPacketPlayerListItem; 11 | import net.minecraft.util.text.TextComponentString; 12 | import net.minecraft.util.text.TextFormatting; 13 | import net.minecraftforge.fml.relauncher.SideOnly; 14 | import net.minecraftforge.fml.relauncher.Side; 15 | 16 | import io.netty.buffer.ByteBuf; 17 | 18 | import java.util.UUID; 19 | 20 | import family_fun_pack.FamilyFunPack; 21 | import family_fun_pack.network.PacketListener; 22 | 23 | /* Stalk player, know when they connect, disconnect, speak in chat.. */ 24 | 25 | @SideOnly(Side.CLIENT) 26 | public class StalkModule extends AbstractPlayersRegister implements PacketListener { 27 | 28 | private static final TextFormatting ANNOUNCE_COLOR = TextFormatting.DARK_PURPLE; 29 | 30 | public StalkModule() { 31 | super("Stalker", "See when given players connect/disconnect/speak", "stalk"); 32 | } 33 | 34 | protected void enable() { 35 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 15, 46); 36 | 37 | NetHandlerPlayClient handler = AbstractPlayersRegister.getNetHandler(); 38 | if(handler != null) { 39 | for(NetworkPlayerInfo info : handler.getPlayerInfoMap()) { 40 | this.uuids_lock.readLock().lock(); 41 | if(this.uuids.contains(info.getGameProfile().getId())) { 42 | FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + info.getGameProfile().getName() + " is connected [" + info.getGameType().getName() + "]"); 43 | } 44 | this.uuids_lock.readLock().unlock(); 45 | } 46 | } 47 | } 48 | 49 | protected void disable() { 50 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 15, 46); 51 | } 52 | 53 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 54 | 55 | if(id == 46) { // SPacketPlayerListItem 56 | SPacketPlayerListItem list = (SPacketPlayerListItem) packet; 57 | 58 | if(list.getAction() == SPacketPlayerListItem.Action.UPDATE_LATENCY) return packet; 59 | 60 | NetHandlerPlayClient handler = AbstractPlayersRegister.getNetHandler(); 61 | 62 | for(SPacketPlayerListItem.AddPlayerData entry : list.getEntries()) { 63 | 64 | UUID uuid = entry.getProfile().getId(); 65 | String name = entry.getProfile().getName(); 66 | if(name == null) { 67 | NetworkPlayerInfo info = handler.getPlayerInfo(entry.getProfile().getId()); 68 | if(info == null) continue; 69 | name = info.getGameProfile().getName(); 70 | } 71 | 72 | this.uuids_lock.readLock().lock(); 73 | boolean flag = this.uuids.contains(uuid); 74 | this.uuids_lock.readLock().unlock(); 75 | 76 | if(flag) { 77 | switch(list.getAction()) { 78 | case ADD_PLAYER: 79 | { 80 | String verb = null; 81 | if(handler.getPlayerInfoMap().isEmpty()) { 82 | verb = " is connected"; 83 | } else verb = " joined"; 84 | if(entry.getDisplayName() == null) 85 | FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + verb + " [" + entry.getGameMode().getName() + "]"); 86 | else FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + verb + " under the name \"" + entry.getDisplayName().toString() + "\" [" + entry.getGameMode().getName() + "]"); 87 | } 88 | break; 89 | case REMOVE_PLAYER: 90 | { 91 | FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + " disconnected"); 92 | } 93 | break; 94 | case UPDATE_GAME_MODE: 95 | FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + " changed their game mode to " + entry.getGameMode().getName()); 96 | break; 97 | case UPDATE_DISPLAY_NAME: 98 | if(entry.getDisplayName() == null) 99 | FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + " removed their custom display name"); 100 | else FamilyFunPack.printMessage(StalkModule.ANNOUNCE_COLOR + "Player " + name + " changed their display name to \"" + entry.getDisplayName().toString() + "\""); 101 | break; 102 | } 103 | } 104 | } 105 | } else { // SPacketChat 106 | SPacketChat chat = (SPacketChat) packet; 107 | 108 | GameProfile sender = AbstractPlayersRegister.getSender(chat.getChatComponent()); 109 | if(sender != null) { 110 | this.uuids_lock.readLock().lock(); 111 | boolean flag = this.uuids.contains(sender.getId()); 112 | this.uuids_lock.readLock().unlock(); 113 | 114 | if(flag) { 115 | TextComponentString nmsg = new TextComponentString(chat.getChatComponent().getFormattedText().replace(String.format("<%s>", sender.getName()), String.format("%s<%s>%s", StalkModule.ANNOUNCE_COLOR, sender.getName(), TextFormatting.RESET))); 116 | packet = new SPacketChat(nmsg, chat.getType()); 117 | } 118 | } 119 | } 120 | 121 | return packet; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/TraceModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.network.EnumPacketDirection; 6 | import net.minecraft.network.Packet; 7 | import net.minecraft.network.play.server.SPacketEntityTeleport; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import org.apache.logging.log4j.LogManager; 12 | import org.apache.logging.log4j.Logger; 13 | 14 | import io.netty.buffer.ByteBuf; 15 | 16 | import java.lang.Math; 17 | 18 | import family_fun_pack.FamilyFunPack; 19 | import family_fun_pack.network.PacketListener; 20 | 21 | /* Trace entities teleporting out of our render distance */ 22 | 23 | @SideOnly(Side.CLIENT) 24 | public class TraceModule extends Module implements PacketListener { 25 | 26 | private static final Logger LOGGER = LogManager.getLogger(); 27 | 28 | public TraceModule() { 29 | super("Track Teleports", "Print in chat coords of entity teleporting far away"); 30 | } 31 | 32 | protected void enable() { 33 | FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 76); 34 | } 35 | 36 | protected void disable() { 37 | FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 76); 38 | } 39 | 40 | public Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in) { 41 | SPacketEntityTeleport tp = (SPacketEntityTeleport) packet; 42 | 43 | Minecraft mc = Minecraft.getMinecraft(); 44 | 45 | if(Math.abs(mc.player.posX - tp.getX()) > 500d || Math.abs(mc.player.posZ - tp.getZ()) > 500d) { 46 | String name = "Unknown"; 47 | Entity entity = mc.world.getEntityByID(tp.getEntityId()); 48 | if(entity != null) name = entity.getClass().getSimpleName(); 49 | 50 | double distance = Math.sqrt(Math.pow(mc.player.posX - tp.getX(), 2d) + Math.pow(mc.player.posZ - tp.getZ(), 2d)); 51 | 52 | String warn = String.format("Entity [%s] teleported to [%.2f, %.2f, %.2f], %.2f blocks away", name, tp.getX(), tp.getY(), tp.getZ(), distance); 53 | FamilyFunPack.printMessage(warn); 54 | LOGGER.info("FFP - trace: " + warn); 55 | } 56 | 57 | return packet; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/modules/UndeadModule.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.modules; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiGameOver; 5 | import net.minecraft.network.play.client.CPacketClientStatus; 6 | import net.minecraftforge.common.MinecraftForge; 7 | import net.minecraftforge.client.event.GuiOpenEvent; 8 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 9 | import net.minecraftforge.fml.relauncher.SideOnly; 10 | import net.minecraftforge.fml.relauncher.Side; 11 | 12 | import io.netty.buffer.ByteBuf; 13 | 14 | import family_fun_pack.FamilyFunPack; 15 | import family_fun_pack.network.PacketListener; 16 | 17 | /* Don't show game over interface after dying, use .respawn to respawn 18 | * In vanilla you can still interact with the environment while beeing dead */ 19 | 20 | @SideOnly(Side.CLIENT) 21 | public class UndeadModule extends Module { 22 | 23 | private boolean isDead; 24 | 25 | public UndeadModule() { 26 | super("Undead", "Keep moving after death"); 27 | this.isDead = false; 28 | } 29 | 30 | protected void enable() { 31 | MinecraftForge.EVENT_BUS.register(this); 32 | } 33 | 34 | protected void disable() { 35 | MinecraftForge.EVENT_BUS.unregister(this); 36 | if(this.isDead) { 37 | FamilyFunPack.getNetworkHandler().sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN)); 38 | this.isDead = false; 39 | } 40 | } 41 | 42 | public void onDisconnect() { 43 | this.isDead = false; 44 | } 45 | 46 | @SubscribeEvent 47 | public void onGuiOpened(GuiOpenEvent event) { 48 | if(event.getGui() instanceof GuiGameOver) { 49 | event.setGui(null); 50 | this.isDead = true; 51 | Minecraft.getMinecraft().player.setHealth(20); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/nbt/SpecialTagCompound.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.nbt; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import net.minecraft.nbt.NBTBase; 7 | import net.minecraft.nbt.NBTTagCompound; 8 | import net.minecraft.item.ItemStack; 9 | 10 | import java.util.UUID; 11 | 12 | /* Store real durability inside special NBTTagCompound */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class SpecialTagCompound extends NBTTagCompound { 16 | 17 | public static int getStackDamage(ItemStack stack) { 18 | NBTTagCompound tag = stack.getTagCompound(); 19 | if(tag != null && tag instanceof SpecialTagCompound) { 20 | return ((SpecialTagCompound)tag).getTrueDamage(); 21 | } 22 | return stack.getItemDamage(); 23 | } 24 | 25 | private boolean empty; 26 | private final int true_damage; 27 | 28 | public SpecialTagCompound(boolean empty, int true_damage) { 29 | this.empty = empty; 30 | this.true_damage = true_damage; 31 | } 32 | 33 | public SpecialTagCompound(NBTTagCompound old, int true_damage) { 34 | super(); 35 | if(old == null) this.empty = true; 36 | else { 37 | for(String key : old.getKeySet()) { 38 | super.setTag(key, old.getTag(key)); 39 | } 40 | } 41 | this.true_damage = true_damage; 42 | } 43 | 44 | public int getTrueDamage() { 45 | return this.true_damage; 46 | } 47 | 48 | public byte getId() { 49 | if(this.empty) return 0; 50 | return super.getId(); 51 | } 52 | 53 | public NBTTagCompound copy() { 54 | NBTTagCompound copy = new SpecialTagCompound(this.empty, this.true_damage); 55 | 56 | for (String s : this.getKeySet()) { 57 | ((SpecialTagCompound)copy).setTagLegacy(s, this.getTag(s).copy()); 58 | } 59 | 60 | return copy; 61 | } 62 | 63 | public boolean hasNoTags() { // do not clear me 64 | if(super.hasNoTags()) { 65 | this.empty = true; 66 | } 67 | return false; 68 | } 69 | 70 | public void setTag(String key, NBTBase value) { 71 | this.empty = false; 72 | super.setTag(key, value); 73 | } 74 | 75 | public void setTagLegacy(String key, NBTBase value) { 76 | super.setTag(key, value); 77 | } 78 | 79 | public void setInteger(String key, int value) { 80 | this.empty = false; 81 | super.setInteger(key, value); 82 | } 83 | 84 | public void setByte(String key, byte value) { 85 | this.empty = false; 86 | super.setByte(key, value); 87 | } 88 | 89 | public void setShort(String key, short value) { 90 | this.empty = false; 91 | super.setShort(key, value); 92 | } 93 | 94 | public void setLong(String key, long value) { 95 | this.empty = false; 96 | super.setLong(key, value); 97 | } 98 | 99 | public void setUniqueId(String key, UUID value) { 100 | this.empty = false; 101 | super.setUniqueId(key, value); 102 | } 103 | 104 | public void setFloat(String key, float value) { 105 | this.empty = false; 106 | super.setFloat(key, value); 107 | } 108 | 109 | public void setDouble(String key, double value) { 110 | this.empty = false; 111 | super.setDouble(key, value); 112 | } 113 | 114 | public void setString(String key, String value) { 115 | this.empty = false; 116 | super.setString(key, value); 117 | } 118 | 119 | public void setByteArray(String key, byte[] value) { 120 | this.empty = false; 121 | super.setByteArray(key, value); 122 | } 123 | 124 | public void setIntArray(String key, int[] value) { 125 | this.empty = false; 126 | super.setIntArray(key, value); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/network/InboundInterceptor.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.network; 2 | 3 | import net.minecraft.network.Packet; 4 | import net.minecraft.network.NetworkManager; 5 | import net.minecraft.network.NettyPacketDecoder; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.EnumConnectionState; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import io.netty.channel.ChannelHandlerContext; 12 | import io.netty.buffer.ByteBuf; 13 | 14 | import java.lang.Exception; 15 | import java.lang.IllegalAccessException; 16 | import java.lang.InstantiationException; 17 | import java.io.IOException; 18 | import java.util.List; 19 | 20 | /* Intercept packet sent by server to client */ 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class InboundInterceptor extends NettyPacketDecoder { 24 | 25 | private final EnumPacketDirection direction; 26 | private final NetworkHandler handler; 27 | private boolean isPlay; 28 | 29 | public InboundInterceptor(NetworkHandler handler, EnumPacketDirection direction) { 30 | super(direction); 31 | this.handler = handler; 32 | this.direction = direction; // let's save it twice 33 | this.isPlay = false; 34 | } 35 | 36 | protected void decode(ChannelHandlerContext context, ByteBuf in, List out) throws Exception { 37 | if (in.readableBytes() != 0) { 38 | 39 | int start_index = in.readerIndex(); // Mark start index 40 | super.decode(context, in, out); // Computer packet 41 | 42 | if(! this.isPlay) { // don't go fetch the attr every time 43 | EnumConnectionState state = context.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get(); 44 | this.isPlay = (state == EnumConnectionState.PLAY); 45 | } 46 | 47 | if(this.isPlay && out.size() > 0) { 48 | Packet packet = (Packet)out.get(0); 49 | int id = context.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get().getPacketId(this.direction, packet); 50 | int end_index = in.readerIndex(); 51 | 52 | in.readerIndex(start_index); 53 | packet = this.handler.packetReceived(this.direction, id, packet, in); 54 | in.readerIndex(end_index); 55 | 56 | if(packet == null) out.clear(); 57 | else out.set(0, packet); 58 | } 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/network/OutboundFrameEncoder.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.network; 2 | 3 | import net.minecraft.network.NettyVarint21FrameEncoder; 4 | import net.minecraftforge.fml.relauncher.SideOnly; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | 7 | import io.netty.buffer.ByteBuf; 8 | import io.netty.channel.ChannelHandlerContext; 9 | 10 | @SideOnly(Side.CLIENT) 11 | public class OutboundFrameEncoder extends NettyVarint21FrameEncoder { 12 | protected void encode(ChannelHandlerContext context, ByteBuf in, ByteBuf out) throws Exception { 13 | if(in.readableBytes() > 1 || (in.readableBytes() == 1 && in.readByte() != (byte) 0)) { // Stop sending empty packets to server 14 | super.encode(context, in, out); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/network/OutboundInterceptor.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.network; 2 | 3 | import net.minecraft.network.Packet; 4 | import net.minecraft.network.NetworkManager; 5 | import net.minecraft.network.NettyPacketEncoder; 6 | import net.minecraft.network.EnumPacketDirection; 7 | import net.minecraft.network.EnumConnectionState; 8 | import net.minecraftforge.fml.relauncher.SideOnly; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | 11 | import io.netty.buffer.ByteBuf; 12 | import io.netty.channel.ChannelHandlerContext; 13 | 14 | import java.lang.Exception; 15 | import java.io.IOException; 16 | 17 | /* Intercept packet sent by client to server */ 18 | 19 | @SideOnly(Side.CLIENT) 20 | public class OutboundInterceptor extends NettyPacketEncoder { 21 | 22 | private final EnumPacketDirection direction; 23 | private final NetworkHandler handler; 24 | private boolean isPlay; 25 | 26 | public OutboundInterceptor(NetworkHandler handler, EnumPacketDirection direction) { 27 | super(direction); 28 | this.handler = handler; 29 | this.direction = direction; // let's save it twice 30 | this.isPlay = false; 31 | } 32 | 33 | protected void encode(ChannelHandlerContext context, Packet packet, ByteBuf out) throws Exception { 34 | 35 | if(! this.isPlay) { 36 | EnumConnectionState state = context.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get(); 37 | this.isPlay = (state == EnumConnectionState.PLAY); 38 | } 39 | 40 | if(this.isPlay) { 41 | int id = context.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get().getPacketId(this.direction, packet); 42 | 43 | packet = this.handler.packetReceived(this.direction, id, packet, null); 44 | 45 | if(packet == null) return; 46 | } 47 | 48 | super.encode(context, packet, out); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/network/PacketListener.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.network; 2 | 3 | import net.minecraft.network.EnumPacketDirection; 4 | import net.minecraft.network.Packet; 5 | import net.minecraftforge.fml.relauncher.SideOnly; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | 8 | import io.netty.buffer.ByteBuf; 9 | 10 | /* A class listening for network packets, register a listener on NetworkHandler */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public interface PacketListener { 14 | 15 | Packet packetReceived(EnumPacketDirection direction, int id, Packet packet, ByteBuf in); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/render/CustomLayerElytra.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.render; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import net.minecraft.client.renderer.GlStateManager; 7 | import net.minecraft.client.renderer.entity.layers.LayerRenderer; 8 | import net.minecraft.client.renderer.entity.layers.LayerArmorBase; 9 | import net.minecraft.client.renderer.entity.RenderLivingBase; 10 | import net.minecraft.client.model.ModelBase; 11 | import net.minecraft.client.model.ModelElytra; 12 | import net.minecraft.entity.Entity; 13 | import net.minecraft.entity.EntityLivingBase; 14 | import net.minecraft.entity.player.EnumPlayerModelParts; 15 | import net.minecraft.client.entity.AbstractClientPlayer; 16 | import net.minecraft.inventory.EntityEquipmentSlot; 17 | import net.minecraft.item.ItemStack; 18 | import net.minecraft.init.Items; 19 | import net.minecraft.util.ResourceLocation; 20 | import net.minecraft.nbt.NBTTagCompound; 21 | 22 | import family_fun_pack.nbt.SpecialTagCompound; 23 | 24 | /* Used to apply red enchant to unbrekable elytras */ 25 | 26 | @SideOnly(Side.CLIENT) 27 | public class CustomLayerElytra implements LayerRenderer { 28 | 29 | private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); 30 | 31 | protected RenderLivingBase renderPlayer; 32 | 33 | private final ModelElytra modelElytra = new ModelElytra(); 34 | 35 | public CustomLayerElytra(RenderLivingBase render) { 36 | this.renderPlayer = render; 37 | } 38 | 39 | public void doRenderLayer(EntityLivingBase entity, float f1, float f2, float f3, float f4, float f5, float f6, float f7) { 40 | ItemStack stack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); 41 | if (stack.getItem() != Items.ELYTRA) return; 42 | 43 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 44 | GlStateManager.enableBlend(); 45 | GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); 46 | 47 | if (entity instanceof AbstractClientPlayer) { 48 | AbstractClientPlayer player = (AbstractClientPlayer)entity; 49 | if (player.isPlayerInfoSet() && player.getLocationElytra() != null) { 50 | this.renderPlayer.bindTexture(player.getLocationElytra()); 51 | } else if (player.hasPlayerInfo() && player.getLocationCape() != null && player.isWearing(EnumPlayerModelParts.CAPE)) { 52 | this.renderPlayer.bindTexture(player.getLocationCape()); 53 | } else { 54 | this.renderPlayer.bindTexture(CustomLayerElytra.TEXTURE_ELYTRA); 55 | } 56 | } else { 57 | this.renderPlayer.bindTexture(CustomLayerElytra.TEXTURE_ELYTRA); 58 | } 59 | 60 | GlStateManager.pushMatrix(); 61 | GlStateManager.translate(0.0F, 0.0F, 0.125F); 62 | 63 | this.modelElytra.setRotationAngles(f1, f2, f4, f5, f6, f7, entity); 64 | this.modelElytra.render(entity, f1, f2, f4, f5, f6, f7); 65 | 66 | NBTTagCompound tag = stack.getTagCompound(); 67 | if(stack.getItemDamage() > stack.getMaxDamage() || (tag != null && tag instanceof SpecialTagCompound)) { 68 | CustomLayerBipedArmor.renderEnchantedGlint(this.renderPlayer, entity, this.modelElytra, f1, f2, f3, f4, f5, f6, f7); 69 | } else if (stack.isItemEnchanted()) { 70 | LayerArmorBase.renderEnchantedGlint(this.renderPlayer, entity, this.modelElytra, f1, f2, f3, f4, f5, f6, f7); 71 | } 72 | 73 | GlStateManager.disableBlend(); 74 | GlStateManager.popMatrix(); 75 | } 76 | 77 | public boolean shouldCombineTextures() { 78 | return false; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/render/CustomRenderItem.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.render; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.renderer.RenderItem; 8 | import net.minecraft.client.renderer.GlStateManager; 9 | import net.minecraft.client.renderer.texture.TextureManager; 10 | import net.minecraft.client.renderer.texture.TextureMap; 11 | import net.minecraft.client.renderer.block.model.ModelManager; 12 | import net.minecraft.client.renderer.color.ItemColors; 13 | import net.minecraft.client.renderer.block.model.IBakedModel; 14 | import net.minecraft.item.ItemStack; 15 | import net.minecraft.util.ResourceLocation; 16 | import net.minecraft.nbt.NBTTagCompound; 17 | 18 | import java.lang.Class; 19 | import java.lang.NoSuchMethodException; 20 | import java.lang.reflect.Method; 21 | import java.lang.reflect.InvocationTargetException; 22 | import java.lang.IllegalAccessException; 23 | 24 | import family_fun_pack.nbt.SpecialTagCompound; 25 | 26 | /* Used to apply red enchant to unbrekable items */ 27 | 28 | @SideOnly(Side.CLIENT) 29 | public class CustomRenderItem extends RenderItem { 30 | 31 | private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); 32 | 33 | private Method renderModel; 34 | 35 | private final TextureManager textureManagerSave; 36 | 37 | public CustomRenderItem(TextureManager textureManager, ModelManager modelManager, ItemColors itemColors) { 38 | super(textureManager, modelManager, itemColors); 39 | this.textureManagerSave = textureManager; 40 | Class renderItem = RenderItem.class; 41 | try { 42 | this.renderModel = renderItem.getDeclaredMethod("func_191967_a", IBakedModel.class, int.class, ItemStack.class); 43 | } catch(NoSuchMethodException e) { 44 | try { 45 | this.renderModel = renderItem.getDeclaredMethod("renderModel", IBakedModel.class, int.class, ItemStack.class); 46 | } catch(NoSuchMethodException e2) { 47 | throw new RuntimeException("FamilyFunPack Error: no method renderModel in class RenderItem"); 48 | } 49 | } 50 | this.renderModel.setAccessible(true); 51 | } 52 | 53 | public void renderItem(ItemStack stack, IBakedModel model) { 54 | if (!stack.isEmpty()) { 55 | 56 | GlStateManager.pushMatrix(); 57 | GlStateManager.translate(-0.5F, -0.5F, -0.5F); 58 | 59 | if (model.isBuiltInRenderer()) { 60 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 61 | GlStateManager.enableRescaleNormal(); 62 | stack.getItem().getTileEntityItemStackRenderer().renderByItem(stack); 63 | } else { 64 | try { 65 | this.renderModel.invoke(this, model, new Integer(-1), stack); 66 | } catch(IllegalAccessException e) {} 67 | catch(InvocationTargetException e) {} 68 | 69 | NBTTagCompound tag = stack.getTagCompound(); 70 | if((stack.isItemStackDamageable() && stack.getItemDamage() > stack.getMaxDamage()) || (tag != null && (tag instanceof SpecialTagCompound || tag.getBoolean("Unbreakable")))) { 71 | this.renderEffect(model, 0xfffc0505); 72 | } else if (stack.hasEffect()) { 73 | this.renderEffect(model, -8372020); 74 | } 75 | } 76 | 77 | GlStateManager.popMatrix(); 78 | } 79 | } 80 | 81 | private void renderEffect(IBakedModel model, int color) { 82 | GlStateManager.depthMask(false); 83 | GlStateManager.depthFunc(514); 84 | GlStateManager.disableLighting(); 85 | GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); 86 | this.textureManagerSave.bindTexture(CustomRenderItem.RES_ITEM_GLINT); 87 | GlStateManager.matrixMode(5890); 88 | GlStateManager.pushMatrix(); 89 | GlStateManager.scale(8.0F, 8.0F, 8.0F); 90 | float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F; 91 | GlStateManager.translate(f, 0.0F, 0.0F); 92 | GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F); 93 | try { 94 | this.renderModel.invoke(this, model, new Integer(color), ItemStack.EMPTY); 95 | } catch(IllegalAccessException e) {} 96 | catch(InvocationTargetException e) {} 97 | GlStateManager.popMatrix(); 98 | GlStateManager.pushMatrix(); 99 | GlStateManager.scale(8.0F, 8.0F, 8.0F); 100 | float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F; 101 | GlStateManager.translate(-f1, 0.0F, 0.0F); 102 | GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F); 103 | try { 104 | this.renderModel.invoke(this, model, new Integer(color), ItemStack.EMPTY); 105 | } catch(IllegalAccessException e) {} 106 | catch(InvocationTargetException e) {} 107 | GlStateManager.popMatrix(); 108 | GlStateManager.matrixMode(5888); 109 | GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); 110 | GlStateManager.enableLighting(); 111 | GlStateManager.depthFunc(515); 112 | GlStateManager.depthMask(true); 113 | this.textureManagerSave.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/render/NoRenderPig.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.render; 2 | 3 | import net.minecraftforge.fml.relauncher.SideOnly; 4 | import net.minecraftforge.fml.relauncher.Side; 5 | import net.minecraft.client.renderer.entity.RenderManager; 6 | import net.minecraft.client.renderer.entity.RenderPig; 7 | import net.minecraft.entity.passive.EntityPig; 8 | import net.minecraft.client.Minecraft; 9 | 10 | /* Render pig few inches lower, to be able to see where we are going with pig POV */ 11 | 12 | @SideOnly(Side.CLIENT) 13 | public class NoRenderPig extends RenderPig { 14 | 15 | private final Minecraft mc; 16 | 17 | public NoRenderPig(RenderManager manager, Minecraft mc) { 18 | super(manager); 19 | this.mc = mc; 20 | } 21 | 22 | public void doRender(EntityPig pig, double d0, double d1, double d2, float f1, float f2) { 23 | if(this.mc.player.getRidingEntity() == pig) d1 -= 0.5; 24 | super.doRender(pig, d0, d1, d2, f1, f2); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/render/RenderGhostDonkey.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.render; 2 | 3 | import net.minecraft.entity.passive.AbstractHorse; 4 | import net.minecraft.client.renderer.entity.RenderAbstractHorse; 5 | import net.minecraft.client.renderer.entity.RenderManager; 6 | import net.minecraft.util.ResourceLocation; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import net.minecraftforge.fml.relauncher.Side; 9 | 10 | import family_fun_pack.FamilyFunPack; 11 | 12 | /* Render ghost donkey with its special (yet shitty) skin */ 13 | 14 | @SideOnly(Side.CLIENT) 15 | public class RenderGhostDonkey extends RenderAbstractHorse { 16 | 17 | private static final ResourceLocation texture = new ResourceLocation(FamilyFunPack.MODID, "textures/entity/horse/ghost_donkey.png"); 18 | 19 | public RenderGhostDonkey(RenderManager manager) { 20 | super(manager, 0.87F); 21 | } 22 | 23 | protected ResourceLocation getEntityTexture(AbstractHorse p_getEntityTexture_1_) { 24 | return RenderGhostDonkey.texture; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/utils/FakeWorld.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.utils; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.block.state.IBlockState; 5 | import net.minecraft.init.Blocks; 6 | import net.minecraft.tileentity.TileEntity; 7 | import net.minecraft.world.World; 8 | import net.minecraft.world.WorldProvider; 9 | import net.minecraft.world.chunk.Chunk; 10 | import net.minecraft.world.chunk.IChunkProvider; 11 | import net.minecraft.world.storage.ISaveHandler; 12 | import net.minecraft.world.storage.WorldInfo; 13 | import net.minecraft.util.math.BlockPos; 14 | import net.minecraftforge.fml.relauncher.SideOnly; 15 | import net.minecraftforge.fml.relauncher.Side; 16 | 17 | import net.minecraft.block.BlockShulkerBox; 18 | import net.minecraft.util.EnumFacing; 19 | 20 | // Only one blockstate world, used for rendering tileentities in gui 21 | 22 | @SideOnly(Side.CLIENT) 23 | public class FakeWorld extends World { 24 | 25 | private IBlockState state; 26 | private Chunk chunk; 27 | 28 | public FakeWorld(IBlockState state, WorldProvider provider) { 29 | super(null, null, provider, null, false); 30 | this.state = state; 31 | } 32 | 33 | public FakeWorld(ISaveHandler saveHandler, WorldInfo info, WorldProvider provider) { 34 | super(saveHandler, info, provider, null, false); 35 | this.state = Blocks.AIR.getDefaultState(); 36 | } 37 | 38 | public void setChunk(Chunk chunk) { 39 | this.chunk = chunk; 40 | } 41 | 42 | public Chunk getChunk(int chunkX, int chunkZ) { 43 | return this.chunk; 44 | } 45 | 46 | public Chunk getChunkFromChunkCoords(int chunkX, int chunkZ) { // Runtime name of getChunk (why is this different ?) 47 | return this.chunk; 48 | } 49 | 50 | public IBlockState getBlockState(BlockPos position) { 51 | if(position.equals(BlockPos.ORIGIN)) return this.state; 52 | return Blocks.AIR.getDefaultState(); 53 | } 54 | 55 | public boolean setBlockState(BlockPos position, IBlockState state, int updt) { 56 | this.state = state; 57 | return true; 58 | } 59 | 60 | public void notifyBlockUpdate(BlockPos pos, IBlockState oldState, IBlockState newState, int flags) { // Don't do anything 61 | 62 | } 63 | 64 | public long getTotalWorldTime() { 65 | if(this.worldInfo == null) return 0L; 66 | return super.getTotalWorldTime(); 67 | } 68 | 69 | protected IChunkProvider createChunkProvider() { 70 | return null; 71 | } 72 | 73 | protected boolean isChunkLoaded(int paramInt1, int paramInt2, boolean paramBoolean) { 74 | return false; 75 | } 76 | 77 | public void neighborChanged(BlockPos pos, final Block blockIn, BlockPos fromPos) {} 78 | 79 | public void observedNeighborChanged(BlockPos pos, final Block block, BlockPos target) {} 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/utils/Timer.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.utils; 2 | 3 | public class Timer { 4 | private long time; 5 | 6 | public boolean passed(double ms) { 7 | return getTime() >= ms; 8 | } 9 | 10 | public Timer reset() { 11 | time = System.currentTimeMillis(); 12 | return this; 13 | } 14 | 15 | public long getTime() { 16 | return System.currentTimeMillis() - time; 17 | } 18 | 19 | public void setTime(long ns) { 20 | time = ns; 21 | } 22 | 23 | public void adjust(int time) { 24 | this.time += time; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/family_fun_pack/utils/WorldCapture.java: -------------------------------------------------------------------------------- 1 | package family_fun_pack.utils; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.datafix.DataFixesManager; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.DimensionType; 7 | import net.minecraft.world.EnumDifficulty; 8 | import net.minecraft.world.GameType; 9 | import net.minecraft.world.MinecraftException; 10 | import net.minecraft.world.World; 11 | import net.minecraft.world.WorldProvider; 12 | import net.minecraft.world.WorldProviderEnd; 13 | import net.minecraft.world.WorldProviderHell; 14 | import net.minecraft.world.WorldProviderSurface; 15 | import net.minecraft.world.WorldSettings; 16 | import net.minecraft.world.WorldType; 17 | import net.minecraft.world.chunk.Chunk; 18 | import net.minecraft.world.chunk.storage.AnvilSaveHandler; 19 | import net.minecraft.world.chunk.storage.IChunkLoader; 20 | import net.minecraft.world.storage.WorldInfo; 21 | import net.minecraftforge.fml.relauncher.SideOnly; 22 | import net.minecraftforge.fml.relauncher.Side; 23 | 24 | import org.apache.logging.log4j.LogManager; 25 | import org.apache.logging.log4j.Logger; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | 30 | /* Utility class to create a world download */ 31 | 32 | public class WorldCapture { 33 | 34 | private static final Logger LOGGER = LogManager.getLogger(); 35 | 36 | private final IChunkLoader chunkLoader; 37 | private final FakeWorld fakeWorld; 38 | private final String name; 39 | 40 | private int count; 41 | 42 | public WorldCapture(String saveName, DimensionType dimension, BlockPos spawn) { 43 | Minecraft mc = Minecraft.getMinecraft(); 44 | 45 | this.name = saveName; 46 | 47 | File saves_folder = new File("./saves"); 48 | saves_folder.mkdirs(); 49 | 50 | AnvilSaveHandler saveHandler = new AnvilSaveHandler(saves_folder, saveName, false, DataFixesManager.createFixer()); 51 | 52 | WorldInfo info = new WorldInfo(new WorldSettings(-8076723744225505211L, GameType.CREATIVE, true, false, WorldType.DEFAULT), saveName); // 9b seed 53 | info.setAllowCommands(true); 54 | info.setDifficulty(EnumDifficulty.PEACEFUL); 55 | info.setServerInitialized(true); 56 | 57 | WorldProvider provider = null; 58 | switch(dimension) { 59 | case OVERWORLD: 60 | provider = new WorldProviderSurface(); 61 | info.setSpawn(spawn); 62 | break; 63 | case NETHER: 64 | provider = new WorldProviderHell(); 65 | provider.setDimension(-1); 66 | break; 67 | case THE_END: 68 | provider = new WorldProviderEnd(); 69 | provider.setDimension(1); 70 | break; 71 | } 72 | 73 | saveHandler.saveWorldInfoWithPlayer(info, null); 74 | 75 | this.chunkLoader = saveHandler.getChunkLoader(provider); 76 | this.fakeWorld = new FakeWorld(saveHandler, info, provider); 77 | this.count = 0; 78 | } 79 | 80 | public void captureChunk(Chunk chunk) { 81 | try { 82 | chunk.setLastSaveTime(this.fakeWorld.getTotalWorldTime()); 83 | this.chunkLoader.saveChunk(this.fakeWorld, chunk); 84 | } catch (IOException e) { 85 | LOGGER.error("FFP: Couldn't save captured chunk", e); 86 | } catch (MinecraftException e) { 87 | LOGGER.error("FFP: Couldn't save captured chunk; already in use by another instance of Minecraft?", e); 88 | } 89 | 90 | this.chunkLoader.flush(); 91 | this.count += 1; 92 | } 93 | 94 | public FakeWorld getWorld() { 95 | return this.fakeWorld; 96 | } 97 | 98 | public String getName() { 99 | return this.name; 100 | } 101 | 102 | public int getRecordedCount() { 103 | return this.count; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/resources/assets/family_fun_pack/textures/entity/horse/ghost_donkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anOtherAnalyse/FamilyFunPack/a5f1fcfe481ac5637fa9a740a0d79aca1da33993/src/main/resources/assets/family_fun_pack/textures/entity/horse/ghost_donkey.png -------------------------------------------------------------------------------- /src/main/resources/assets/family_fun_pack/textures/gui/navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anOtherAnalyse/FamilyFunPack/a5f1fcfe481ac5637fa9a740a0d79aca1da33993/src/main/resources/assets/family_fun_pack/textures/gui/navigation.png -------------------------------------------------------------------------------- /src/main/resources/assets/family_fun_pack/textures/gui/on_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anOtherAnalyse/FamilyFunPack/a5f1fcfe481ac5637fa9a740a0d79aca1da33993/src/main/resources/assets/family_fun_pack/textures/gui/on_off.png -------------------------------------------------------------------------------- /src/main/resources/assets/family_fun_pack/textures/gui/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anOtherAnalyse/FamilyFunPack/a5f1fcfe481ac5637fa9a740a0d79aca1da33993/src/main/resources/assets/family_fun_pack/textures/gui/preview.png -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "family_fun_pack", 4 | "name": "Family Fun Pack", 5 | "description": "Family Fun Pack - fun for the whole family.\n\nGo to https://github.com/anOtherAnalyse/FamilyFunPack for a list of features.", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "", 9 | "updateUrl": "", 10 | "authorList": ["Bobeezz"], 11 | "credits": "The Forge and FML guys", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "examplemod resources", 4 | "pack_format": 3, 5 | "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." 6 | } 7 | } 8 | --------------------------------------------------------------------------------