├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── addon.gradle ├── build.gradle ├── changelog.txt ├── dependencies.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── license-gpl.txt ├── license.txt ├── publish ├── .gitignore ├── README.txt ├── build.gradle ├── build_and_release.sh ├── curseforge_all.sh ├── gameVersions.json ├── get_version.py ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── modrinth_all.sh ├── prepare_publish.py └── update_updatejson.py ├── readme.md ├── readme_server.txt ├── repositories.gradle └── src └── main ├── java └── net │ └── smart │ ├── core │ ├── SmartCoreClassVisitor.java │ ├── SmartCoreContainer.java │ ├── SmartCoreEventHandler.java │ ├── SmartCoreInfo.java │ ├── SmartCoreMethodVisitor.java │ ├── SmartCorePlugin.java │ ├── SmartCoreTransformation.java │ └── SmartCoreTransformer.java │ ├── moving │ ├── Button.java │ ├── ClimbGap.java │ ├── Compat.java │ ├── FeetClimbing.java │ ├── HandsClimbing.java │ ├── IEntityPlayerMP.java │ ├── IEntityPlayerSP.java │ ├── ILocalUserNameProvider.java │ ├── IPacketReceiver.java │ ├── IPacketSender.java │ ├── ISmartMovingClient.java │ ├── ISmartMovingSelf.java │ ├── LocalUserNameProvider.java │ ├── Orientation.java │ ├── SmartMoving.java │ ├── SmartMovingBase.java │ ├── SmartMovingClient.java │ ├── SmartMovingComm.java │ ├── SmartMovingContext.java │ ├── SmartMovingCoreEventHandler.java │ ├── SmartMovingFactory.java │ ├── SmartMovingInfo.java │ ├── SmartMovingInstall.java │ ├── SmartMovingMod.java │ ├── SmartMovingOther.java │ ├── SmartMovingPacketStream.java │ ├── SmartMovingSelf.java │ ├── SmartMovingServer.java │ ├── SmartMovingServerComm.java │ ├── config │ │ ├── SmartMovingClientConfig.java │ │ ├── SmartMovingConfig.java │ │ ├── SmartMovingOptions.java │ │ ├── SmartMovingProperties.java │ │ ├── SmartMovingServerConfig.java │ │ └── SmartMovingServerOptions.java │ ├── playerapi │ │ ├── SmartMoving.java │ │ ├── SmartMovingFactory.java │ │ ├── SmartMovingPlayerBase.java │ │ ├── SmartMovingSelf.java │ │ └── SmartMovingServerPlayerBase.java │ ├── render │ │ ├── IModelPlayer.java │ │ ├── IRenderPlayer.java │ │ ├── ModelPlayer.java │ │ ├── RenderPlayer.java │ │ ├── SmartMovingModel.java │ │ ├── SmartMovingRender.java │ │ ├── SmartRenderContext.java │ │ └── playerapi │ │ │ ├── SmartMoving.java │ │ │ ├── SmartMovingModelPlayerBase.java │ │ │ └── SmartMovingRenderPlayerBase.java │ └── test │ │ ├── SmartMovingTestCommand.java │ │ └── SmartMovingTestMod.java │ ├── properties │ ├── Properties.java │ ├── Property.java │ └── Value.java │ └── utilities │ ├── Name.java │ └── Reflect.java └── resources ├── META-INF └── smartmoving_at.cfg ├── assets └── smartmoving │ ├── gui │ └── icons.png │ └── lang │ ├── en_US.lang │ ├── nl_NL.lang │ ├── pt_BR.lang │ └── ru_RU.lang ├── license-gpl.txt ├── license.txt └── mcmod.info /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: [push, pull_request] 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | with: 16 | fetch-depth: 0 17 | - name: Set up JDK 1.8 18 | uses: actions/setup-java@v3 19 | with: 20 | distribution: 'temurin' 21 | java-version: 8 22 | - name: Grant execute permission for gradlew 23 | run: chmod +x gradlew 24 | - name: Set up Gradle build 25 | run: ./gradlew setupCIWorkspace 26 | - name: Build with Gradle 27 | run: ./gradlew build 28 | - uses: actions/upload-artifact@v3 29 | with: 30 | name: Package 31 | path: build/libs 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,forgegradle,java,eclipse,netbeans 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,gradle,forgegradle,java,eclipse,netbeans 3 | 4 | ### Eclipse ### 5 | .metadata 6 | bin/ 7 | tmp/ 8 | *.tmp 9 | *.bak 10 | *.swp 11 | *~.nib 12 | local.properties 13 | .settings/ 14 | .loadpath 15 | .recommenders 16 | 17 | # External tool builders 18 | .externalToolBuilders/ 19 | 20 | # Locally stored "Eclipse launch configurations" 21 | *.launch 22 | 23 | # PyDev specific (Python IDE for Eclipse) 24 | *.pydevproject 25 | 26 | # CDT-specific (C/C++ Development Tooling) 27 | .cproject 28 | 29 | # CDT- autotools 30 | .autotools 31 | 32 | # Java annotation processor (APT) 33 | .factorypath 34 | 35 | # PDT-specific (PHP Development Tools) 36 | .buildpath 37 | 38 | # sbteclipse plugin 39 | .target 40 | 41 | # Tern plugin 42 | .tern-project 43 | 44 | # TeXlipse plugin 45 | .texlipse 46 | 47 | # STS (Spring Tool Suite) 48 | .springBeans 49 | 50 | # Code Recommenders 51 | .recommenders/ 52 | 53 | # Annotation Processing 54 | .apt_generated/ 55 | .apt_generated_test/ 56 | 57 | # Scala IDE specific (Scala & Java development for Eclipse) 58 | .cache-main 59 | .scala_dependencies 60 | .worksheet 61 | 62 | # Uncomment this line if you wish to ignore the project description file. 63 | # Typically, this file would be tracked if it contains build/dependency configurations: 64 | #.project 65 | 66 | ### Eclipse Patch ### 67 | # Spring Boot Tooling 68 | .sts4-cache/ 69 | 70 | ### ForgeGradle ### 71 | # Minecraft client/server files 72 | run/ 73 | 74 | ### Intellij+all ### 75 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 76 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 77 | 78 | # User-specific stuff 79 | .idea/**/workspace.xml 80 | .idea/**/tasks.xml 81 | .idea/**/usage.statistics.xml 82 | .idea/**/dictionaries 83 | .idea/**/shelf 84 | 85 | # AWS User-specific 86 | .idea/**/aws.xml 87 | 88 | # Generated files 89 | .idea/**/contentModel.xml 90 | 91 | # Sensitive or high-churn files 92 | .idea/**/dataSources/ 93 | .idea/**/dataSources.ids 94 | .idea/**/dataSources.local.xml 95 | .idea/**/sqlDataSources.xml 96 | .idea/**/dynamic.xml 97 | .idea/**/uiDesigner.xml 98 | .idea/**/dbnavigator.xml 99 | 100 | # Gradle 101 | .idea/**/gradle.xml 102 | .idea/**/libraries 103 | 104 | # Gradle and Maven with auto-import 105 | # When using Gradle or Maven with auto-import, you should exclude module files, 106 | # since they will be recreated, and may cause churn. Uncomment if using 107 | # auto-import. 108 | # .idea/artifacts 109 | # .idea/compiler.xml 110 | # .idea/jarRepositories.xml 111 | # .idea/modules.xml 112 | # .idea/*.iml 113 | # .idea/modules 114 | # *.iml 115 | # *.ipr 116 | 117 | # CMake 118 | cmake-build-*/ 119 | 120 | # Mongo Explorer plugin 121 | .idea/**/mongoSettings.xml 122 | 123 | # File-based project format 124 | *.iws 125 | 126 | # IntelliJ 127 | out/ 128 | 129 | # mpeltonen/sbt-idea plugin 130 | .idea_modules/ 131 | 132 | # JIRA plugin 133 | atlassian-ide-plugin.xml 134 | 135 | # Cursive Clojure plugin 136 | .idea/replstate.xml 137 | 138 | # SonarLint plugin 139 | .idea/sonarlint/ 140 | 141 | # Crashlytics plugin (for Android Studio and IntelliJ) 142 | com_crashlytics_export_strings.xml 143 | crashlytics.properties 144 | crashlytics-build.properties 145 | fabric.properties 146 | 147 | # Editor-based Rest Client 148 | .idea/httpRequests 149 | 150 | # Android studio 3.1+ serialized cache file 151 | .idea/caches/build_file_checksums.ser 152 | 153 | ### Intellij+all Patch ### 154 | # Ignore everything but code style settings and run configurations 155 | # that are supposed to be shared within teams. 156 | 157 | .idea/* 158 | 159 | !.idea/codeStyles 160 | !.idea/runConfigurations 161 | 162 | ### Java ### 163 | # Compiled class file 164 | *.class 165 | 166 | # Log file 167 | *.log 168 | 169 | # BlueJ files 170 | *.ctxt 171 | 172 | # Mobile Tools for Java (J2ME) 173 | .mtj.tmp/ 174 | 175 | # Package Files # 176 | *.jar 177 | *.war 178 | *.nar 179 | *.ear 180 | *.zip 181 | *.tar.gz 182 | *.rar 183 | 184 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 185 | hs_err_pid* 186 | replay_pid* 187 | 188 | ### NetBeans ### 189 | **/nbproject/private/ 190 | **/nbproject/Makefile-*.mk 191 | **/nbproject/Package-*.bash 192 | build/ 193 | nbbuild/ 194 | dist/ 195 | nbdist/ 196 | .nb-gradle/ 197 | 198 | ### Gradle ### 199 | .gradle 200 | **/build/ 201 | !src/**/build/ 202 | 203 | # Ignore Gradle GUI config 204 | gradle-app.setting 205 | 206 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 207 | !gradle-wrapper.jar 208 | 209 | # Avoid ignore Gradle wrappper properties 210 | !gradle-wrapper.properties 211 | 212 | # Cache of project 213 | .gradletasknamecache 214 | 215 | # Eclipse Gradle plugin generated files 216 | # Eclipse Core 217 | .project 218 | # JDT-specific (Eclipse Java Development Tools) 219 | .classpath 220 | 221 | ### Gradle Patch ### 222 | # Java heap dump 223 | *.hprof 224 | 225 | # End of https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,forgegradle,java,eclipse,netbeans 226 | -------------------------------------------------------------------------------- /addon.gradle: -------------------------------------------------------------------------------- 1 | if(!project.hasProperty("testMod")){ 2 | jar { 3 | sourceSets.main.java.exclude('net/smart/moving/test/**') 4 | } 5 | 6 | repositories { 7 | maven { url 'https://jitpack.io' } 8 | } 9 | 10 | dependencies { 11 | compile 'com.github.makamys:SmartRender:2.1:dev' 12 | 13 | String curseMaven = "https://cursemaven.com/" //Use https://cursemaven.com/ if this is down 14 | 15 | compileOnly deobf("https://b2.mcarchive.net/file/mcarchive/7c89d50fb4b9d8a7c9de628ce9b7119c40819d706fe2426c0960883c56da210b/Starminer1710-0.9.9.jar") 16 | compileOnly deobfMaven(curseMaven, "curse.maven:ships-mod-226731:2254977") 17 | compileOnly deobf('https://github.com/Roadhog360/Et-Futurum-Requiem/releases/download/2.4.2/Et_Futurum_Requiem-2.4.2-nomixin.jar') 18 | } 19 | } else { 20 | project.coreModClass = "" 21 | 22 | jar { 23 | sourceSets.main.java.include('net/smart/moving/test/**') 24 | include('net/smart/moving/test/**') 25 | classifier = 'test' 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/changelog.txt -------------------------------------------------------------------------------- /dependencies.gradle: -------------------------------------------------------------------------------- 1 | // Add your dependencies here 2 | 3 | dependencies { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | This minecraft mod, Smart Moving, including all parts herein, 2 | is licensed under the GNU General Public License Version 3 or later. 3 | 4 | Homepage: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1274224 5 | 6 | You should have received a copy of the GNU General Public License along with Smart Moving. 7 | If not, see . -------------------------------------------------------------------------------- /publish/.gitignore: -------------------------------------------------------------------------------- 1 | changelog.md 2 | gameVersions.txt -------------------------------------------------------------------------------- /publish/README.txt: -------------------------------------------------------------------------------- 1 | # How to publish 2 | sh ./build_and_release.sh $GITHUB_TOKEN [$CURSEFORGE_TOKEN] [$MODRINTH_TOKEN] -------------------------------------------------------------------------------- /publish/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.github.breadmoirai.github-release" version "2.2.12" 3 | id "com.matthewprenger.cursegradle" version "1.4.0" 4 | id "com.modrinth.minotaur" version "1.2.1" 5 | } 6 | 7 | import com.modrinth.minotaur.TaskModrinthUpload 8 | import groovy.json.JsonSlurper 9 | import okhttp3.OkHttpClient 10 | import java.util.concurrent.TimeUnit 11 | 12 | def getCommitVersion(){ 13 | try { 14 | def commitHashProc = "python3 ${projectDir}/get_version.py".execute() 15 | commitHashProc.waitFor() 16 | if(commitHashProc.exitValue() == 0){ 17 | def commitHash = commitHashProc.text.trim() 18 | 19 | return commitHash 20 | } else { 21 | println commitHashProc.err.text 22 | throw new Exception("get_version.py exited with non-zero return value") 23 | } 24 | } catch(Exception e){ 25 | println "Failed to run get_version.py: " + e.getMessage() 26 | } 27 | return "UNKNOWN" // fallback 28 | } 29 | 30 | def buildVersion = getCommitVersion() 31 | def changeLogFile = new File("${projectDir}/changelog.md") 32 | def changeLog = changeLogFile.exists() ? changeLogFile.getText('UTF-8') : "" 33 | ext.gameVersionsMap = new JsonSlurper().parseText(file("gameVersions.json").getText('UTF-8')) 34 | ext.gameVersions = gameVersionsMap.keySet() 35 | 36 | def githubOK = project.hasProperty("githubToken") 37 | def curseOK = project.hasProperty("curseToken") && project.hasProperty("gameVersion") 38 | def modrinthOK = project.hasProperty("modrinthToken") && project.hasProperty("gameVersion") 39 | 40 | def debugPublish = project.hasProperty("debugPublish") && project.debugPublish.toBoolean() 41 | 42 | def useVPrefixForTag = project.hasProperty("useVPrefixForTag") && project.useVPrefixForTag.toBoolean() 43 | 44 | task build {} 45 | task assemble {} 46 | 47 | if(githubOK){ 48 | githubRelease { 49 | token project.githubToken // This is your personal access token with Repo permissions 50 | // You get this from your user settings > developer settings > Personal Access Tokens 51 | owner project.githubOwner // default is the last part of your group. Eg group: "com.github.breadmoirai" => owner: "breadmoirai" 52 | repo project.githubRepo // by default this is set to your project name 53 | tagName ((useVPrefixForTag ? "v" : "") + "${buildVersion}") // by default this is set to "v${project.version}" 54 | targetCommitish "master" // by default this is set to "master" 55 | releaseName "${project.releaseName} ${buildVersion}" 56 | body changeLog // by default this is empty 57 | draft false // by default this is false 58 | prerelease false // by default this is false 59 | releaseAssets getFiles() // this points to which files you want to upload as assets with your release 60 | 61 | overwrite false // by default false; if set to true, will delete an existing release with the same tag and name 62 | dryRun debugPublish // by default false; you can use this to see what actions would be taken without making a release 63 | apiEndpoint "https://api.github.com" // should only change for github enterprise users 64 | client new OkHttpClient.Builder() 65 | .writeTimeout(5, TimeUnit.MINUTES) 66 | .readTimeout(5, TimeUnit.MINUTES) 67 | .build() // Added because I kept getting SocketTimeoutExceptions 68 | } 69 | } else { 70 | println("Not configuring GitHub publish because project arguments are missing.") 71 | } 72 | 73 | if(project.hasProperty("gameVersion")){ 74 | def gameVersion = project.gameVersion 75 | def baseVersion = toBaseVersion(gameVersion) 76 | def files = getFiles(baseVersion) 77 | def shortest = null 78 | files.each { 79 | if(shortest == null || it.name.length() < shortest.name.length()){ 80 | shortest = it 81 | } 82 | } 83 | def additionalFiles = files - shortest 84 | 85 | if(curseOK) { 86 | curseforge { 87 | apiKey = project.curseToken 88 | project { 89 | id = project.curseID 90 | changelogType = 'markdown' 91 | changelog = changeLog 92 | releaseType = 'release' 93 | addGameVersion gameVersion 94 | addGameVersion "Forge" 95 | 96 | mainArtifact(file(shortest)) { 97 | displayName = "${releaseName} ${buildVersion} for Minecraft ${gameVersion}" 98 | } 99 | additionalFiles.each { addArtifact(it) } 100 | } 101 | options { 102 | debug = debugPublish 103 | javaIntegration = false 104 | forgeGradleIntegration = false 105 | javaVersionAutoDetect = false 106 | } 107 | } 108 | } else { 109 | println("Not configuring CurseForge publish because project arguments are missing.") 110 | } 111 | 112 | if(modrinthOK) { 113 | task publishModrinth (type: TaskModrinthUpload) { 114 | token = project.modrinthToken 115 | projectId = project.modrinthID 116 | versionNumber = "$gameVersion-$buildVersion" 117 | versionName = "$gameVersion-$buildVersion" // the doc says this defaults to the versionNumber, but it defaulted to the string "undefined" for me so i'm setting it 118 | uploadFile = shortest 119 | addGameVersion(gameVersion) 120 | additionalFiles.each { addFile(it) } 121 | addLoader('forge') 122 | changelog = changeLog 123 | detectLoaders = false 124 | } 125 | } else { 126 | println("Not configuring Modrinth publish because project arguments are missing.") 127 | } 128 | } 129 | 130 | def toBaseVersion(ver){ 131 | return String.join(".", ver.tokenize(".").subList(0, 2)) 132 | } 133 | 134 | def getVersionProjectPath(ver){ 135 | if(project.versionedProjectDirectories.toBoolean()){ 136 | return "${projectDir}/../${ver}" 137 | } else { 138 | return "${projectDir}/.." 139 | } 140 | } 141 | 142 | def getFiles(ver) { 143 | def files = [] 144 | new File("${getVersionProjectPath(ver)}/build/libs").eachFile(groovy.io.FileType.FILES, { 145 | if(!(it.name.endsWith("-sources.jar") || it.name.endsWith("-dev.jar"))){ 146 | files << it 147 | } 148 | }) 149 | return files 150 | } 151 | 152 | def getFiles() { 153 | def files = [] 154 | project.gameVersions.collect({toBaseVersion(it)}).each { 155 | files += getFiles(it) 156 | } 157 | return files 158 | } 159 | 160 | // for debug 161 | task listFiles { 162 | doLast { 163 | project.gameVersions.collect({toBaseVersion(it)}).each { 164 | println("$it: ${getFiles(it)}") 165 | } 166 | } 167 | } 168 | 169 | def getBuildArgumentSets(ver) { 170 | def projectConfig = new Properties() 171 | projectConfig.load(file("../gradle.properties").newReader()) 172 | return projectConfig.enable_mixin ? ["", "-Pnomixin"] : [""] 173 | } 174 | 175 | project.gameVersions.each { ver -> 176 | def baseVer = toBaseVersion(ver) 177 | def dir = getVersionProjectPath(baseVer) 178 | task ("cleanBuild-$baseVer", type: Exec) { 179 | workingDir dir 180 | commandLine 'sh', '-c', "rm -f build/libs/* && " + String.join(" && ", getBuildArgumentSets(ver).collect({"./gradlew build ${it}"})) 181 | } 182 | } 183 | 184 | task cleanBuildAll(dependsOn: project.gameVersions.collect({"cleanBuild-${toBaseVersion(it)}"})) { 185 | 186 | } -------------------------------------------------------------------------------- /publish/build_and_release.sh: -------------------------------------------------------------------------------- 1 | if [ ! -s changelog.md ]; then 2 | echo "Changelog is empty, refusing to publish." 3 | exit 3 4 | fi 5 | 6 | if [[ $(git diff --cached --stat) != '' ]] 7 | then 8 | echo "There are staged uncommitted changes, refusing to publish." 9 | exit 2 10 | fi 11 | 12 | if [ "$#" -lt 1 ] || [ "$#" -gt 3 ] 13 | then 14 | echo "Usage: $0 GITHUB_TOKEN CURSEFORGE_TOKEN [MODRINTH_TOKEN]" 15 | exit 1 16 | fi 17 | 18 | # exit when any command fails 19 | set -e 20 | 21 | GITHUB_TOKEN=$1 22 | CURSEFORGE_TOKEN=$2 23 | MODRINTH_TOKEN=$3 24 | 25 | # build the release 26 | ./gradlew cleanBuildAll 27 | 28 | # release 29 | py prepare_publish.py 30 | ./gradlew githubRelease -PgithubToken=$GITHUB_TOKEN 31 | py update_updatejson.py 32 | 33 | if [ -n "$CURSEFORGE_TOKEN" ] 34 | then 35 | ./curseforge_all.sh -PcurseToken=$CURSEFORGE_TOKEN 36 | fi 37 | 38 | /dev/null > changelog.md 39 | 40 | if [ -n "$MODRINTH_TOKEN" ] 41 | then 42 | ./modrinth_all.sh -PmodrinthToken=$MODRINTH_TOKEN 43 | fi -------------------------------------------------------------------------------- /publish/curseforge_all.sh: -------------------------------------------------------------------------------- 1 | for proj in `cat gameVersions.txt`; do 2 | ./gradlew curseforge -PgameVersion=$proj $* 3 | done -------------------------------------------------------------------------------- /publish/gameVersions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.7.10": {} 3 | } 4 | -------------------------------------------------------------------------------- /publish/get_version.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | import os 4 | 5 | ver = None 6 | 7 | versionPath = os.path.dirname(sys.argv[0]) + "/version.txt" 8 | if os.path.exists(versionPath): 9 | with open(versionPath, "r", encoding="utf8") as fp: 10 | ver = fp.read() 11 | else: 12 | ver = subprocess.run(["git", "describe", "--tags", "--dirty"], capture_output=True, text=True).stdout or "UNKNOWN-" + subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, text=True).stdout or "UNKNOWN" 13 | 14 | ver = ver.strip() 15 | if ver[0] == "v": 16 | ver = ver[1:] 17 | 18 | print(ver) 19 | -------------------------------------------------------------------------------- /publish/gradle.properties: -------------------------------------------------------------------------------- 1 | githubOwner=makamys 2 | githubRepo=SmartMoving 3 | 4 | curseID= 5 | modrinthID= 6 | 7 | releaseName=Smart Moving 8 | 9 | versionedProjectDirectories=false 10 | updateJsonFullVersionFormat=false 11 | useVPrefixForTag=false 12 | -------------------------------------------------------------------------------- /publish/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/publish/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /publish/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 14 12:28:28 PDT 2015 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-7.1.1-bin.zip 7 | -------------------------------------------------------------------------------- /publish/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 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 | -------------------------------------------------------------------------------- /publish/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz 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 | -------------------------------------------------------------------------------- /publish/modrinth_all.sh: -------------------------------------------------------------------------------- 1 | for proj in `cat gameVersions.txt`; do 2 | ./gradlew publishModrinth -PgameVersion=$proj $* 3 | done -------------------------------------------------------------------------------- /publish/prepare_publish.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | open("gameVersions.txt", "w").write(" ".join(json.load(open("gameVersions.json", "r")).keys())) -------------------------------------------------------------------------------- /publish/update_updatejson.py: -------------------------------------------------------------------------------- 1 | import json 2 | import subprocess 3 | 4 | jsonPath = "../updatejson/update.json" 5 | 6 | # lol 7 | fullFormat = "updateJsonFullVersionFormat=true" in open("gradle.properties", "r", encoding="utf8").read() 8 | 9 | data = json.load(open(jsonPath, "r", encoding="utf8")) 10 | ver = subprocess.run(["python3", "get_version.py"], capture_output=True, text=True).stdout.strip() 11 | 12 | for gameVer in json.load(open("gameVersions.json", "r")).keys(): 13 | modVer = "{}".format(ver) if not fullFormat else "{}-{}".format(gameVer, ver) 14 | 15 | if gameVer not in data: 16 | data[gameVer] = {} 17 | 18 | data[gameVer][modVer] = "" 19 | data["promos"]["{}-latest".format(gameVer)] = modVer 20 | 21 | json.dump(data, open(jsonPath, "w", encoding="utf8"), indent=2) 22 | 23 | subprocess.run(["git", "add", jsonPath]) 24 | subprocess.run(["git", "commit", "-m", "[skip ci] Update update json"]) 25 | subprocess.run(["git", "push"]) -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Smart Moving 2 | 3 | This is as an unofficial fork of Divisor's [Smart Moving](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1274224-smart-moving) mod, based on version 15.6 for Minecraft 1.7.10. This fork's goal is to fix bugs and improve [compatibility](https://github.com/makamys/SmartMoving/wiki/Compatibility-List) with other mods. 4 | 5 | A fork of [PlayerAPI](https://github.com/makamys/PlayerAPI) is available which further improves compatibility. 6 | 7 | ## Description 8 | 9 | The Smart moving mod provides various additional moving possibilities: 10 | 11 | * Climbing only via gaps in the walls 12 | * Climbing ladders with different speeds depending on ladder coverage and/or neighbour blocks 13 | * Alternative animations for flying and falling 14 | * Climbing along ceilings and up vines 15 | * Jumping up & back while climbing 16 | * Configurable sneaking 17 | * Alternative swimming 18 | * Alternative diving 19 | * Alternative flying 20 | * Faster sprinting 21 | * Side & Back jumps 22 | * Charged jumps 23 | * Wall jumping 24 | * Head jumps 25 | * Crawling 26 | * Sliding 27 | 28 | Exact behavior depends on configuration (see chapter 'Configuration' below) 29 | 30 | 31 | 32 | ## Required Mods 33 | 34 | This mod requires 35 | 36 | * [Minecraft Forge](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.7.10.html) and 37 | * [PlayerAPI](https://github.com/makamys/PlayerAPI) core 1.3 or higher 38 | * [SmartRender](https://github.com/makamys/SmartRender) 2.1 or higher 39 | 40 | to be installed too. Additionally 41 | 42 | * [RenderPlayerAPI](https://github.com/makamys/RenderPlayerAPI) core 1.0 or higher 43 | 44 | can be installed to improve the compatibiltity with other mods. 45 | 46 | 47 | 48 | ## Configuration 49 | 50 | The file `smart_moving_options.txt` can be used to configure the behavior this mod. 51 | It is located in your `.minecraft` folder next to Minecraft's `options.txt`. 52 | If does not exist at Minecraft startup time it is automatically generated. 53 | 54 | You can use its content to manipulate this mod's various features. 55 | -------------------------------------------------------------------------------- /readme_server.txt: -------------------------------------------------------------------------------- 1 | ======================= 2 | Smart Moving Server Mod 3 | ======================= 4 | 5 | Version 15.6 for Minecraft Server 1.7.10 6 | 7 | by Divisor 8 | 9 | 10 | 11 | Description 12 | =========== 13 | 14 | The Smart Moving Server mod provides smart moving specific communication between different SMP clients. 15 | 16 | Additionally using a SMP server with this mod avoids bugs that can happen when using Smart Moving clients with standard SMP servers. 17 | 18 | In summary using a SMP server with Smart Moving provides the following features: 19 | * crawling into small holes without taking damage 20 | * climbing down without suffering ground arrival damage 21 | * smart moving anmiations for the other players 22 | * correct item placement while being small sized 23 | 24 | 25 | 26 | Required Mods 27 | ============= 28 | 29 | This mod requires 30 | 31 | * MinecraftForge and 32 | * Player API core 1.3 or higher 33 | 34 | to be installed too. 35 | 36 | 37 | 38 | Installation 39 | ============ 40 | 41 | Move the Smart Moving file "${%mod.moving.file}" into the subfolder "mods" of your Minecraft server installation folder. In case this folder does not exist, create it or run your Minecraft Forge server at least once. 42 | 43 | Don't forget to: 44 | * ensure you have the latest version of Minecraft Forge server installed! 45 | * ensure you have the latest version of PlayerAPI core installed! 46 | * ensure all your clients have Minecraft Forge client installed! 47 | 48 | 49 | In any case, NEVER forget: ALWAYS back up your stuff! 50 | 51 | 52 | 53 | Development Installation 54 | ======================== 55 | 56 | The details of how to install Smart Moving at a Minecraft Forge development environent are described in the section "Development Installation" of the file "development.txt". 57 | 58 | 59 | 60 | Configuration 61 | ============= 62 | 63 | The file "smart_moving_options.txt" can be used to configure the behavior this mod. 64 | It is located in your minecraft server's working directory. 65 | If does not exist at Minecraft server startup time it is automatically generated. 66 | 67 | You can use its content to manipulate this mod's various features on all connected clients. 68 | 69 | 70 | 71 | SBC Support 72 | =========== 73 | Smart Moving provides support for Simple Block code (http://dev.bukkit.org/server-mods/sbc/) 74 | Have a look at the website to find the exact codes to block specific Smart Moving features for server players. -------------------------------------------------------------------------------- /repositories.gradle: -------------------------------------------------------------------------------- 1 | // Add any additional repositories for your dependencies here 2 | 3 | repositories { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreClassVisitor.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.io.*; 21 | import java.util.*; 22 | 23 | import org.objectweb.asm.*; 24 | 25 | public final class SmartCoreClassVisitor extends ClassVisitor 26 | { 27 | public static byte[] transform(byte[] bytes, List transformations) 28 | { 29 | try 30 | { 31 | ByteArrayInputStream in = new ByteArrayInputStream(bytes); 32 | ClassReader cr = new ClassReader(in); 33 | ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); 34 | SmartCoreClassVisitor p = new SmartCoreClassVisitor(cw, transformations); 35 | 36 | cr.accept(p, 0); 37 | 38 | byte[] result = cw.toByteArray(); 39 | in.close(); 40 | return result; 41 | } 42 | catch(IOException ioe) 43 | { 44 | throw new RuntimeException(ioe); 45 | } 46 | } 47 | 48 | private final List transformations; 49 | 50 | public SmartCoreClassVisitor(ClassVisitor classVisitor, List transformations) 51 | { 52 | super(262144, classVisitor); 53 | this.transformations = transformations; 54 | } 55 | 56 | @Override 57 | public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) 58 | { 59 | MethodVisitor base = super.visitMethod(access, name, desc, signature, exceptions); 60 | 61 | for(SmartCoreTransformation transformation : transformations) 62 | if(name.equals(transformation.methodName) && desc.equals(transformation.getMethodDesc())) 63 | return new SmartCoreMethodVisitor(base, transformation); 64 | 65 | return base; 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreContainer.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.util.*; 21 | import com.google.common.eventbus.*; 22 | import cpw.mods.fml.common.*; 23 | 24 | public class SmartCoreContainer extends DummyModContainer 25 | { 26 | public SmartCoreContainer() 27 | { 28 | super(createMetadata()); 29 | } 30 | 31 | @Override 32 | public boolean registerBus(EventBus bus, LoadController controller) 33 | { 34 | return true; 35 | } 36 | 37 | private static ModMetadata createMetadata() 38 | { 39 | ModMetadata meta = new ModMetadata(); 40 | 41 | meta.modId = "SmartCore"; 42 | meta.name = SmartCoreInfo.ModName; 43 | meta.version = SmartCoreInfo.ModVersion; 44 | meta.description = "Adds some core hooks required by Smart Moving"; 45 | meta.url = "http://www.minecraftforum.net/topic/738498-"; 46 | meta.authorList = Arrays.asList(new String[] { "Divisor" }); 47 | 48 | return meta; 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreEventHandler.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.util.*; 21 | 22 | import net.minecraft.client.multiplayer.*; 23 | import net.minecraft.entity.player.*; 24 | import net.minecraft.item.ItemStack; 25 | import net.minecraft.network.*; 26 | import net.minecraft.server.management.*; 27 | import net.minecraft.util.Vec3; 28 | import net.minecraft.world.World; 29 | import net.minecraft.network.play.client.*; 30 | 31 | public class SmartCoreEventHandler 32 | { 33 | private final static Set handlers = new HashSet(); 34 | 35 | public static void Add(SmartCoreEventHandler handler) 36 | { 37 | handlers.add(handler); 38 | } 39 | 40 | public static void Remove(SmartCoreEventHandler handler) 41 | { 42 | handlers.remove(handler); 43 | } 44 | 45 | @SuppressWarnings("unused") 46 | public static void NetHandlerPlayServer_beforeProcessPlayer(NetHandlerPlayServer netServerHandler, C03PacketPlayer packetPlayer) 47 | { 48 | for(SmartCoreEventHandler eventHandler : handlers) 49 | eventHandler.beforeProcessPlayer(netServerHandler); 50 | } 51 | 52 | @SuppressWarnings("unused") 53 | public static void NetHandlerPlayServer_afterProcessPlayer(NetHandlerPlayServer netServerHandler, C03PacketPlayer packetPlayer) 54 | { 55 | for(SmartCoreEventHandler eventHandler : handlers) 56 | eventHandler.afterProcessPlayer(netServerHandler); 57 | } 58 | 59 | public static void NetHandlerPlayServer_beforeProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 60 | { 61 | for(SmartCoreEventHandler eventHandler : handlers) 62 | eventHandler.beforeProcessPlayerBlockPlacement(netServerHandler, packet15place); 63 | } 64 | 65 | public static void NetHandlerPlayServer_afterProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 66 | { 67 | for(SmartCoreEventHandler eventHandler : handlers) 68 | eventHandler.afterProcessPlayerBlockPlacement(netServerHandler, packet15place); 69 | } 70 | 71 | @SuppressWarnings("unused") 72 | public static void PlayerControllerMP_beforeOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP, World world, ItemStack itemStack, int integer1, int integer2, int integer3, int integer4, Vec3 vec3) 73 | { 74 | for(SmartCoreEventHandler eventHandler : handlers) 75 | eventHandler.beforeOnPlayerRightClick(playerControllerMP, entityPlayerSP); 76 | } 77 | 78 | @SuppressWarnings("unused") 79 | public static void PlayerControllerMP_afterOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP, World world, ItemStack itemStack, int integer1, int integer2, int integer3, int integer4, Vec3 vec3) 80 | { 81 | for(SmartCoreEventHandler eventHandler : handlers) 82 | eventHandler.afterOnPlayerRightClick(playerControllerMP, entityPlayerSP); 83 | } 84 | 85 | @SuppressWarnings("unused") 86 | public static void ItemInWorldManager_beforeActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer, World world, ItemStack itemStack, int integer1, int integer2, int integer3, int integer4, float float1, float float2, float float3) 87 | { 88 | for(SmartCoreEventHandler eventHandler : handlers) 89 | eventHandler.beforeActivateBlockOrUseItem(itemInWorldManager, entityPlayer); 90 | } 91 | 92 | @SuppressWarnings("unused") 93 | public static void ItemInWorldManager_afterActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer, World world, ItemStack itemStack, int integer1, int integer2, int integer3, int integer4, float float1, float float2, float float3) 94 | { 95 | for(SmartCoreEventHandler eventHandler : handlers) 96 | eventHandler.afterActivateBlockOrUseItem(itemInWorldManager, entityPlayer); 97 | } 98 | 99 | @SuppressWarnings("unused") 100 | public void beforeProcessPlayer(NetHandlerPlayServer netServerHandler) 101 | { 102 | } 103 | 104 | @SuppressWarnings("unused") 105 | public void afterProcessPlayer(NetHandlerPlayServer netServerHandler) 106 | { 107 | } 108 | 109 | @SuppressWarnings("unused") 110 | public void beforeProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 111 | { 112 | } 113 | 114 | @SuppressWarnings("unused") 115 | public void afterProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 116 | { 117 | } 118 | 119 | @SuppressWarnings("unused") 120 | public void beforeOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP) 121 | { 122 | } 123 | 124 | @SuppressWarnings("unused") 125 | public void afterOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP) 126 | { 127 | } 128 | 129 | @SuppressWarnings("unused") 130 | public void beforeActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer) 131 | { 132 | } 133 | 134 | @SuppressWarnings("unused") 135 | public void afterActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer) 136 | { 137 | } 138 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreInfo.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | public class SmartCoreInfo 21 | { 22 | public static final String ModName = "Smart Core"; 23 | public static final String ModVersion = SmartCorePlugin.Version; 24 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreMethodVisitor.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import org.objectweb.asm.*; 21 | 22 | public class SmartCoreMethodVisitor extends MethodVisitor 23 | { 24 | private final SmartCoreTransformation transformation; 25 | 26 | public SmartCoreMethodVisitor(MethodVisitor paramMethodVisitor, SmartCoreTransformation transformation) 27 | { 28 | super(262144, paramMethodVisitor); 29 | 30 | this.transformation = transformation; 31 | 32 | invokeHook(transformation.beforeHookMethodName); 33 | } 34 | 35 | @Override 36 | public void visitInsn(int opcode) 37 | { 38 | if(opcode == Opcodes.RETURN || opcode == Opcodes.IRETURN || opcode == Opcodes.LRETURN ||opcode == Opcodes.FRETURN || opcode == Opcodes.DRETURN || opcode == Opcodes.ARETURN) 39 | invokeHook(transformation.afterHookMethodName); 40 | super.visitInsn(opcode); 41 | } 42 | 43 | private void invokeHook(String hookName) 44 | { 45 | if (hookName == null) 46 | return; 47 | 48 | mv.visitVarInsn(Opcodes.ALOAD, 0); 49 | int offset = 1; 50 | for(int i=0; i. 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.util.*; 21 | 22 | import cpw.mods.fml.relauncher.*; 23 | 24 | @IFMLLoadingPlugin.MCVersion("1.7.10") 25 | public class SmartCorePlugin implements IFMLLoadingPlugin 26 | { 27 | public static String Version = "1.0.3"; 28 | 29 | public static boolean isObfuscated; 30 | 31 | @Override 32 | public String[] getASMTransformerClass() 33 | { 34 | return new String[] { "net.smart.core.SmartCoreTransformer" }; 35 | } 36 | 37 | @Override 38 | public String getAccessTransformerClass() 39 | { 40 | return null; 41 | } 42 | 43 | @Override 44 | public String getModContainerClass() 45 | { 46 | return "net.smart.core.SmartCoreContainer"; 47 | } 48 | 49 | @Override 50 | public String getSetupClass() 51 | { 52 | return null; 53 | } 54 | 55 | @Override 56 | public void injectData(Map data) 57 | { 58 | isObfuscated = (Boolean)data.get("runtimeDeobfuscationEnabled"); 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/core/SmartCoreTransformation.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.util.*; 21 | 22 | public class SmartCoreTransformation 23 | { 24 | public final String className; 25 | public final String methodName; 26 | public final String[] parameterTypeNames; 27 | public final String returnType; 28 | public final String hookClassName; 29 | public final String beforeHookMethodName; 30 | public final String afterHookMethodName; 31 | 32 | public SmartCoreTransformation(String className, String methodName, String[] parameterTypeNames, String returnType, String hookClassName, String beforeHookMethodName, String afterHookMethodName) 33 | { 34 | this.className = className; 35 | this.methodName = methodName; 36 | this.parameterTypeNames = parameterTypeNames; 37 | this.returnType = returnType; 38 | this.hookClassName = hookClassName; 39 | this.beforeHookMethodName = beforeHookMethodName; 40 | this.afterHookMethodName = afterHookMethodName; 41 | } 42 | 43 | private static String getDescription(String type) 44 | { 45 | if(type == null || type == "void") 46 | return "V"; 47 | if(type.endsWith("[]")) 48 | return "[" + getDescription(type.substring(0, type.length() - 2)); 49 | if(type.equals("boolean")) 50 | return "Z"; 51 | if(type.equals("byte")) 52 | return "B"; 53 | if(type.equals("short")) 54 | return "S"; 55 | if(type.equals("int")) 56 | return "I"; 57 | if(type.equals("float")) 58 | return "F"; 59 | if(type.equals("long")) 60 | return "J"; 61 | if(type.equals("double")) 62 | return "D"; 63 | return "L" + type.replace(".", "/") + ";"; 64 | } 65 | 66 | private static String getDescriptions(String[] parameterTypes) 67 | { 68 | String result = ""; 69 | for(int i=0; i. 16 | // ================================================================== 17 | 18 | package net.smart.core; 19 | 20 | import java.util.*; 21 | 22 | import net.minecraft.launchwrapper.*; 23 | 24 | public class SmartCoreTransformer implements IClassTransformer 25 | { 26 | @Override 27 | public byte[] transform(String name, String transformedName, byte[] bytes) 28 | { 29 | List list = null; 30 | for(SmartCoreTransformation transformation : _transformations) 31 | if(transformedName.equals(transformation.className)) 32 | (list == null ? (list = new ArrayList()) : list).add(transformation); 33 | 34 | if(list != null) 35 | return SmartCoreClassVisitor.transform(bytes, list); 36 | return bytes; 37 | } 38 | 39 | private static final SmartCoreTransformation[] _transformations = new SmartCoreTransformation[] 40 | { 41 | new SmartCoreTransformation 42 | ( 43 | "net.minecraft.network.NetHandlerPlayServer", 44 | Name("processPlayer", "a"), 45 | new String[] 46 | { 47 | Name("net.minecraft.network.play.client.C03PacketPlayer", "jd") 48 | }, 49 | null, 50 | "net.smart.core.SmartCoreEventHandler", 51 | "NetHandlerPlayServer_beforeProcessPlayer", 52 | "NetHandlerPlayServer_afterProcessPlayer" 53 | ), 54 | new SmartCoreTransformation 55 | ( 56 | "net.minecraft.network.NetHandlerPlayServer", 57 | Name("processPlayerBlockPlacement", "a"), 58 | new String[] 59 | { 60 | Name("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement", "jo") 61 | }, 62 | null, 63 | "net.smart.core.SmartCoreEventHandler", 64 | "NetHandlerPlayServer_beforeProcessPlayerBlockPlacement", 65 | "NetHandlerPlayServer_afterProcessPlayerBlockPlacement" 66 | ), 67 | new SmartCoreTransformation 68 | ( 69 | Name("net.minecraft.client.multiplayer.PlayerControllerMP", "bje"), 70 | Name("onPlayerRightClick", "a"), 71 | new String[] 72 | { 73 | Name("net.minecraft.entity.player.EntityPlayer", "yz"), 74 | Name("net.minecraft.world.World", "ahb"), 75 | Name("net.minecraft.item.ItemStack", "add"), 76 | "int", 77 | "int", 78 | "int", 79 | "int", 80 | Name("net.minecraft.util.Vec3", "azw") 81 | }, 82 | "boolean", 83 | "net.smart.core.SmartCoreEventHandler", 84 | "PlayerControllerMP_beforeOnPlayerRightClick", 85 | "PlayerControllerMP_afterOnPlayerRightClick" 86 | ), 87 | new SmartCoreTransformation 88 | ( 89 | Name("net.minecraft.server.management.ItemInWorldManager", "qx"), 90 | Name("activateBlockOrUseItem", "a"), 91 | new String[] 92 | { 93 | Name("net.minecraft.entity.player.EntityPlayer", "yz"), 94 | Name("net.minecraft.world.World", "ahb"), 95 | Name("net.minecraft.item.ItemStack", "add"), 96 | "int", 97 | "int", 98 | "int", 99 | "int", 100 | "float", 101 | "float", 102 | "float" 103 | }, 104 | "boolean", 105 | "net.smart.core.SmartCoreEventHandler", 106 | "ItemInWorldManager_beforeActivateBlockOrUseItem", 107 | "ItemInWorldManager_afterActivateBlockOrUseItem" 108 | ) 109 | }; 110 | 111 | private static String Name(String deobfuscated, String obfuscated) 112 | { 113 | return SmartCorePlugin.isObfuscated ? obfuscated : deobfuscated; 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/Button.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import org.lwjgl.input.Keyboard; 21 | import org.lwjgl.input.Mouse; 22 | 23 | import net.minecraft.client.*; 24 | import net.minecraft.client.gui.*; 25 | import net.minecraft.client.settings.*; 26 | 27 | public class Button extends SmartMovingContext 28 | { 29 | public boolean Pressed; 30 | public boolean WasPressed; 31 | 32 | public boolean StartPressed; 33 | public boolean StopPressed; 34 | 35 | public void update(KeyBinding binding) 36 | { 37 | update(Minecraft.getMinecraft().inGameHasFocus && isKeyDown(binding)); 38 | } 39 | 40 | public void update(int keyCode) 41 | { 42 | update(Minecraft.getMinecraft().inGameHasFocus && isKeyDown(keyCode)); 43 | } 44 | 45 | public void update(boolean pressed) 46 | { 47 | WasPressed = Pressed; 48 | Pressed = pressed; 49 | 50 | StartPressed = !WasPressed && Pressed; 51 | StopPressed = WasPressed && !Pressed; 52 | } 53 | 54 | private static boolean isKeyDown(KeyBinding keyBinding) 55 | { 56 | return isKeyDown(keyBinding, keyBinding.isPressed()); 57 | } 58 | 59 | private static boolean isKeyDown(KeyBinding keyBinding, boolean wasDown) 60 | { 61 | GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; 62 | if(currentScreen == null || currentScreen.allowUserInput) 63 | return isKeyDown(keyBinding.getKeyCode()); 64 | return wasDown; 65 | } 66 | 67 | private static boolean isKeyDown(int keyCode) 68 | { 69 | if(keyCode >= 0) 70 | return Keyboard.isKeyDown(keyCode); 71 | return Mouse.isButtonDown(keyCode + 100); 72 | } 73 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/ClimbGap.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.block.*; 21 | 22 | public class ClimbGap 23 | { 24 | public Block Block; 25 | public int Meta; 26 | public boolean CanStand; 27 | public boolean MustCrawl; 28 | public Orientation Direction; 29 | public boolean SkipGaps; 30 | 31 | public ClimbGap() 32 | { 33 | reset(); 34 | } 35 | 36 | public void reset() 37 | { 38 | Block = null; 39 | Meta = -1; 40 | CanStand = false; 41 | MustCrawl = false; 42 | Direction = null; 43 | SkipGaps = false; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/Compat.java: -------------------------------------------------------------------------------- 1 | package net.smart.moving; 2 | 3 | import cpw.mods.fml.common.Loader; 4 | import cuchaz.ships.EntityShip; 5 | import cuchaz.ships.ShipLocator; 6 | import ganymedes01.etfuturum.api.elytra.IElytraPlayer; 7 | import jp.mc.ancientred.starminer.api.Gravity; 8 | import jp.mc.ancientred.starminer.api.GravityDirection; 9 | import jp.mc.ancientred.starminer.core.entity.ExtendedPropertyGravity; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.entity.Entity; 12 | import net.minecraft.entity.player.EntityPlayer; 13 | 14 | public class Compat { 15 | 16 | private static boolean isStarMinerPresent; 17 | private static boolean isShipsModPresent; 18 | private static boolean isEtFuturumRequiemPresent; 19 | private static boolean isEtFuturumRequiemElytraPresent; 20 | 21 | public static void init() 22 | { 23 | isStarMinerPresent = Loader.isModLoaded("modJ_StarMiner"); 24 | isShipsModPresent = Loader.isModLoaded("cuchaz.ships"); 25 | isEtFuturumRequiemPresent = Loader.isModLoaded("etfuturum"); 26 | isEtFuturumRequiemElytraPresent = isEtFuturumRequiemPresent && classExists("ganymedes01.etfuturum.api.elytra.IElytraPlayer"); 27 | } 28 | 29 | private static boolean classExists(String className) 30 | { 31 | return Compat.class.getClassLoader().getResourceAsStream(className.replaceAll("\\.", "/") + ".class") != null; 32 | } 33 | 34 | public static boolean isBlockedByIncompatibility(EntityPlayer sp) 35 | { 36 | return isStarMinerGravitized(sp) || isOnCuchazShip(sp) || isElytraFlying(sp) || isSpectator(sp); 37 | } 38 | 39 | public static boolean isStarMinerGravitized(Entity player) 40 | { 41 | return isStarMinerPresent && StarMinerCompat.isGravitized(player); 42 | } 43 | 44 | public static boolean isOnCuchazShip(Entity player) 45 | { 46 | return isShipsModPresent && ShipsCompat.isOnShip(player); 47 | } 48 | 49 | public static boolean isElytraFlying(Entity player) 50 | { 51 | return isEtFuturumRequiemElytraPresent && EtFuturumRequiemElytraCompat.isElytraFlying(player); 52 | } 53 | 54 | public static boolean isSpectator(Entity player) 55 | { 56 | return isEtFuturumRequiemPresent && Minecraft.getMinecraft().playerController.currentGameType.getID() == 3; 57 | } 58 | 59 | private static class StarMinerCompat 60 | { 61 | public static boolean isGravitized(Entity player) 62 | { 63 | Gravity gravity = ExtendedPropertyGravity.getExtendedPropertyGravity(player); 64 | return gravity.gravityDirection != GravityDirection.upTOdown_YN || gravity.isZeroGravity(); 65 | } 66 | } 67 | 68 | private static class ShipsCompat 69 | { 70 | public static boolean isOnShip(Entity player) 71 | { 72 | for (EntityShip ship : ShipLocator.getFromEntityLocation(player)) 73 | { 74 | if (ship.getCollider().isEntityAboard(player)) 75 | { 76 | return true; 77 | } 78 | } 79 | return false; 80 | } 81 | } 82 | 83 | private static class EtFuturumRequiemElytraCompat 84 | { 85 | public static boolean isElytraFlying(Entity player) 86 | { 87 | return player instanceof IElytraPlayer && ((IElytraPlayer)player).etfu$isElytraFlying(); 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/FeetClimbing.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.io.*; 21 | 22 | public class FeetClimbing 23 | { 24 | public static final int DownStep = 1; 25 | public static final int NoStep = 0; 26 | 27 | public static FeetClimbing None = new FeetClimbing(-3); 28 | public static FeetClimbing BaseHold = new FeetClimbing(-2); 29 | public static FeetClimbing BaseWithHands = new FeetClimbing(-1); 30 | public static FeetClimbing TopWithHands = new FeetClimbing(0); 31 | public static FeetClimbing SlowUpWithHoldWithoutHands = new FeetClimbing(1); 32 | public static FeetClimbing SlowUpWithSinkWithoutHands = new FeetClimbing(2); 33 | public static FeetClimbing FastUp = new FeetClimbing(3); 34 | 35 | private int _value; 36 | 37 | private FeetClimbing(int value) 38 | { 39 | _value = value; 40 | } 41 | 42 | public boolean IsRelevant() 43 | { 44 | return _value > None._value; 45 | } 46 | 47 | public boolean IsIndependentlyRelevant() 48 | { 49 | return _value > BaseWithHands._value; 50 | } 51 | 52 | public boolean IsUp() 53 | { 54 | return this == SlowUpWithHoldWithoutHands || this == SlowUpWithSinkWithoutHands || this == FastUp; 55 | } 56 | 57 | public FeetClimbing max(FeetClimbing other, ClimbGap inout_thisClimbGap, ClimbGap otherClimbGap) 58 | { 59 | if(!otherClimbGap.SkipGaps) 60 | { 61 | inout_thisClimbGap.CanStand |= otherClimbGap.CanStand; 62 | inout_thisClimbGap.MustCrawl |= otherClimbGap.MustCrawl; 63 | } 64 | if(_value < other._value) 65 | { 66 | inout_thisClimbGap.Block = otherClimbGap.Block; 67 | inout_thisClimbGap.Meta = otherClimbGap.Meta; 68 | inout_thisClimbGap.Direction = otherClimbGap.Direction; 69 | } 70 | return get(Math.max(_value, other._value)); 71 | } 72 | 73 | @Override 74 | public String toString() 75 | { 76 | if(_value <= None._value) 77 | return "None"; 78 | if(_value == BaseHold._value) 79 | return "BaseHold"; 80 | if(_value == BaseWithHands._value) 81 | return "BaseWithHands"; 82 | if(_value == TopWithHands._value) 83 | return "TopWithHands"; 84 | if(_value == SlowUpWithHoldWithoutHands._value) 85 | return "SlowUpWithHoldWithoutHands"; 86 | if(_value == SlowUpWithSinkWithoutHands._value) 87 | return "SlowUpWithSinkWithoutHands"; 88 | return "FastUp"; 89 | } 90 | 91 | public void print(String name) 92 | { 93 | PrintStream stream = System.err; 94 | if(name != null) 95 | stream.print(name + " = "); 96 | stream.println(this); 97 | } 98 | 99 | private static FeetClimbing get(int value) 100 | { 101 | if(value <= None._value) 102 | return None; 103 | if(value == BaseHold._value) 104 | return BaseHold; 105 | if(value == BaseWithHands._value) 106 | return BaseWithHands; 107 | if(value == TopWithHands._value) 108 | return TopWithHands; 109 | if(value == SlowUpWithHoldWithoutHands._value) 110 | return SlowUpWithHoldWithoutHands; 111 | if(value == SlowUpWithSinkWithoutHands._value) 112 | return SlowUpWithSinkWithoutHands; 113 | return FastUp; 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/HandsClimbing.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.io.*; 21 | 22 | public class HandsClimbing 23 | { 24 | public static final int MiddleGrab = 2; 25 | public static final int UpGrab = 1; 26 | public static final int NoGrab = 0; 27 | 28 | public static HandsClimbing None = new HandsClimbing(-3); 29 | public static HandsClimbing Sink = new HandsClimbing(-2); 30 | public static HandsClimbing TopHold = new HandsClimbing(-1); 31 | public static HandsClimbing BottomHold = new HandsClimbing(0); 32 | public static HandsClimbing Up = new HandsClimbing(1); 33 | public static HandsClimbing FastUp = new HandsClimbing(2); 34 | 35 | private int _value; 36 | 37 | private HandsClimbing(int value) 38 | { 39 | _value = value; 40 | } 41 | 42 | public boolean IsRelevant() 43 | { 44 | return _value > None._value; 45 | } 46 | 47 | public boolean IsUp() 48 | { 49 | return this == Up || this == FastUp; 50 | } 51 | 52 | public HandsClimbing ToUp() 53 | { 54 | if(this == BottomHold) 55 | return Up; 56 | return this; 57 | } 58 | 59 | public HandsClimbing ToDown() 60 | { 61 | if(this == TopHold) 62 | return Sink; 63 | return this; 64 | } 65 | 66 | public HandsClimbing max(HandsClimbing other, ClimbGap inout_thisClimbGap, ClimbGap otherClimbGap) 67 | { 68 | if(!otherClimbGap.SkipGaps) 69 | { 70 | inout_thisClimbGap.CanStand |= otherClimbGap.CanStand; 71 | inout_thisClimbGap.MustCrawl |= otherClimbGap.MustCrawl; 72 | } 73 | if(_value < other._value) 74 | { 75 | inout_thisClimbGap.Block = otherClimbGap.Block; 76 | inout_thisClimbGap.Meta = otherClimbGap.Meta; 77 | inout_thisClimbGap.Direction = otherClimbGap.Direction; 78 | } 79 | return get(Math.max(_value, other._value)); 80 | } 81 | 82 | @Override 83 | public String toString() 84 | { 85 | if(_value <= None._value) 86 | return "None"; 87 | if(_value == Sink._value) 88 | return "Sink"; 89 | if(_value == BottomHold._value) 90 | return "BottomHold"; 91 | if(_value == TopHold._value) 92 | return "TopHold"; 93 | if(_value == Up._value) 94 | return "Up"; 95 | return "FastUp"; 96 | } 97 | 98 | public void print(String name) 99 | { 100 | PrintStream stream = System.err; 101 | if(name != null) 102 | stream.print(name + " = "); 103 | stream.println(this); 104 | } 105 | 106 | private static HandsClimbing get(int value) 107 | { 108 | if(value <= None._value) 109 | return None; 110 | if(value == Sink._value) 111 | return Sink; 112 | if(value == BottomHold._value) 113 | return BottomHold; 114 | if(value == TopHold._value) 115 | return TopHold; 116 | if(value == Up._value) 117 | return Up; 118 | return FastUp; 119 | } 120 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/IEntityPlayerMP.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.util.*; 21 | 22 | import cpw.mods.fml.common.network.internal.FMLProxyPacket; 23 | 24 | import net.minecraft.entity.*; 25 | import net.minecraft.util.*; 26 | 27 | public interface IEntityPlayerMP extends IPacketSender 28 | { 29 | void sendPacketToTrackedPlayers(FMLProxyPacket packet); 30 | 31 | String getUsername(); 32 | 33 | void resetFallDistance(); 34 | 35 | void resetTicksForFloatKick(); 36 | 37 | void setHeight(float height); 38 | 39 | double getMinY(); 40 | 41 | float getHeight(); 42 | 43 | void setMaxY(double maxY); 44 | 45 | boolean localIsEntityInsideOpaqueBlock(); 46 | 47 | SmartMovingServer getMoving(); 48 | 49 | IEntityPlayerMP[] getAllPlayers(); 50 | 51 | float doGetHealth(); 52 | 53 | AxisAlignedBB getBox(); 54 | 55 | AxisAlignedBB expandBox(AxisAlignedBB box, double x, double y, double z); 56 | 57 | List getEntitiesExcludingPlayer(AxisAlignedBB box); 58 | 59 | boolean isDeadEntity(Entity entity); 60 | 61 | void onCollideWithPlayer(Entity entity); 62 | 63 | void localAddExhaustion(float exhaustion); 64 | 65 | void localAddMovementStat(double x, double y, double z); 66 | 67 | void localPlaySound(String soundId, float volume, float pitch); 68 | 69 | boolean localIsSneaking(); 70 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/IEntityPlayerSP.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.block.material.*; 21 | import net.minecraft.client.*; 22 | import net.minecraft.entity.player.EntityPlayer.*; 23 | import net.minecraft.nbt.*; 24 | 25 | public interface IEntityPlayerSP 26 | { 27 | SmartMoving getMoving(); 28 | 29 | boolean getSleepingField(); 30 | 31 | boolean getIsJumpingField(); 32 | 33 | boolean getIsInWebField(); 34 | 35 | void setIsInWebField(boolean b); 36 | 37 | Minecraft getMcField(); 38 | 39 | void setMoveForwardField(float f); 40 | 41 | void setMoveStrafingField(float f); 42 | 43 | void setIsJumpingField(boolean flag); 44 | 45 | void localMoveEntity(double d, double d1, double d2); 46 | 47 | EnumStatus localSleepInBedAt(int i, int j, int k); 48 | 49 | float localGetBrightness(float f); 50 | 51 | int localGetBrightnessForRender(float f); 52 | 53 | void localUpdateEntityActionState(); 54 | 55 | boolean localIsInsideOfMaterial(Material material); 56 | 57 | void localWriteEntityToNBT(NBTTagCompound nBTTagCompound); 58 | 59 | boolean localIsSneaking(); 60 | 61 | float localGetFOVMultiplier(); 62 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/ILocalUserNameProvider.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | public interface ILocalUserNameProvider 21 | { 22 | String getLocalConfigUserName(); 23 | 24 | String getLocalSpeedUserName(); 25 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/IPacketReceiver.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import cpw.mods.fml.common.network.internal.*; 21 | 22 | public interface IPacketReceiver 23 | { 24 | boolean processStatePacket(FMLProxyPacket packet, IEntityPlayerMP player, int entityId, long state); 25 | 26 | boolean processConfigInfoPacket(FMLProxyPacket packet, IEntityPlayerMP player, String info); 27 | 28 | boolean processConfigContentPacket(FMLProxyPacket packet, IEntityPlayerMP player, String[] content, String username); 29 | 30 | boolean processConfigChangePacket(FMLProxyPacket packet, IEntityPlayerMP player); 31 | 32 | boolean processSpeedChangePacket(FMLProxyPacket packet, IEntityPlayerMP player, int difference, String username); 33 | 34 | boolean processHungerChangePacket(FMLProxyPacket packet, IEntityPlayerMP player, float hunger); 35 | 36 | boolean processSoundPacket(FMLProxyPacket packet, IEntityPlayerMP player, String soundId, float distance, float pitch); 37 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/IPacketSender.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | public interface IPacketSender 21 | { 22 | void sendPacket(byte[] byteArray); 23 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/ISmartMovingClient.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | public interface ISmartMovingClient 21 | { 22 | float getMaximumExhaustion(); 23 | 24 | float getMaximumUpJumpCharge(); 25 | 26 | float getMaximumHeadJumpCharge(); 27 | 28 | void setMaximumExhaustionValue(String key, float value); 29 | 30 | float getMaximumExhaustionValue(String key); 31 | 32 | boolean removeMaximumExhaustionValue(String key); 33 | 34 | void setNativeUserInterfaceDrawing(boolean value); 35 | 36 | boolean getNativeUserInterfaceDrawing(); 37 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/ISmartMovingSelf.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | public interface ISmartMovingSelf 21 | { 22 | float getExhaustion(); 23 | 24 | float getUpJumpCharge(); 25 | 26 | float getHeadJumpCharge(); 27 | 28 | void addExhaustion(float factor); 29 | 30 | void setMaxExhaustionForAction(float maxExhaustionForAction); 31 | 32 | void setMaxExhaustionToStartAction(float maxExhaustionToStartAction); 33 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/LocalUserNameProvider.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.client.*; 21 | 22 | public class LocalUserNameProvider extends SmartMovingContext implements ILocalUserNameProvider 23 | { 24 | @Override 25 | public String getLocalConfigUserName() 26 | { 27 | return Options._localUserHasChangeConfigRight.value ? Minecraft.getMinecraft().thePlayer.getGameProfile().getName() : null; 28 | } 29 | 30 | @Override 31 | public String getLocalSpeedUserName() 32 | { 33 | return Options._localUserHasChangeSpeedRight.value ? Minecraft.getMinecraft().thePlayer.getGameProfile().getName() : null; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMoving.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.block.*; 21 | import net.minecraft.client.*; 22 | import net.minecraft.client.particle.*; 23 | import net.minecraft.entity.player.*; 24 | import net.minecraft.util.*; 25 | 26 | public abstract class SmartMoving extends SmartMovingBase 27 | { 28 | public boolean isSlow; 29 | public boolean isFast; 30 | 31 | public boolean isClimbing; 32 | public boolean isHandsVineClimbing; 33 | public boolean isFeetVineClimbing; 34 | 35 | public boolean isClimbJumping; 36 | public boolean isClimbBackJumping; 37 | public boolean isWallJumping; 38 | public boolean isClimbCrawling; 39 | public boolean isCrawlClimbing; 40 | public boolean isCeilingClimbing; 41 | public boolean isRopeSliding; 42 | 43 | public boolean isDipping; 44 | public boolean isSwimming; 45 | public boolean isDiving; 46 | public boolean isLevitating; 47 | public boolean isHeadJumping; 48 | public boolean isCrawling; 49 | public boolean isSliding; 50 | public boolean isFlying; 51 | 52 | public int actualHandsClimbType; 53 | public int actualFeetClimbType; 54 | 55 | public int angleJumpType; 56 | 57 | public float heightOffset; 58 | 59 | private float spawnSlindingParticle; 60 | private float spawnSwimmingParticle; 61 | 62 | public SmartMoving(EntityPlayer sp, IEntityPlayerSP isp) 63 | { 64 | super(sp, isp); 65 | } 66 | 67 | public boolean isAngleJumping() 68 | { 69 | return angleJumpType > 1 && angleJumpType < 7; 70 | } 71 | 72 | public abstract boolean isJumping(); 73 | 74 | public abstract boolean doFlyingAnimation(); 75 | 76 | public abstract boolean doFallingAnimation(); 77 | 78 | protected void spawnParticles(Minecraft minecraft, double playerMotionX, double playerMotionZ) 79 | { 80 | float horizontalSpeedSquare = 0; 81 | if(isSliding || isSwimming) 82 | horizontalSpeedSquare = (float)(playerMotionX * playerMotionX + playerMotionZ * playerMotionZ); 83 | 84 | if(isSliding) 85 | { 86 | int i = MathHelper.floor_double(sp.posX); 87 | int j = MathHelper.floor_double(sp.boundingBox.minY - 0.1F); 88 | int k = MathHelper.floor_double(sp.posZ); 89 | Block block = sp.worldObj.getBlock(i, j, k); 90 | if(block != null) 91 | { 92 | double posY = sp.boundingBox.minY + 0.1D; 93 | double motionX = -playerMotionX * 4D; 94 | double motionY = 1.5D; 95 | double motionZ = -playerMotionZ * 4D; 96 | 97 | spawnSlindingParticle += horizontalSpeedSquare; 98 | 99 | float maxSpawnSlindingParticle = Config._slideParticlePeriodFactor.value * 0.1F; 100 | while(spawnSlindingParticle > maxSpawnSlindingParticle) 101 | { 102 | double posX = sp.posX + getSpawnOffset(); 103 | double posZ = sp.posZ + getSpawnOffset(); 104 | int metaData = sp.worldObj.getBlockMetadata(i, j, k); 105 | sp.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + metaData, posX, posY, posZ, motionX, motionY, motionZ); 106 | spawnSlindingParticle -= maxSpawnSlindingParticle; 107 | } 108 | } 109 | } 110 | 111 | if(isSwimming) 112 | { 113 | float posY = MathHelper.floor_double(sp.boundingBox.minY) + 1.0F; 114 | int i = (int)Math.floor(sp.posX); 115 | int j = (int)Math.floor(posY - 0.5); 116 | int k = (int)Math.floor(sp.posZ); 117 | 118 | Block block = sp.worldObj.getBlock(i, j, k); 119 | 120 | boolean isLava = block != null && isLava(block); 121 | spawnSwimmingParticle += horizontalSpeedSquare; 122 | 123 | float maxSpawnSwimmingParticle = (isLava ? Config._lavaSwimParticlePeriodFactor.value : Config._swimParticlePeriodFactor.value) * 0.01F; 124 | while(spawnSwimmingParticle > maxSpawnSwimmingParticle) 125 | { 126 | double posX = sp.posX + getSpawnOffset(); 127 | double posZ = sp.posZ + getSpawnOffset(); 128 | EntityFX splash = isLava ? new EntityLavaFX(sp.worldObj, posX, posY, posZ) : new EntitySplashFX(sp.worldObj, posX, posY, posZ, 0, 0, 0); 129 | splash.motionX = 0; 130 | splash.motionY = 0.2; 131 | splash.motionZ = 0; 132 | minecraft.effectRenderer.addEffect(splash); 133 | 134 | spawnSwimmingParticle -= maxSpawnSwimmingParticle; 135 | } 136 | } 137 | } 138 | 139 | private float getSpawnOffset() 140 | { 141 | return (sp.getRNG().nextFloat() - 0.5F) * 2F * sp.width; 142 | } 143 | 144 | protected void onStartClimbBackJump() 145 | { 146 | net.smart.render.SmartRenderRender.getPreviousRendererData(sp).rotateAngleY += isHeadJumping ? Half : Quarter; 147 | isClimbBackJumping = true; 148 | } 149 | 150 | protected void onStartWallJump(Float angle) 151 | { 152 | if (angle != null) 153 | net.smart.render.SmartRenderRender.getPreviousRendererData(sp).rotateAngleY = angle / RadiantToAngle; 154 | isWallJumping = true; 155 | sp.fallDistance = 0F; 156 | } 157 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingClient.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.util.*; 21 | 22 | public class SmartMovingClient extends SmartMovingContext implements ISmartMovingClient 23 | { 24 | private final Map maximumExhaustionValues = new HashMap(); 25 | private boolean nativeUserInterfaceDrawing = true; 26 | 27 | @Override 28 | public float getMaximumExhaustion() 29 | { 30 | float maxExhaustion = Config.getMaxExhaustion(); 31 | if(maximumExhaustionValues.size() > 0) 32 | { 33 | Iterator iterator = maximumExhaustionValues.values().iterator(); 34 | while(iterator.hasNext()) 35 | maxExhaustion = Math.max(iterator.next(), maxExhaustion); 36 | } 37 | return maxExhaustion; 38 | } 39 | 40 | @Override 41 | public float getMaximumUpJumpCharge() 42 | { 43 | return Config._jumpChargeMaximum.value; 44 | } 45 | 46 | @Override 47 | public float getMaximumHeadJumpCharge() 48 | { 49 | return Config._headJumpChargeMaximum.value; 50 | } 51 | 52 | @Override 53 | public void setMaximumExhaustionValue(String key, float value) 54 | { 55 | maximumExhaustionValues.put(key, value); 56 | } 57 | 58 | @Override 59 | public float getMaximumExhaustionValue(String key) 60 | { 61 | return maximumExhaustionValues.get(key); 62 | } 63 | 64 | @Override 65 | public boolean removeMaximumExhaustionValue(String key) 66 | { 67 | return maximumExhaustionValues.remove(key) != null; 68 | } 69 | 70 | @Override 71 | public void setNativeUserInterfaceDrawing(boolean value) 72 | { 73 | nativeUserInterfaceDrawing = value; 74 | } 75 | 76 | @Override 77 | public boolean getNativeUserInterfaceDrawing() 78 | { 79 | return nativeUserInterfaceDrawing; 80 | } 81 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingComm.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/src/main/java/net/smart/moving/SmartMovingComm.java -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingContext.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import cpw.mods.fml.client.registry.*; 21 | import cpw.mods.fml.common.*; 22 | 23 | import net.minecraft.client.*; 24 | import net.minecraft.server.*; 25 | 26 | import net.smart.moving.config.*; 27 | import net.smart.render.*; 28 | 29 | public abstract class SmartMovingContext extends SmartRenderContext 30 | { 31 | public static final float ClimbPullMotion = 0.3F; 32 | 33 | public static final double FastUpMotion = 0.2D; 34 | public static final double MediumUpMotion = 0.14D; 35 | public static final double SlowUpMotion = 0.1D; 36 | public static final double HoldMotion = 0.08D; 37 | public static final double SinkDownMotion = 0.05D; 38 | public static final double ClimbDownMotion = 0.01D; 39 | public static final double CatchCrawlGapMotion = 0.17D; 40 | 41 | public static final float SwimCrawlWaterMaxBorder = 1F; 42 | public static final float SwimCrawlWaterTopBorder = 0.65F; 43 | public static final float SwimCrawlWaterMediumBorder = 0.6F; 44 | public static final float SwimCrawlWaterBottomBorder = 0.55F; 45 | 46 | public static final float HorizontalGroundDamping = 0.546F; 47 | public static final float HorizontalAirDamping = 0.91F; 48 | public static final float HorizontalAirodynamicDamping = 0.999F; 49 | 50 | public static final float SwimSoundDistance = 1F / 0.7F; 51 | public static final float SlideToHeadJumpingFallDistance = 0.05F; 52 | 53 | 54 | public static final SmartMovingClient Client = new SmartMovingClient(); 55 | public static final SmartMovingOptions Options = new SmartMovingOptions(); 56 | public static final SmartMovingServerConfig ServerConfig = new SmartMovingServerConfig(); 57 | public static SmartMovingClientConfig Config = Options; 58 | 59 | 60 | private static boolean wasInitialized; 61 | 62 | public static void onTickInGame() 63 | { 64 | Minecraft minecraft = Minecraft.getMinecraft(); 65 | 66 | if(minecraft.theWorld != null && minecraft.theWorld.isRemote) 67 | SmartMovingFactory.handleMultiPlayerTick(minecraft); 68 | 69 | Options.initializeForGameIfNeccessary(); 70 | 71 | initializeServerIfNecessary(); 72 | } 73 | 74 | public static void initialize() 75 | { 76 | if(!wasInitialized) 77 | net.smart.render.statistics.SmartStatisticsContext.setCalculateHorizontalStats(true); 78 | 79 | ClientRegistry.registerKeyBinding(Options.keyBindGrab); 80 | ClientRegistry.registerKeyBinding(Options.keyBindConfigToggle); 81 | ClientRegistry.registerKeyBinding(Options.keyBindSpeedIncrease); 82 | ClientRegistry.registerKeyBinding(Options.keyBindSpeedDecrease); 83 | 84 | if(wasInitialized) 85 | return; 86 | 87 | wasInitialized = true; 88 | 89 | System.out.println(SmartMovingInfo.ModComMessage); 90 | FMLLog.getLogger().info(SmartMovingInfo.ModComMessage); 91 | } 92 | 93 | public static void initializeServerIfNecessary() 94 | { 95 | MinecraftServer currentMinecraftServer = MinecraftServer.getServer(); 96 | if(currentMinecraftServer != null && currentMinecraftServer != lastMinecraftServer) 97 | SmartMovingServer.initialize(SmartMovingOptions.optionsPath, currentMinecraftServer.getGameType().getID(), Options); 98 | lastMinecraftServer = currentMinecraftServer; 99 | } 100 | 101 | public static void registerRenderers() 102 | { 103 | registerRenderers(net.smart.moving.render.RenderPlayer.class); 104 | } 105 | 106 | private static MinecraftServer lastMinecraftServer = null; 107 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingCoreEventHandler.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.client.entity.*; 21 | import net.minecraft.client.multiplayer.*; 22 | import net.minecraft.entity.player.*; 23 | import net.minecraft.item.*; 24 | import net.minecraft.network.*; 25 | import net.minecraft.network.play.client.*; 26 | import net.minecraft.server.management.*; 27 | 28 | import net.smart.core.*; 29 | import net.smart.moving.playerapi.*; 30 | 31 | public class SmartMovingCoreEventHandler extends SmartCoreEventHandler 32 | { 33 | 34 | @Override 35 | public void beforeProcessPlayer(NetHandlerPlayServer netServerHandler) 36 | { 37 | SmartMovingServerPlayerBase playerBase = SmartMovingServerPlayerBase.getPlayerBase(netServerHandler.playerEntity); 38 | playerBase.moving.beforeAddMovingHungerBatch(); 39 | } 40 | 41 | @Override 42 | public void afterProcessPlayer(NetHandlerPlayServer netServerHandler) 43 | { 44 | SmartMovingServerPlayerBase playerBase = SmartMovingServerPlayerBase.getPlayerBase(netServerHandler.playerEntity); 45 | playerBase.moving.afterAddMovingHungerBatch(); 46 | } 47 | 48 | @Override 49 | public void beforeProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 50 | { 51 | if (packet15place.func_149568_f() == 255) 52 | { 53 | ItemStack itemstack = netServerHandler.playerEntity.inventory.getCurrentItem(); 54 | if (itemstack != null) 55 | { 56 | float offset = 1.62F - netServerHandler.playerEntity.getEyeHeight(); 57 | netServerHandler.playerEntity.yOffset += offset; 58 | } 59 | } 60 | } 61 | 62 | @Override 63 | public void afterProcessPlayerBlockPlacement(NetHandlerPlayServer netServerHandler, C08PacketPlayerBlockPlacement packet15place) 64 | { 65 | if (packet15place.func_149568_f() == 255) 66 | { 67 | ItemStack itemstack = netServerHandler.playerEntity.inventory.getCurrentItem(); 68 | if (itemstack != null) 69 | { 70 | float offset = 1.62F - netServerHandler.playerEntity.getEyeHeight(); 71 | netServerHandler.playerEntity.yOffset -= offset; 72 | } 73 | } 74 | } 75 | 76 | @Override 77 | public void beforeOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP) 78 | { 79 | SmartMovingPlayerBase playerBase = SmartMovingPlayerBase.getPlayerBase((EntityPlayerSP)entityPlayerSP); 80 | playerBase.moving.beforeActivateBlockOrUseItem(); 81 | } 82 | 83 | @Override 84 | public void afterOnPlayerRightClick(PlayerControllerMP playerControllerMP, EntityPlayer entityPlayerSP) 85 | { 86 | SmartMovingPlayerBase playerBase = SmartMovingPlayerBase.getPlayerBase((EntityPlayerSP)entityPlayerSP); 87 | playerBase.moving.afterActivateBlockOrUseItem(); 88 | } 89 | 90 | @Override 91 | public void beforeActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer) 92 | { 93 | SmartMovingServerPlayerBase playerBase = SmartMovingServerPlayerBase.getPlayerBase(entityPlayer); 94 | playerBase.moving.beforeActivateBlockOrUseItem(); 95 | } 96 | 97 | @Override 98 | public void afterActivateBlockOrUseItem(ItemInWorldManager itemInWorldManager, EntityPlayer entityPlayer) 99 | { 100 | SmartMovingServerPlayerBase playerBase = SmartMovingServerPlayerBase.getPlayerBase(entityPlayer); 101 | playerBase.moving.afterActivateBlockOrUseItem(); 102 | } 103 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingFactory.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.util.*; 21 | 22 | import net.minecraft.client.*; 23 | import net.minecraft.client.entity.*; 24 | import net.minecraft.entity.*; 25 | import net.minecraft.entity.player.*; 26 | 27 | public class SmartMovingFactory extends SmartMovingContext 28 | { 29 | private static SmartMovingFactory factory; 30 | 31 | private Hashtable otherSmartMovings; 32 | 33 | public SmartMovingFactory() 34 | { 35 | if(factory != null) 36 | throw new RuntimeException("FATAL: Can only create one instance of type 'SmartMovingFactory'"); 37 | factory = this; 38 | } 39 | 40 | protected static boolean isInitialized() 41 | { 42 | return factory != null; 43 | } 44 | 45 | public static void initialize() 46 | { 47 | if(!isInitialized()) 48 | new SmartMovingFactory(); 49 | } 50 | 51 | public static void handleMultiPlayerTick(Minecraft minecraft) 52 | { 53 | factory.doHandleMultiPlayerTick(minecraft); 54 | } 55 | 56 | public static SmartMoving getInstance(EntityPlayer entityPlayer) 57 | { 58 | return factory.doGetInstance(entityPlayer); 59 | } 60 | 61 | public static SmartMoving getOtherSmartMoving(int entityId) 62 | { 63 | return factory.doGetOtherSmartMoving(entityId); 64 | } 65 | 66 | public static SmartMovingOther getOtherSmartMoving(EntityOtherPlayerMP entity) 67 | { 68 | return factory.doGetOtherSmartMoving(entity); 69 | } 70 | 71 | protected void doHandleMultiPlayerTick(Minecraft minecraft) 72 | { 73 | Iterator others = minecraft.theWorld.playerEntities.iterator(); 74 | while(others.hasNext()) 75 | { 76 | Entity player = (Entity)others.next(); 77 | if(player instanceof EntityOtherPlayerMP) 78 | { 79 | EntityOtherPlayerMP otherPlayer = (EntityOtherPlayerMP)player; 80 | SmartMovingOther moving = doGetOtherSmartMoving(otherPlayer); 81 | moving.spawnParticles(minecraft, otherPlayer.posX - otherPlayer.prevPosX, otherPlayer.posZ - otherPlayer.prevPosZ); 82 | moving.foundAlive = true; 83 | } 84 | } 85 | 86 | if(otherSmartMovings == null || otherSmartMovings.isEmpty()) 87 | return; 88 | 89 | Iterator entityIds = otherSmartMovings.keySet().iterator(); 90 | while(entityIds.hasNext()) 91 | { 92 | Integer entityId = entityIds.next(); 93 | SmartMovingOther moving = otherSmartMovings.get(entityId); 94 | if(moving.foundAlive) 95 | moving.foundAlive = false; 96 | else 97 | entityIds.remove(); 98 | } 99 | } 100 | 101 | protected SmartMoving doGetInstance(EntityPlayer entityPlayer) 102 | { 103 | if(entityPlayer instanceof EntityOtherPlayerMP) 104 | return doGetOtherSmartMoving(entityPlayer.getEntityId()); 105 | else if(entityPlayer instanceof IEntityPlayerSP) 106 | return ((IEntityPlayerSP)entityPlayer).getMoving(); 107 | return null; 108 | } 109 | 110 | protected SmartMoving doGetOtherSmartMoving(int entityId) 111 | { 112 | SmartMoving moving = tryGetOtherSmartMoving(entityId); 113 | if(moving == null) 114 | { 115 | Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(entityId); 116 | if(entity != null && entity instanceof EntityOtherPlayerMP) 117 | moving = addOtherSmartMoving((EntityOtherPlayerMP)entity); 118 | } 119 | return moving; 120 | } 121 | 122 | protected SmartMovingOther doGetOtherSmartMoving(EntityOtherPlayerMP entity) 123 | { 124 | SmartMovingOther moving = tryGetOtherSmartMoving(entity.getEntityId()); 125 | if(moving == null) 126 | moving = addOtherSmartMoving(entity); 127 | return moving; 128 | } 129 | 130 | protected final SmartMovingOther tryGetOtherSmartMoving(int entityId) 131 | { 132 | if(otherSmartMovings == null) 133 | otherSmartMovings = new Hashtable(); 134 | return otherSmartMovings.get(entityId); 135 | } 136 | 137 | protected final SmartMovingOther addOtherSmartMoving(EntityOtherPlayerMP entity) 138 | { 139 | SmartMovingOther moving = new SmartMovingOther(entity); 140 | otherSmartMovings.put(entity.getEntityId(), moving); 141 | return moving; 142 | } 143 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingInfo.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import cpw.mods.fml.common.*; 21 | 22 | public class SmartMovingInfo 23 | { 24 | public static final byte StatePacketId = 0; 25 | public static final byte ConfigInfoPacketId = 1; 26 | public static final byte ConfigContentPacketId = 2; 27 | public static final byte ConfigChangePacketId = 3; 28 | public static final byte SpeedChangePacketId = 4; 29 | public static final byte HungerChangePacketId = 5; 30 | public static final byte SoundPacketId = 6; 31 | 32 | private static final Mod Mod = SmartMovingMod.class.getAnnotation(Mod.class); 33 | 34 | public static final String ModId = Mod.modid(); 35 | public static final String ModName = Mod.name(); 36 | public static final String ModVersion = Mod.version(); 37 | public static final String ModComVersion = SmartMovingMod.ModComVersion; 38 | 39 | public static final String ModComMessage = ModName + " uses communication protocol " + ModComVersion; 40 | public static final String ModComId = ModName.replace(" ", "") + " " + ModComVersion; 41 | 42 | public static final int DefaultChatId = 0; 43 | public static final int ConfigChatId = ModName.hashCode(); 44 | public static final int SpeedChatId = ModName.hashCode() + 1; 45 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingInstall.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.smart.utilities.*; 21 | 22 | public class SmartMovingInstall 23 | { 24 | public final static Name RopesPlusCore = new Name("atomicstryker.ropesplus.common.RopesPlusCore"); 25 | public final static Name ModBlockFence = new Name("net.minecraft.src.modBlockFence", "modBlockFence"); 26 | public final static Name MacroModCore = new Name("net.eq2online.macros.core.MacroModCore"); 27 | public final static Name BlockSturdyLadder = new Name("mods.chupmacabre.ladderKit.sturdyLadders.BlockSturdyLadder"); 28 | public final static Name BlockRopeLadder = new Name("mods.chupmacabre.ladderKit.ropeLadders.BlockRopeLadder"); 29 | 30 | public final static Name RopesPlusClient = new Name("atomicstryker.ropesplus.client.RopesPlusClient"); 31 | public final static Name RopesPlusClient_onZipLine = new Name("onZipLine"); 32 | 33 | public final static Name CarpentersBlockLadder = new Name("com.carpentersblocks.block.BlockCarpentersLadder"); 34 | public final static Name CarpentersTEBaseBlock = new Name("com.carpentersblocks.tileentity.TEBase"); 35 | public final static Name CarpentersTEBaseBlock_getData = new Name("getData"); 36 | 37 | public final static Name NetServerHandler_ticksForFloatKick = new Name("floatingTickCount", "field_147365_f", "f"); 38 | public final static Name GuiNewChat_chatMessageList = new Name("chatLines", "field_146252_h", "h"); 39 | public final static Name PlayerControllerMP_currentGameType = new Name("currentGameType", "field_78779_k", "k"); 40 | public final static Name ModifiableAttributeInstance_attributeValue = new Name("cachedValue", "field_111139_h", "h"); 41 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingMod.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.io.*; 21 | import java.lang.reflect.*; 22 | import java.util.*; 23 | 24 | import cpw.mods.fml.common.*; 25 | import cpw.mods.fml.common.Mod.*; 26 | import cpw.mods.fml.common.event.*; 27 | import cpw.mods.fml.common.eventhandler.*; 28 | import cpw.mods.fml.common.gameevent.TickEvent.*; 29 | import cpw.mods.fml.common.network.*; 30 | import cpw.mods.fml.common.network.FMLNetworkEvent.*; 31 | import net.minecraft.entity.player.*; 32 | import net.minecraft.network.*; 33 | import net.smart.core.*; 34 | import net.smart.moving.config.*; 35 | import net.smart.utilities.*; 36 | 37 | @Mod(modid = "SmartMoving", name = "Smart Moving", version = "15.6", dependencies = "required-after:PlayerAPI@[1.3,);required-after:SmartRender@[2.1,)") 38 | public class SmartMovingMod 39 | { 40 | protected static String ModComVersion = "2.3.1"; 41 | 42 | private final boolean isClient; 43 | 44 | private boolean hasRenderer = false; 45 | 46 | public SmartMovingMod() 47 | { 48 | isClient = FMLCommonHandler.instance().getSide().isClient(); 49 | } 50 | 51 | @EventHandler 52 | @SuppressWarnings("unused") 53 | public void init(FMLInitializationEvent event) 54 | { 55 | NetworkRegistry.INSTANCE.newEventDrivenChannel(SmartMovingPacketStream.Id).register(this); 56 | 57 | if(isClient) 58 | { 59 | hasRenderer = Loader.isModLoaded("RenderPlayerAPI"); 60 | 61 | net.smart.moving.playerapi.SmartMoving.register(); 62 | 63 | if(hasRenderer) 64 | { 65 | Class type = Reflect.LoadClass(SmartMovingMod.class, new Name("net.smart.moving.render.playerapi.SmartMoving"), true); 66 | Method method = Reflect.GetMethod(type, new Name("register")); 67 | Reflect.Invoke(method, null); 68 | } 69 | else 70 | net.smart.render.SmartRenderMod.doNotAddRenderer(); 71 | 72 | SmartMovingServerComm.localUserNameProvider = new LocalUserNameProvider(); 73 | if(!hasRenderer) 74 | SmartMovingContext.registerRenderers(); 75 | 76 | registerGameTicks(); 77 | 78 | net.smart.moving.playerapi.SmartMovingFactory.initialize(); 79 | 80 | checkForPresentModsAndInitializeOptions(); 81 | 82 | SmartMovingContext.initialize(); 83 | } 84 | else 85 | SmartMovingServer.initialize(new File("."), FMLCommonHandler.instance().getMinecraftServerInstance().getGameType().getID(), new SmartMovingConfig()); 86 | 87 | SmartCoreEventHandler.Add(new SmartMovingCoreEventHandler()); 88 | 89 | Compat.init(); 90 | } 91 | 92 | @EventHandler 93 | @SuppressWarnings("unused") 94 | public void postInit(FMLPostInitializationEvent event) 95 | { 96 | if(!isClient) 97 | net.smart.moving.playerapi.SmartMovingServerPlayerBase.registerPlayerBase(); 98 | } 99 | 100 | @SubscribeEvent 101 | @SuppressWarnings({ "static-method", "unused" }) 102 | public void tickStart(ClientTickEvent event) 103 | { 104 | SmartMovingContext.onTickInGame(); 105 | } 106 | 107 | @SubscribeEvent 108 | @SuppressWarnings("static-method") 109 | public void onPacketData(ServerCustomPacketEvent event) 110 | { 111 | SmartMovingPacketStream.receivePacket(event.packet, SmartMovingServerComm.instance, net.smart.moving.playerapi.SmartMovingServerPlayerBase.getPlayerBase(((NetHandlerPlayServer)event.handler).playerEntity)); 112 | } 113 | 114 | @SubscribeEvent 115 | @SuppressWarnings("static-method") 116 | public void onPacketData(ClientCustomPacketEvent event) 117 | { 118 | SmartMovingPacketStream.receivePacket(event.packet, SmartMovingComm.instance, null); 119 | } 120 | 121 | public void registerGameTicks() 122 | { 123 | FMLCommonHandler.instance().bus().register(this); 124 | } 125 | 126 | @SuppressWarnings("static-method") 127 | public Object getInstance(EntityPlayer entityPlayer) 128 | { 129 | return SmartMovingFactory.getInstance(entityPlayer); 130 | } 131 | 132 | @SuppressWarnings("static-method") 133 | public Object getClient() 134 | { 135 | return SmartMovingContext.Client; 136 | } 137 | 138 | @SuppressWarnings("static-method") 139 | public void checkForPresentModsAndInitializeOptions() 140 | { 141 | List modList = Loader.instance().getActiveModList(); 142 | boolean hasRedPowerWiring = false; 143 | boolean hasBuildCraftTransport = false; 144 | boolean hasFiniteLiquid = false; 145 | boolean hasBetterThanWolves = false; 146 | boolean hasSinglePlayerCommands = false; 147 | boolean hasRopesPlus = false; 148 | boolean hasASGrapplingHook = false; 149 | boolean hasBetterMisc = false; 150 | 151 | for(int i = 0; i < modList.size(); i++) 152 | { 153 | ModContainer mod = modList.get(i); 154 | String name = mod.getName(); 155 | 156 | if(name.contains("RedPowerWiring")) 157 | hasRedPowerWiring = true; 158 | else if(name.contains("BuildCraftTransport")) 159 | hasBuildCraftTransport = true; 160 | else if(name.contains("Liquid")) 161 | hasFiniteLiquid = true; 162 | else if(name.contains("FCBetterThanWolves")) 163 | hasBetterThanWolves = true; 164 | else if(name.contains("SinglePlayerCommands")) 165 | hasSinglePlayerCommands = true; 166 | else if(name.contains("ASGrapplingHook")) 167 | hasASGrapplingHook = true; 168 | else if(name.contains("BetterMisc")) 169 | hasBetterMisc = true; 170 | } 171 | 172 | hasRopesPlus = Reflect.CheckClasses(SmartMovingMod.class, SmartMovingInstall.RopesPlusCore); 173 | 174 | SmartMovingOptions.initialize(hasRedPowerWiring, hasBuildCraftTransport, hasFiniteLiquid, hasBetterThanWolves, hasSinglePlayerCommands, hasRopesPlus, hasASGrapplingHook, hasBetterMisc); 175 | } 176 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingOther.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import net.minecraft.client.entity.*; 21 | 22 | public class SmartMovingOther extends SmartMoving 23 | { 24 | public boolean foundAlive; 25 | 26 | public SmartMovingOther(EntityOtherPlayerMP sp) 27 | { 28 | super(sp, null); 29 | } 30 | 31 | public void processStatePacket(long state) 32 | { 33 | actualFeetClimbType = (int)(state & 15); 34 | state >>>= 4; 35 | 36 | actualHandsClimbType = (int)(state & 15); 37 | state >>>= 4; 38 | 39 | _isJumping = (state & 1) != 0; 40 | state >>>= 1; 41 | 42 | isDiving = (state & 1) != 0; 43 | state >>>= 1; 44 | 45 | isDipping = (state & 1) != 0; 46 | state >>>= 1; 47 | 48 | isSwimming = (state & 1) != 0; 49 | state >>>= 1; 50 | 51 | isCrawlClimbing = (state & 1) != 0; 52 | state >>>= 1; 53 | 54 | isCrawling = (state & 1) != 0; 55 | state >>>= 1; 56 | 57 | isClimbing = (state & 1) != 0; 58 | state >>>= 1; 59 | 60 | boolean isSmall = (state & 1) != 0; 61 | heightOffset = isSmall ? -1 : 0; 62 | sp.height = 1.8F + heightOffset; 63 | state >>>= 1; 64 | 65 | _doFallingAnimation = (state & 1) != 0; 66 | state >>>= 1; 67 | 68 | _doFlyingAnimation = (state & 1) != 0; 69 | state >>>= 1; 70 | 71 | isCeilingClimbing = (state & 1) != 0; 72 | state >>>= 1; 73 | 74 | isLevitating = (state & 1) != 0; 75 | state >>>= 1; 76 | 77 | isHeadJumping = (state & 1) != 0; 78 | state >>>= 1; 79 | 80 | isSliding = (state & 1) != 0; 81 | state >>>= 1; 82 | 83 | angleJumpType = (int)(state & 7); 84 | state >>>= 3; 85 | 86 | isFeetVineClimbing = (state & 1) != 0; 87 | state >>>= 1; 88 | 89 | isHandsVineClimbing = (state & 1) != 0; 90 | state >>>= 1; 91 | 92 | isClimbJumping = (state & 1) != 0; 93 | state >>>= 1; 94 | 95 | boolean wasClimbBackJumping = isClimbBackJumping; 96 | isClimbBackJumping = (state & 1) != 0; 97 | if(!wasClimbBackJumping && isClimbBackJumping) 98 | onStartClimbBackJump(); 99 | state >>>= 1; 100 | 101 | isSlow = (state & 1) != 0; 102 | state >>>= 1; 103 | 104 | isFast = (state & 1) != 0; 105 | state >>>= 1; 106 | 107 | boolean wasWallJumping = isWallJumping; 108 | isWallJumping = (state & 1) != 0; 109 | if(!wasWallJumping && isWallJumping) 110 | onStartWallJump(null); 111 | state >>>= 1; 112 | 113 | isRopeSliding = (state & 1) != 0; 114 | } 115 | 116 | @Override 117 | public boolean isJumping() 118 | { 119 | return _isJumping; 120 | } 121 | 122 | @Override 123 | public boolean doFlyingAnimation() 124 | { 125 | return _doFlyingAnimation; 126 | } 127 | 128 | @Override 129 | public boolean doFallingAnimation() 130 | { 131 | return _doFallingAnimation; 132 | } 133 | 134 | private boolean _isJumping = false; 135 | private boolean _doFlyingAnimation = false; 136 | private boolean _doFallingAnimation = false; 137 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingPacketStream.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import java.io.*; 21 | import java.util.*; 22 | 23 | import cpw.mods.fml.common.network.internal.*; 24 | 25 | public class SmartMovingPacketStream 26 | { 27 | public static final String Id; 28 | public static final Set errors; 29 | 30 | static 31 | { 32 | String id = SmartMovingInfo.ModComId; 33 | if(id.length() > 15) 34 | id = id.substring(0, 15); 35 | Id = id; 36 | errors = new HashSet(); 37 | } 38 | 39 | public static void receivePacket(FMLProxyPacket packet, IPacketReceiver comm, IEntityPlayerMP player) 40 | { 41 | try 42 | { 43 | ByteArrayInputStream byteInput = new ByteArrayInputStream(packet.payload().array()); 44 | ObjectInputStream objectInput = new ObjectInputStream(byteInput); 45 | byte packetId = objectInput.readByte(); 46 | switch(packetId) 47 | { 48 | case SmartMovingInfo.StatePacketId: 49 | int entityId = objectInput.readInt(); 50 | long state = objectInput.readLong(); 51 | comm.processStatePacket(packet, player, entityId, state); 52 | break; 53 | case SmartMovingInfo.ConfigInfoPacketId: 54 | String info = (String)objectInput.readObject(); 55 | comm.processConfigInfoPacket(packet, player, info); 56 | break; 57 | case SmartMovingInfo.ConfigContentPacketId: 58 | String[] content = (String[])objectInput.readObject(); 59 | String username = (String)objectInput.readObject(); 60 | comm.processConfigContentPacket(packet, player, content, username); 61 | break; 62 | case SmartMovingInfo.ConfigChangePacketId: 63 | comm.processConfigChangePacket(packet, player); 64 | break; 65 | case SmartMovingInfo.SpeedChangePacketId: 66 | int difference = objectInput.readInt(); 67 | username = (String)objectInput.readObject(); 68 | comm.processSpeedChangePacket(packet, player, difference, username); 69 | break; 70 | case SmartMovingInfo.HungerChangePacketId: 71 | float hunger = objectInput.readFloat(); 72 | comm.processHungerChangePacket(packet, player, hunger); 73 | break; 74 | case SmartMovingInfo.SoundPacketId: 75 | String soundId = (String)objectInput.readObject(); 76 | float volume = objectInput.readFloat(); 77 | float pitch = objectInput.readFloat(); 78 | comm.processSoundPacket(packet, player, soundId, volume, pitch); 79 | break; 80 | default: 81 | throw new RuntimeException("Unknown packet id '" + packetId + "' found"); 82 | } 83 | } 84 | catch(Throwable t) 85 | { 86 | if(errors.add(t.getStackTrace()[0])) 87 | t.printStackTrace(); 88 | else 89 | System.err.println(t.getClass().getName() + ": " + t.getMessage()); 90 | } 91 | } 92 | 93 | public static void sendState(IPacketSender comm, int entityId, long state) 94 | { 95 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 96 | try 97 | { 98 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 99 | objectOutput.writeByte(SmartMovingInfo.StatePacketId); 100 | objectOutput.writeInt(entityId); 101 | objectOutput.writeLong(state); 102 | objectOutput.flush(); 103 | } 104 | catch(Throwable t) 105 | { 106 | throw new RuntimeException(t); 107 | } 108 | comm.sendPacket(byteOutput.toByteArray()); 109 | } 110 | 111 | public static void sendConfigInfo(IPacketSender comm, String info) 112 | { 113 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 114 | try 115 | { 116 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 117 | objectOutput.writeByte(SmartMovingInfo.ConfigInfoPacketId); 118 | objectOutput.writeObject(info); 119 | objectOutput.flush(); 120 | } 121 | catch(Throwable t) 122 | { 123 | throw new RuntimeException(t); 124 | } 125 | comm.sendPacket(byteOutput.toByteArray()); 126 | } 127 | 128 | public static void sendConfigContent(IPacketSender comm, String[] content, String username) 129 | { 130 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 131 | try 132 | { 133 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 134 | objectOutput.writeByte(SmartMovingInfo.ConfigContentPacketId); 135 | objectOutput.writeObject(content); 136 | objectOutput.writeObject(username); 137 | objectOutput.flush(); 138 | } 139 | catch(Throwable t) 140 | { 141 | throw new RuntimeException(t); 142 | } 143 | comm.sendPacket(byteOutput.toByteArray()); 144 | } 145 | 146 | public static void sendConfigChange(IPacketSender comm) 147 | { 148 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 149 | try 150 | { 151 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 152 | objectOutput.writeByte(SmartMovingInfo.ConfigChangePacketId); 153 | objectOutput.flush(); 154 | } 155 | catch(Throwable t) 156 | { 157 | throw new RuntimeException(t); 158 | } 159 | comm.sendPacket(byteOutput.toByteArray()); 160 | } 161 | 162 | public static void sendSpeedChange(IPacketSender comm, int difference, String username) 163 | { 164 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 165 | try 166 | { 167 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 168 | objectOutput.writeByte(SmartMovingInfo.SpeedChangePacketId); 169 | objectOutput.writeInt(difference); 170 | objectOutput.writeObject(username); 171 | objectOutput.flush(); 172 | } 173 | catch(Throwable t) 174 | { 175 | throw new RuntimeException(t); 176 | } 177 | comm.sendPacket(byteOutput.toByteArray()); 178 | } 179 | 180 | public static void sendHungerChange(IPacketSender comm, float hunger) 181 | { 182 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 183 | try 184 | { 185 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 186 | objectOutput.writeByte(SmartMovingInfo.HungerChangePacketId); 187 | objectOutput.writeFloat(hunger); 188 | objectOutput.flush(); 189 | } 190 | catch(Throwable t) 191 | { 192 | throw new RuntimeException(t); 193 | } 194 | comm.sendPacket(byteOutput.toByteArray()); 195 | } 196 | 197 | public static void sendSound(IPacketSender comm, String soundId, float volume, float pitch) 198 | { 199 | ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 200 | try 201 | { 202 | ObjectOutputStream objectOutput = new ObjectOutputStream(byteOutput); 203 | objectOutput.writeByte(SmartMovingInfo.SoundPacketId); 204 | objectOutput.writeObject(soundId); 205 | objectOutput.writeFloat(volume); 206 | objectOutput.writeFloat(pitch); 207 | objectOutput.flush(); 208 | } 209 | catch(Throwable t) 210 | { 211 | throw new RuntimeException(t); 212 | } 213 | comm.sendPacket(byteOutput.toByteArray()); 214 | } 215 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/SmartMovingServerComm.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving; 19 | 20 | import cpw.mods.fml.common.network.internal.*; 21 | 22 | public class SmartMovingServerComm implements IPacketReceiver 23 | { 24 | public static ILocalUserNameProvider localUserNameProvider = null; 25 | 26 | @Override 27 | public boolean processStatePacket(FMLProxyPacket packet, IEntityPlayerMP player, int entityId, long state) 28 | { 29 | player.getMoving().processStatePacket(packet, state); 30 | return true; 31 | } 32 | 33 | @Override 34 | public boolean processConfigInfoPacket(FMLProxyPacket packet, IEntityPlayerMP player, String info) 35 | { 36 | player.getMoving().processConfigPacket(info); 37 | return true; 38 | } 39 | 40 | @Override 41 | public boolean processConfigContentPacket(FMLProxyPacket packet, IEntityPlayerMP player, String[] content, String username) 42 | { 43 | return false; 44 | } 45 | 46 | @Override 47 | public boolean processConfigChangePacket(FMLProxyPacket packet, IEntityPlayerMP player) 48 | { 49 | player.getMoving().processConfigChangePacket(localUserNameProvider != null ? localUserNameProvider.getLocalConfigUserName() : null); 50 | return true; 51 | } 52 | 53 | @Override 54 | public boolean processSpeedChangePacket(FMLProxyPacket packet, IEntityPlayerMP player, int difference, String username) 55 | { 56 | player.getMoving().processSpeedChangePacket(difference, localUserNameProvider != null ? localUserNameProvider.getLocalSpeedUserName() : null); 57 | return true; 58 | } 59 | 60 | @Override 61 | public boolean processHungerChangePacket(FMLProxyPacket packet, IEntityPlayerMP player, float hunger) 62 | { 63 | player.getMoving().processHungerChangePacket(hunger); 64 | return true; 65 | } 66 | 67 | @Override 68 | public boolean processSoundPacket(FMLProxyPacket packet, IEntityPlayerMP player, String soundId, float volume, float pitch) 69 | { 70 | player.getMoving().processSoundPacket(soundId, volume, pitch); 71 | return true; 72 | } 73 | 74 | public static final SmartMovingServerComm instance = new SmartMovingServerComm(); 75 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/config/SmartMovingProperties.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.config; 19 | 20 | import java.io.*; 21 | import java.util.*; 22 | 23 | import net.smart.properties.*; 24 | import net.smart.properties.Properties; 25 | 26 | public abstract class SmartMovingProperties extends Properties 27 | { 28 | public final static String Enabled = "enabled"; 29 | public final static String Disabled = "disabled"; 30 | private final static String[] _defaultKeys = new String[1]; 31 | 32 | private int toggler = -2; 33 | private String[] keys = _defaultKeys; 34 | 35 | public boolean enabled; 36 | 37 | protected void load(Properties... propertiesList) throws Exception 38 | { 39 | List> propertiesToLoad = getProperties(); 40 | if(toggler != -2) 41 | { 42 | Iterator> iterator = propertiesToLoad.iterator(); 43 | while(iterator.hasNext()) 44 | iterator.next().reset(); 45 | } 46 | 47 | while (propertiesToLoad.size() > 0) 48 | { 49 | Iterator> iterator = propertiesToLoad.iterator(); 50 | while(iterator.hasNext()) 51 | if(iterator.next().load(propertiesList)) 52 | iterator.remove(); 53 | } 54 | 55 | toggler = 0; 56 | update(); 57 | } 58 | 59 | protected void save(File file, String version, boolean header, boolean comments) throws Exception 60 | { 61 | List> propertiesToSave = getProperties(); 62 | 63 | FileOutputStream stream = new FileOutputStream(file); 64 | PrintWriter printer = new PrintWriter(stream); 65 | 66 | if(header) 67 | printHeader(printer); 68 | 69 | if(version != null) 70 | printVersion(printer, version, comments); 71 | 72 | for(int i = 0; i < propertiesToSave.size(); i++) 73 | if(propertiesToSave.get(i).print(printer, keys, version, comments) && i < propertiesToSave.size() - 1) 74 | printer.println(); 75 | 76 | printer.close(); 77 | } 78 | 79 | protected abstract void printVersion(PrintWriter printer, String version, boolean comments); 80 | 81 | protected abstract void printHeader(PrintWriter printer); 82 | 83 | public void toggle() 84 | { 85 | int length = keys == null ? 0 : keys.length; 86 | toggler++; 87 | if(toggler == length) 88 | toggler = -1; 89 | update(); 90 | } 91 | 92 | public void setKeys(String[] keys) 93 | { 94 | if(keys == null || keys.length == 0) 95 | keys = _defaultKeys; 96 | this.keys = keys; 97 | toggler = 0; 98 | update(); 99 | } 100 | 101 | public String getKey(int index) 102 | { 103 | if(keys[index] == null) 104 | return Enabled; 105 | return keys[index]; 106 | } 107 | 108 | public String getNextKey(String key) 109 | { 110 | if(key == null || key.equals("disabled")) 111 | return getKey(0); 112 | int index; 113 | for(index = 0; index < keys.length; index++) 114 | if(key.equals(keys[index])) 115 | break; 116 | index++; 117 | if(index < keys.length) 118 | return keys[index]; 119 | return Disabled; 120 | } 121 | 122 | public void setCurrentKey(String key) 123 | { 124 | if(key == null || key.equals(Disabled)) 125 | toggler = -1; 126 | else if(keys.length == 1 && keys[0] == null && key.equals(Enabled)) 127 | toggler = 0; 128 | else 129 | { 130 | for(toggler = 0; toggler < keys.length; toggler++) 131 | if(key.equals(keys[toggler])) 132 | break; 133 | 134 | if(toggler == keys.length) 135 | toggler = -1; 136 | } 137 | update(); 138 | } 139 | 140 | public String getCurrentKey() 141 | { 142 | if(toggler == -1) 143 | return Disabled; 144 | return keys[toggler]; 145 | } 146 | 147 | public boolean hasKey(String key) 148 | { 149 | if(Enabled.equals(key)) 150 | return keys[0] == null; 151 | if(Disabled.equals(key)) 152 | return true; 153 | 154 | for(int i = 0; i < keys.length; i++) 155 | if(key == null && keys[i] == null || key != null && key.equals(keys[i])) 156 | return true; 157 | return false; 158 | } 159 | 160 | public int getKeyCount() 161 | { 162 | return keys.length; 163 | } 164 | 165 | protected void update() 166 | { 167 | List> properties = getProperties(); 168 | Iterator> iterator = properties.iterator(); 169 | 170 | String currentKey = getCurrentKey(); 171 | while(iterator.hasNext()) 172 | iterator.next().update(currentKey); 173 | enabled = toggler != -1; 174 | } 175 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/config/SmartMovingServerConfig.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.config; 19 | 20 | import java.util.Iterator; 21 | 22 | import net.smart.properties.*; 23 | 24 | public class SmartMovingServerConfig extends SmartMovingClientConfig 25 | { 26 | private Properties properties = new Properties(); 27 | private Properties topProperties = new Properties(); 28 | 29 | public void loadFromProperties(String[] propertyArray, boolean top) 30 | { 31 | for(int i = 0; i < propertyArray.length - 1; i += 2) 32 | { 33 | String key = propertyArray[i]; 34 | String value = propertyArray[i + 1]; 35 | properties.put(key, value); 36 | if(top) 37 | topProperties.put(key, value); 38 | } 39 | 40 | load(top); 41 | } 42 | 43 | public void load(boolean top) 44 | { 45 | if(!top && !topProperties.isEmpty()) 46 | { 47 | Iterator iterator = topProperties.keySet().iterator(); 48 | while(iterator.hasNext()) 49 | { 50 | Object topKey = iterator.next(); 51 | properties.put(topKey, topProperties.get(topKey)); 52 | } 53 | } 54 | super.loadFromProperties(properties); 55 | } 56 | 57 | public void reset() 58 | { 59 | properties.clear(); 60 | topProperties.clear(); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/config/SmartMovingServerOptions.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.config; 19 | 20 | import java.io.*; 21 | import java.util.*; 22 | 23 | import cpw.mods.fml.common.*; 24 | 25 | import net.smart.moving.*; 26 | import net.smart.properties.*; 27 | import net.smart.properties.Properties; 28 | 29 | public class SmartMovingServerOptions 30 | { 31 | public final SmartMovingConfig config; 32 | public final File optionsPath; 33 | private final Property> _userConfigKeys; 34 | 35 | public SmartMovingServerOptions(SmartMovingConfig config, File optionsPath, int gameType) 36 | { 37 | this.config = config; 38 | this.optionsPath = optionsPath; 39 | 40 | config.loadFromOptionsFile(optionsPath); 41 | config.saveToOptionsFile(optionsPath); 42 | 43 | Property configKey = null; 44 | Property configKeys = null; 45 | switch(gameType) 46 | { 47 | default: 48 | case SmartMovingConfig.Survival: 49 | configKey = config._survivalDefaultConfigKey; 50 | configKeys = config._survivalConfigKeys; 51 | _userConfigKeys = config._survivalDefaultConfigUserKeys; 52 | break; 53 | case SmartMovingConfig.Creative: 54 | configKey = config._creativeDefaultConfigKey; 55 | configKeys = config._creativeConfigKeys; 56 | _userConfigKeys = config._creativeDefaultConfigUserKeys; 57 | break; 58 | case SmartMovingConfig.Adventure: 59 | configKey = config. _adventureDefaultConfigKey; 60 | configKeys = config._adventureConfigKeys; 61 | _userConfigKeys = config._adventureDefaultConfigUserKeys; 62 | break; 63 | } 64 | 65 | config.setKeys(configKeys.value); 66 | config.setCurrentKey(configKey != null && !configKey.value.isEmpty() ? configKey.value : null); 67 | 68 | logConfigState(config, null, false); 69 | } 70 | 71 | public void toggle(IEntityPlayerMP player) 72 | { 73 | config.toggle(); 74 | config.saveToOptionsFile(optionsPath); 75 | logConfigState(config, player.getUsername(), true); 76 | } 77 | 78 | public void changeSpeed(int difference, IEntityPlayerMP player) 79 | { 80 | config.changeSpeed(difference); 81 | config.saveToOptionsFile(optionsPath); 82 | logSpeedState(config, player.getUsername()); 83 | } 84 | 85 | private static void logConfigState(SmartMovingConfig config, String username, boolean reconfig) 86 | { 87 | String message = "Smart Moving "; 88 | if(config._globalConfig.value) 89 | { 90 | if(!reconfig) 91 | FMLLog.info(message + "overrides client configurations"); 92 | 93 | String postfix = getPostfix(username); 94 | 95 | if(config.enabled) 96 | { 97 | String currentKey = config.getCurrentKey(); 98 | 99 | message += reconfig ? "changed to " : "uses "; 100 | if(currentKey == null) 101 | FMLLog.info(message + "default server configuration" + postfix); 102 | else 103 | { 104 | String configName = config._configKeyName.value; 105 | 106 | message += "server configuration "; 107 | if(configName.isEmpty()) 108 | FMLLog.info(message + "with key \"" + currentKey + "\"" + postfix); 109 | else 110 | FMLLog.info(message + "\"" + configName + "\"" + postfix); 111 | } 112 | } 113 | else 114 | FMLLog.info(message + "disabled" + postfix); 115 | } 116 | else 117 | FMLLog.info(message + "allows client configurations"); 118 | } 119 | 120 | private static void logSpeedState(SmartMovingConfig config, String username) 121 | { 122 | FMLLog.info("Smart Moving speed set to " + config.getSpeedPercent() + "%" + getPostfix(username)); 123 | } 124 | 125 | private static String getPostfix(String username) 126 | { 127 | if(username == null) 128 | return ""; 129 | return " by user '" + username + "'"; 130 | } 131 | 132 | public String[] writeToProperties() 133 | { 134 | return writeToProperties(null, null); 135 | } 136 | 137 | public String[] writeToProperties(IEntityPlayerMP mp, String key) 138 | { 139 | if(key == null ? !config.enabled : key == SmartMovingProperties.Disabled) 140 | return new String[] { config._globalConfig.getCurrentKey(), config._globalConfig.getValueString() }; 141 | 142 | Properties properties = new Properties(); 143 | config.write(properties, key); 144 | 145 | String[] result = new String[properties.size() * 2]; 146 | Iterator> keys = properties.entrySet().iterator(); 147 | 148 | String speedUserExponentKey = mp != null ? config._speedUserExponent.getCurrentKey() : null; 149 | int i = 0; 150 | while(keys.hasNext()) 151 | { 152 | Map.Entry entry = keys.next(); 153 | String propertyKey = result[i++] = entry.getKey().toString(); 154 | if(mp != null && propertyKey.equals(speedUserExponentKey)) 155 | { 156 | Integer userExponent = config._speedUsersExponents.value.get(mp.getUsername()); 157 | if(userExponent != null) 158 | entry.setValue(config._speedUserExponent.getValueString(userExponent)); 159 | } 160 | result[i++] = entry.getValue().toString(); 161 | } 162 | return result; 163 | } 164 | 165 | public void changeSingleSpeed(IEntityPlayerMP player, int difference) 166 | { 167 | Integer exponent = getPlayerSpeedExponent(player); 168 | if(exponent == null) 169 | exponent = config._speedUserExponent.value; 170 | 171 | exponent += difference; 172 | setPlayerSpeedExponent(player, exponent); 173 | } 174 | 175 | public Integer getPlayerSpeedExponent(IEntityPlayerMP player) 176 | { 177 | return config._speedUsersExponents.value.get(player.getUsername()); 178 | } 179 | 180 | public synchronized void setPlayerSpeedExponent(IEntityPlayerMP player, Integer exponent) 181 | { 182 | config._speedUsersExponents.value.put(player.getUsername(), exponent); 183 | config.saveToOptionsFile(optionsPath); 184 | } 185 | 186 | public String[] writeToProperties(IEntityPlayerMP player, boolean toggle) 187 | { 188 | String key = getPlayerConfigurationKey(player); 189 | if(key == null || !config.hasKey(key)) 190 | { 191 | key = config.getCurrentKey(); 192 | setPlayerConfigurationKey(player, key); 193 | } 194 | 195 | if(toggle) 196 | { 197 | key = config.getNextKey(key); 198 | setPlayerConfigurationKey(player, key); 199 | } 200 | 201 | return writeToProperties(player, key); 202 | } 203 | 204 | public String getPlayerConfigurationKey(IEntityPlayerMP player) 205 | { 206 | return _userConfigKeys.value.get(player.getUsername()); 207 | } 208 | 209 | public synchronized void setPlayerConfigurationKey(IEntityPlayerMP player, String key) 210 | { 211 | _userConfigKeys.value.put(player.getUsername(), key); 212 | config.saveToOptionsFile(optionsPath); 213 | } 214 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/playerapi/SmartMoving.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.playerapi; 19 | 20 | import net.minecraft.client.entity.*; 21 | import net.minecraft.entity.player.*; 22 | import net.smart.moving.*; 23 | 24 | public abstract class SmartMoving 25 | { 26 | public static final String SPC_ID = "Single Player Commands"; 27 | 28 | public static void register() 29 | { 30 | SmartMovingPlayerBase.registerPlayerBase(); 31 | SmartMovingServerPlayerBase.registerPlayerBase(); 32 | } 33 | 34 | public static IEntityPlayerSP getPlayerBase(EntityPlayer entityPlayer) 35 | { 36 | if(entityPlayer instanceof EntityPlayerSP) 37 | return SmartMovingPlayerBase.getPlayerBase((EntityPlayerSP)entityPlayer); 38 | return null; 39 | } 40 | 41 | public static IEntityPlayerMP getServerPlayerBase(EntityPlayer entityPlayer) 42 | { 43 | if(entityPlayer instanceof EntityPlayerMP) 44 | return SmartMovingServerPlayerBase.getPlayerBase(entityPlayer); 45 | return null; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/playerapi/SmartMovingFactory.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.playerapi; 19 | 20 | import net.minecraft.entity.player.*; 21 | 22 | import net.smart.moving.*; 23 | 24 | public class SmartMovingFactory extends net.smart.moving.SmartMovingFactory 25 | { 26 | public static void initialize() 27 | { 28 | if(!isInitialized()) 29 | new SmartMovingFactory(); 30 | } 31 | 32 | @Override 33 | protected net.smart.moving.SmartMoving doGetInstance(EntityPlayer entityPlayer) 34 | { 35 | net.smart.moving.SmartMoving moving = super.doGetInstance(entityPlayer); 36 | if(moving != null) 37 | return moving; 38 | 39 | IEntityPlayerSP playerBase = SmartMoving.getPlayerBase(entityPlayer); 40 | if(playerBase != null) 41 | return playerBase.getMoving(); 42 | 43 | return null; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/playerapi/SmartMovingPlayerBase.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.playerapi; 19 | 20 | import api.player.client.*; 21 | 22 | import net.minecraft.block.material.*; 23 | import net.minecraft.client.*; 24 | import net.minecraft.client.entity.*; 25 | import net.minecraft.entity.player.EntityPlayer.*; 26 | import net.minecraft.nbt.*; 27 | 28 | import net.smart.moving.*; 29 | 30 | public class SmartMovingPlayerBase extends ClientPlayerBase implements IEntityPlayerSP 31 | { 32 | public static void registerPlayerBase() 33 | { 34 | ClientPlayerAPI.register(SmartMovingInfo.ModName, SmartMovingPlayerBase.class); 35 | } 36 | 37 | public static SmartMovingPlayerBase getPlayerBase(EntityPlayerSP player) 38 | { 39 | return (SmartMovingPlayerBase)((IClientPlayerAPI)player).getClientPlayerBase(SmartMovingInfo.ModName); 40 | } 41 | 42 | public SmartMovingPlayerBase(ClientPlayerAPI playerApi) 43 | { 44 | super(playerApi); 45 | moving = new SmartMovingSelf(player, this); 46 | } 47 | 48 | @Override 49 | public void beforeMoveEntity(double d, double d1, double d2) 50 | { 51 | if(!moving.isActive()) return; 52 | moving.beforeMoveEntity(d, d1, d2); 53 | } 54 | 55 | @Override 56 | public void afterMoveEntity(double d, double d1, double d2) 57 | { 58 | if(!moving.isActive()) return; 59 | moving.afterMoveEntity(d, d1, d2); 60 | } 61 | 62 | @Override 63 | public void localMoveEntity(double d, double d1, double d2) 64 | { 65 | super.moveEntity(d, d1, d2); 66 | } 67 | 68 | @Override 69 | public void beforeSleepInBedAt(int i, int j, int k) 70 | { 71 | if(!moving.isActive()) return; 72 | moving.beforeSleepInBedAt(i, j, k); 73 | } 74 | 75 | @Override 76 | public EnumStatus localSleepInBedAt(int i, int j, int k) 77 | { 78 | return super.sleepInBedAt(i, j, k); 79 | } 80 | 81 | @Override 82 | public float getBrightness(float f) 83 | { 84 | if(!moving.isActive()) return localGetBrightness(f); 85 | return moving.getBrightness(f); 86 | } 87 | 88 | @Override 89 | public float localGetBrightness(float f) 90 | { 91 | return super.getBrightness(f); 92 | } 93 | 94 | @Override 95 | public int getBrightnessForRender(float f) 96 | { 97 | if(!moving.isActive()) return localGetBrightnessForRender(f); 98 | return moving.getBrightnessForRender(f); 99 | } 100 | 101 | @Override 102 | public int localGetBrightnessForRender(float f) 103 | { 104 | return super.getBrightnessForRender(f); 105 | } 106 | 107 | @Override 108 | public boolean pushOutOfBlocks(double d, double d1, double d2) 109 | { 110 | if(!moving.isActive()) return super.pushOutOfBlocks(d, d1, d2); 111 | return moving.pushOutOfBlocks(d, d1, d2); 112 | } 113 | 114 | @Override 115 | public void beforeOnUpdate() 116 | { 117 | if(!moving.isActive()) return; 118 | moving.beforeOnUpdate(); 119 | } 120 | 121 | @Override 122 | public void afterOnUpdate() 123 | { 124 | if(!moving.isActive()) return; 125 | moving.afterOnUpdate(); 126 | } 127 | 128 | @Override 129 | public void beforeOnLivingUpdate() 130 | { 131 | if(!moving.isActive()) return; 132 | moving.beforeOnLivingUpdate(); 133 | } 134 | 135 | @Override 136 | public void afterOnLivingUpdate() 137 | { 138 | if(!moving.isActive()) return; 139 | moving.afterOnLivingUpdate(); 140 | } 141 | 142 | @Override 143 | public boolean getSleepingField() 144 | { 145 | return playerAPI.getSleepingField(); 146 | } 147 | 148 | @Override 149 | public boolean getIsInWebField() 150 | { 151 | return playerAPI.getIsInWebField(); 152 | } 153 | 154 | @Override 155 | public void setIsInWebField(boolean newIsInWeb) 156 | { 157 | playerAPI.setIsInWebField(newIsInWeb); 158 | } 159 | 160 | @Override 161 | public boolean getIsJumpingField() 162 | { 163 | return playerAPI.getIsJumpingField(); 164 | } 165 | 166 | @Override 167 | public Minecraft getMcField() 168 | { 169 | return playerAPI.getMcField(); 170 | } 171 | 172 | @Override 173 | public void moveEntityWithHeading(float f, float f1) 174 | { 175 | if(!moving.isActive()) { 176 | super.moveEntityWithHeading(f, f1); 177 | return; 178 | } 179 | moving.moveEntityWithHeading(f, f1); 180 | } 181 | 182 | @Override 183 | public boolean canTriggerWalking() 184 | { 185 | if(!moving.isActive()) return super.canTriggerWalking(); 186 | return moving.canTriggerWalking(); 187 | } 188 | 189 | @Override 190 | public boolean isOnLadder() 191 | { 192 | if(!moving.isActive()) return super.isOnLadder(); 193 | return moving.isOnLadderOrVine(); 194 | } 195 | 196 | @Override 197 | public SmartMovingSelf getMoving() 198 | { 199 | return moving; 200 | } 201 | 202 | @Override 203 | public void updateEntityActionState() 204 | { 205 | moving.tickEssential(); 206 | 207 | if(!moving.isActive()) { 208 | localUpdateEntityActionState(); 209 | return; 210 | } 211 | moving.updateEntityActionState(false); 212 | } 213 | 214 | @Override 215 | public void localUpdateEntityActionState() 216 | { 217 | super.updateEntityActionState(); 218 | } 219 | 220 | @Override 221 | public void setIsJumpingField(boolean flag) 222 | { 223 | playerAPI.setIsJumpingField(flag); 224 | } 225 | 226 | @Override 227 | public void setMoveForwardField(float f) 228 | { 229 | player.moveForward = f; 230 | } 231 | 232 | @Override 233 | public void setMoveStrafingField(float f) 234 | { 235 | player.moveStrafing = f; 236 | } 237 | 238 | @Override 239 | public boolean isInsideOfMaterial(Material material) 240 | { 241 | if(!moving.isActive()) return localIsInsideOfMaterial(material); 242 | return moving.isInsideOfMaterial(material); 243 | } 244 | 245 | @Override 246 | public boolean localIsInsideOfMaterial(Material material) 247 | { 248 | return super.isInsideOfMaterial(material); 249 | } 250 | 251 | @Override 252 | public void writeEntityToNBT(NBTTagCompound nBTTagCompound) 253 | { 254 | moving.writeEntityToNBT(nBTTagCompound); 255 | } 256 | 257 | @Override 258 | public void localWriteEntityToNBT(NBTTagCompound nBTTagCompound) 259 | { 260 | super.writeEntityToNBT(nBTTagCompound); 261 | } 262 | 263 | @Override 264 | public boolean isSneaking() 265 | { 266 | if(!moving.isActive()) return localIsSneaking(); 267 | return moving.isSneaking(); 268 | } 269 | 270 | @Override 271 | public boolean localIsSneaking() 272 | { 273 | return super.isSneaking(); 274 | } 275 | 276 | @Override 277 | public float getFOVMultiplier() 278 | { 279 | if(!moving.isActive()) return localGetFOVMultiplier(); 280 | return moving.getFOVMultiplier(); 281 | } 282 | 283 | @Override 284 | public float localGetFOVMultiplier() 285 | { 286 | return playerAPI.localGetFOVMultiplier(); 287 | } 288 | 289 | @Override 290 | public void beforeSetPositionAndRotation(double d, double d1, double d2, float f, float f1) 291 | { 292 | if(!moving.isActive()) return; 293 | moving.beforeSetPositionAndRotation(); 294 | } 295 | 296 | @Override 297 | public void beforeGetSleepTimer() 298 | { 299 | if(!moving.isActive()) return; 300 | moving.beforeGetSleepTimer(); 301 | } 302 | 303 | @Override 304 | public void jump() 305 | { 306 | if(!moving.isActive()) { 307 | super.jump(); 308 | return; 309 | } 310 | moving.jump(); 311 | } 312 | 313 | public SmartMovingSelf moving; 314 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/playerapi/SmartMovingSelf.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.playerapi; 19 | 20 | import java.lang.reflect.*; 21 | 22 | import api.player.client.*; 23 | 24 | import net.minecraft.client.entity.*; 25 | import net.minecraft.entity.player.*; 26 | 27 | import net.smart.moving.config.*; 28 | import net.smart.utilities.*; 29 | 30 | public class SmartMovingSelf extends net.smart.moving.SmartMovingSelf 31 | { 32 | public SmartMovingSelf(EntityPlayer sp, SmartMovingPlayerBase playerBase) 33 | { 34 | super(sp, playerBase); 35 | } 36 | 37 | @Override 38 | public boolean doFlyingAnimation() 39 | { 40 | return SmartMovingOptions.hasSinglePlayerCommands && isSPCFlying(esp) || super.doFlyingAnimation(); 41 | } 42 | 43 | public static boolean isSPCFlying(EntityPlayerSP entityPlayer) 44 | { 45 | if(!SmartMovingOptions.hasSinglePlayerCommands) 46 | return false; 47 | 48 | ClientPlayerBase spcPlayerBase = ((IClientPlayerAPI)entityPlayer).getClientPlayerBase(SmartMoving.SPC_ID); 49 | if(spcPlayerBase == null) 50 | return false; 51 | 52 | if(playerHelperField == null) 53 | playerHelperField = Reflect.GetField(spcPlayerBase.getClass(), new Name("ph"), false); 54 | if(playerHelperField == null) 55 | return false; 56 | 57 | Object playerHelper = Reflect.GetField(playerHelperField, spcPlayerBase); 58 | if(playerHelper == null) 59 | return false; 60 | 61 | if(flyingField == null) 62 | flyingField = Reflect.GetField(playerHelper.getClass(), new Name("flying"), false); 63 | if(flyingField == null) 64 | return false; 65 | 66 | Object isFlying = Reflect.GetField(flyingField, playerHelper); 67 | if(isFlying == null) 68 | return false; 69 | 70 | return isFlying instanceof Boolean && (Boolean)isFlying; 71 | } 72 | 73 | private static Field playerHelperField = null; 74 | private static Field flyingField = null; 75 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/playerapi/SmartMovingServerPlayerBase.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.playerapi; 19 | 20 | import io.netty.buffer.*; 21 | 22 | import java.util.*; 23 | 24 | import cpw.mods.fml.common.network.internal.*; 25 | 26 | import api.player.server.*; 27 | 28 | import net.smart.moving.*; 29 | import net.smart.utilities.*; 30 | import net.minecraft.entity.*; 31 | import net.minecraft.util.*; 32 | 33 | public class SmartMovingServerPlayerBase extends ServerPlayerBase implements IEntityPlayerMP 34 | { 35 | public static void registerPlayerBase() 36 | { 37 | ServerPlayerAPI.register(SmartMovingInfo.ModName, SmartMovingServerPlayerBase.class); 38 | } 39 | 40 | public static SmartMovingServerPlayerBase getPlayerBase(Object player) 41 | { 42 | return (SmartMovingServerPlayerBase)((IServerPlayerAPI)player).getServerPlayerBase(SmartMovingInfo.ModName); 43 | } 44 | 45 | public SmartMovingServerPlayerBase(ServerPlayerAPI playerApi) 46 | { 47 | super(playerApi); 48 | moving = new SmartMovingServer(this, false); 49 | } 50 | 51 | @Override 52 | public float getHeight() 53 | { 54 | return player.height; 55 | } 56 | 57 | @Override 58 | public double getMinY() 59 | { 60 | return player.boundingBox.minY; 61 | } 62 | 63 | @Override 64 | public void setMaxY(double maxY) 65 | { 66 | player.boundingBox.maxY = maxY; 67 | } 68 | 69 | @Override 70 | public void afterSetPosition(double d, double d1, double d2) 71 | { 72 | moving.afterSetPosition(d, d1, d2); 73 | } 74 | 75 | @Override 76 | public void beforeIsPlayerSleeping() 77 | { 78 | moving.beforeIsPlayerSleeping(); 79 | } 80 | 81 | @Override 82 | public void beforeOnUpdate() 83 | { 84 | moving.beforeOnUpdate(); 85 | } 86 | 87 | @Override 88 | public void afterOnUpdate() 89 | { 90 | moving.afterOnUpdate(); 91 | } 92 | 93 | @Override 94 | public void beforeOnLivingUpdate() 95 | { 96 | moving.beforeOnLivingUpdate(); 97 | } 98 | 99 | @Override 100 | public void afterOnLivingUpdate() 101 | { 102 | moving.afterOnLivingUpdate(); 103 | } 104 | 105 | @Override 106 | public float doGetHealth() 107 | { 108 | return player.getHealth(); 109 | } 110 | 111 | @Override 112 | public AxisAlignedBB getBox() 113 | { 114 | return player.boundingBox; 115 | } 116 | 117 | @Override 118 | public AxisAlignedBB expandBox(AxisAlignedBB box, double x, double y, double z) 119 | { 120 | return box.expand(x, y, z); 121 | } 122 | 123 | @Override 124 | public List getEntitiesExcludingPlayer(AxisAlignedBB box) 125 | { 126 | return player.worldObj.getEntitiesWithinAABBExcludingEntity(player, box); 127 | } 128 | 129 | @Override 130 | public boolean isDeadEntity(Entity entity) 131 | { 132 | return entity.isDead; 133 | } 134 | 135 | @Override 136 | public void onCollideWithPlayer(Entity entity) 137 | { 138 | entity.onCollideWithPlayer(player); 139 | } 140 | 141 | @Override 142 | public float getEyeHeight() 143 | { 144 | return player.height - 0.18F; 145 | } 146 | 147 | @Override 148 | public boolean isEntityInsideOpaqueBlock() 149 | { 150 | return moving.isEntityInsideOpaqueBlock(); 151 | } 152 | 153 | @Override 154 | public boolean localIsEntityInsideOpaqueBlock() 155 | { 156 | return super.isEntityInsideOpaqueBlock(); 157 | } 158 | 159 | @Override 160 | public void addExhaustion(float exhaustion) 161 | { 162 | moving.addExhaustion(exhaustion); 163 | } 164 | 165 | @Override 166 | public void localAddExhaustion(float exhaustion) 167 | { 168 | super.addExhaustion(exhaustion); 169 | } 170 | 171 | @Override 172 | public void addMovementStat(double x, double y, double z) 173 | { 174 | moving.addMovementStat(x, y, z); 175 | } 176 | 177 | @Override 178 | public void localAddMovementStat(double x, double y, double z) 179 | { 180 | super.addMovementStat(x, y, z); 181 | } 182 | 183 | @Override 184 | public void localPlaySound(String soundId, float volume, float pitch) 185 | { 186 | player.playSound(soundId, volume, pitch); 187 | } 188 | 189 | @Override 190 | public void beforeUpdatePotionEffects() 191 | { 192 | moving.afterAddMovingHungerBatch(); 193 | } 194 | 195 | @Override 196 | public void afterUpdatePotionEffects() 197 | { 198 | moving.beforeAddMovingHungerBatch(); 199 | } 200 | 201 | @Override 202 | public boolean isSneaking() 203 | { 204 | return moving.isSneaking(); 205 | } 206 | 207 | @Override 208 | public boolean localIsSneaking() 209 | { 210 | return playerAPI.localIsSneaking(); 211 | } 212 | 213 | @Override 214 | public void setHeight(float height) 215 | { 216 | player.height = height; 217 | } 218 | 219 | @Override 220 | public void sendPacket(byte[] data) 221 | { 222 | player.playerNetServerHandler.sendPacket(new FMLProxyPacket(Unpooled.wrappedBuffer(data), SmartMovingPacketStream.Id)); 223 | } 224 | 225 | @Override 226 | public String getUsername() 227 | { 228 | return player.getGameProfile().getName(); 229 | } 230 | 231 | @Override 232 | public void resetFallDistance() 233 | { 234 | player.fallDistance = 0; 235 | player.motionY = 0.08; 236 | } 237 | 238 | @Override 239 | public void resetTicksForFloatKick() 240 | { 241 | Reflect.SetField(net.minecraft.network.NetHandlerPlayServer.class, player.playerNetServerHandler, SmartMovingInstall.NetServerHandler_ticksForFloatKick, 0); 242 | } 243 | 244 | @Override 245 | public void sendPacketToTrackedPlayers(FMLProxyPacket packet) 246 | { 247 | player.mcServer.worldServerForDimension(player.dimension).getEntityTracker().func_151247_a(player, packet); 248 | } 249 | 250 | @Override 251 | public SmartMovingServer getMoving() 252 | { 253 | return moving; 254 | } 255 | 256 | @Override 257 | public IEntityPlayerMP[] getAllPlayers() 258 | { 259 | List playerEntityList = player.mcServer.getConfigurationManager().playerEntityList; 260 | IEntityPlayerMP[] result = new IEntityPlayerMP[playerEntityList.size()]; 261 | for(int i=0; i. 16 | // ================================================================== 17 | 18 | package net.smart.moving.render; 19 | 20 | public interface IModelPlayer 21 | { 22 | SmartMovingModel getMovingModel(); 23 | 24 | void superAnimateHeadRotation(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 25 | void superAnimateSleeping(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 26 | void superAnimateArmSwinging(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 27 | void superAnimateRiding(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 28 | void superAnimateLeftArmItemHolding(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 29 | void superAnimateRightArmItemHolding(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 30 | void superAnimateWorkingBody(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 31 | void superAnimateWorkingArms(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 32 | void superAnimateSneaking(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 33 | void superApplyAnimationOffsets(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 34 | void superAnimateBowAiming(float totalHorizontalDistance, float currentHorizontalSpeed, float totalTime, float viewHorizontalAngelOffset, float viewVerticalAngelOffset, float factor); 35 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/render/IRenderPlayer.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.render; 19 | 20 | import net.minecraft.client.entity.*; 21 | import net.minecraft.client.renderer.entity.*; 22 | import net.minecraft.entity.*; 23 | 24 | public interface IRenderPlayer 25 | { 26 | void superRenderRenderPlayer(AbstractClientPlayer entityplayer, double d, double d1, double d2, float f, float renderPartialTicks); 27 | 28 | void superRenderRotatePlayer(AbstractClientPlayer entityplayer, float totalTime, float actualRotation, float f2); 29 | 30 | void superRenderRenderPlayerAt(AbstractClientPlayer entityplayer, double d, double d1, double d2); 31 | 32 | void superRenderRenderName(EntityLivingBase par1EntityPlayer, double par2, double par4, double par6); 33 | 34 | RenderManager getRenderManager(); 35 | 36 | IModelPlayer getPlayerModelBipedMain(); 37 | 38 | IModelPlayer getPlayerModelArmorChestplate(); 39 | 40 | IModelPlayer getPlayerModelArmor(); 41 | 42 | IModelPlayer[] getPlayerModels(); 43 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/render/RenderPlayer.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.render; 19 | 20 | import net.minecraft.client.entity.*; 21 | import net.minecraft.client.model.*; 22 | import net.minecraft.client.renderer.entity.*; 23 | import net.minecraft.entity.*; 24 | 25 | public class RenderPlayer extends net.smart.render.RenderPlayer implements IRenderPlayer 26 | { 27 | public RenderPlayer() 28 | { 29 | render = new SmartMovingRender(this); 30 | } 31 | 32 | @Override 33 | public net.smart.render.IModelPlayer createModel(ModelBiped existing, float f) 34 | { 35 | return new ModelPlayer(f); 36 | } 37 | 38 | @Override 39 | public void doRender(AbstractClientPlayer entityplayer, double d, double d1, double d2, float f, float renderPartialTicks) 40 | { 41 | render.renderPlayer(entityplayer, d, d1, d2, f, renderPartialTicks); 42 | } 43 | 44 | @Override 45 | public void superRenderRenderPlayer(AbstractClientPlayer entityplayer, double d, double d1, double d2, float f, float renderPartialTicks) 46 | { 47 | super.doRender(entityplayer, d, d1, d2, f, renderPartialTicks); 48 | } 49 | 50 | @Override 51 | protected void rotateCorpse(AbstractClientPlayer entityplayer, float totalTime, float actualRotation, float f2) 52 | { 53 | render.rotatePlayer(entityplayer, totalTime, actualRotation, f2); 54 | } 55 | 56 | @Override 57 | public void superRenderRotatePlayer(AbstractClientPlayer entityplayer, float totalTime, float actualRotation, float f2) 58 | { 59 | super.rotateCorpse(entityplayer, totalTime, actualRotation, f2); 60 | } 61 | 62 | @Override 63 | protected void renderLivingAt(AbstractClientPlayer entityplayer, double d, double d1, double d2) 64 | { 65 | render.renderPlayerAt(entityplayer, d, d1, d2); 66 | } 67 | 68 | @Override 69 | public void superRenderRenderPlayerAt(AbstractClientPlayer entityplayer, double d, double d1, double d2) 70 | { 71 | super.renderLivingAt(entityplayer, d, d1, d2); 72 | } 73 | 74 | @Override 75 | protected void passSpecialRender(EntityLivingBase par1EntityLiving, double par2, double par4, double par6) 76 | { 77 | render.renderName(par1EntityLiving, par2, par4, par6); 78 | } 79 | 80 | @Override 81 | public void superRenderRenderName(EntityLivingBase par1EntityLiving, double par2, double par4, double par6) 82 | { 83 | super.passSpecialRender(par1EntityLiving, par2, par4, par6); 84 | } 85 | 86 | @Override 87 | public RenderManager getRenderManager() 88 | { 89 | return renderManager; 90 | } 91 | 92 | @Override 93 | public IModelPlayer getPlayerModelBipedMain() 94 | { 95 | return (ModelPlayer)super.getModelBipedMain(); 96 | } 97 | 98 | @Override 99 | public IModelPlayer getPlayerModelArmorChestplate() 100 | { 101 | return (ModelPlayer)super.getModelArmorChestplate(); 102 | } 103 | 104 | @Override 105 | public IModelPlayer getPlayerModelArmor() 106 | { 107 | return (ModelPlayer)super.getModelArmor(); 108 | } 109 | 110 | @Override 111 | public IModelPlayer[] getPlayerModels() 112 | { 113 | if(allIModelPlayers == null) 114 | allIModelPlayers = new IModelPlayer[] { getPlayerModelBipedMain(), getPlayerModelArmorChestplate(), getPlayerModelArmor() }; 115 | return allIModelPlayers; 116 | } 117 | 118 | private IModelPlayer[] allIModelPlayers; 119 | 120 | private final SmartMovingRender render; 121 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/render/SmartRenderContext.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.render; 19 | 20 | import net.smart.moving.*; 21 | 22 | public abstract class SmartRenderContext extends SmartMovingContext 23 | { 24 | public static final int Scale = 0; 25 | public static final int NoScaleStart = 1; 26 | public static final int NoScaleEnd = 2; 27 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/render/playerapi/SmartMoving.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.render.playerapi; 19 | 20 | import api.player.model.*; 21 | import api.player.render.*; 22 | 23 | import net.smart.moving.*; 24 | import net.smart.render.playerapi.*; 25 | 26 | public abstract class SmartMoving 27 | { 28 | public static final String ID = SmartMovingInfo.ModName; 29 | 30 | public static void register() 31 | { 32 | String[] inferiors = new String[] { SmartRender.ID }; 33 | 34 | RenderPlayerBaseSorting renderSorting = new RenderPlayerBaseSorting(); 35 | renderSorting.setAfterLocalConstructingInferiors(inferiors); 36 | renderSorting.setOverrideRenderPlayerInferiors(inferiors); 37 | renderSorting.setOverrideRotatePlayerInferiors(inferiors); 38 | renderSorting.setOverrideRenderPlayerSleepInferiors(inferiors); 39 | RenderPlayerAPI.register(ID, SmartMovingRenderPlayerBase.class, renderSorting); 40 | 41 | ModelPlayerBaseSorting modelSorting = new ModelPlayerBaseSorting(); 42 | modelSorting.setAfterLocalConstructingInferiors(inferiors); 43 | ModelPlayerAPI.register(ID, SmartMovingModelPlayerBase.class, modelSorting); 44 | } 45 | 46 | public static SmartMovingRenderPlayerBase getPlayerBase(net.minecraft.client.renderer.entity.RenderPlayer renderPlayer) 47 | { 48 | return (SmartMovingRenderPlayerBase)((IRenderPlayerAPI)renderPlayer).getRenderPlayerBase(ID); 49 | } 50 | 51 | public static SmartMovingModelPlayerBase getPlayerBase(api.player.model.ModelPlayer modelPlayer) 52 | { 53 | return (SmartMovingModelPlayerBase)((IModelPlayerAPI)modelPlayer).getModelPlayerBase(ID); 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/render/playerapi/SmartMovingRenderPlayerBase.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Moving. 3 | // 4 | // Smart Moving is free software: you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // Smart Moving is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Moving. If not, see . 16 | // ================================================================== 17 | 18 | package net.smart.moving.render.playerapi; 19 | 20 | import net.minecraft.client.entity.*; 21 | import net.minecraft.client.renderer.entity.*; 22 | import net.minecraft.entity.*; 23 | 24 | import api.player.render.*; 25 | 26 | import net.smart.moving.render.*; 27 | import net.smart.moving.render.IRenderPlayer; 28 | 29 | public class SmartMovingRenderPlayerBase extends RenderPlayerBase implements IRenderPlayer 30 | { 31 | public SmartMovingRenderPlayerBase(RenderPlayerAPI renderPlayerAPI) 32 | { 33 | super(renderPlayerAPI); 34 | } 35 | 36 | public SmartMovingRender getRenderModel() 37 | { 38 | if(render == null) 39 | render = new SmartMovingRender(this); 40 | return render; 41 | } 42 | 43 | @Override 44 | public void renderPlayer(AbstractClientPlayer entityplayer, double d, double d1, double d2, float f, float renderPartialTicks) 45 | { 46 | getRenderModel().renderPlayer(entityplayer, d, d1, d2, f, renderPartialTicks); 47 | } 48 | 49 | @Override 50 | public void superRenderRenderPlayer(AbstractClientPlayer entityplayer, double d, double d1, double d2, float f, float renderPartialTicks) 51 | { 52 | super.renderPlayer(entityplayer, d, d1, d2, f, renderPartialTicks); 53 | } 54 | 55 | @Override 56 | public void rotatePlayer(AbstractClientPlayer entityplayer, float totalTime, float actualRotation, float f2) 57 | { 58 | getRenderModel().rotatePlayer(entityplayer, totalTime, actualRotation, f2); 59 | } 60 | 61 | @Override 62 | public void superRenderRotatePlayer(AbstractClientPlayer entityplayer, float totalTime, float actualRotation, float f2) 63 | { 64 | super.rotatePlayer(entityplayer, totalTime, actualRotation, f2); 65 | } 66 | 67 | @Override 68 | public void renderPlayerSleep(AbstractClientPlayer entityplayer, double d, double d1, double d2) 69 | { 70 | getRenderModel().renderPlayerAt(entityplayer, d, d1, d2); 71 | } 72 | 73 | @Override 74 | public void superRenderRenderPlayerAt(AbstractClientPlayer entityplayer, double d, double d1, double d2) 75 | { 76 | super.renderPlayerSleep(entityplayer, d, d1, d2); 77 | } 78 | 79 | @Override 80 | public void passSpecialRender(EntityLivingBase entityliving, double d, double d1, double d2) 81 | { 82 | getRenderModel().renderName(entityliving, d, d1, d2); 83 | } 84 | 85 | @Override 86 | public void superRenderRenderName(EntityLivingBase entityplayer, double d, double d1, double d2) 87 | { 88 | super.passSpecialRender(entityplayer, d, d1, d2); 89 | } 90 | 91 | @Override 92 | public RenderManager getRenderManager() 93 | { 94 | return renderPlayerAPI.getRenderManagerField(); 95 | } 96 | 97 | public boolean isRenderedWithBodyTopAlwaysInAccelerateDirection() 98 | { 99 | SmartMovingRender render = getRenderModel(); 100 | return render.modelBipedMain.isFlying || render.modelBipedMain.isSwim || render.modelBipedMain.isDive || render.modelBipedMain.isHeadJump; 101 | } 102 | 103 | @Override 104 | public IModelPlayer getPlayerModelArmor() 105 | { 106 | return SmartMoving.getPlayerBase((api.player.model.ModelPlayer)renderPlayerAPI.getModelArmorField()); 107 | } 108 | 109 | @Override 110 | public IModelPlayer getPlayerModelArmorChestplate() 111 | { 112 | return SmartMoving.getPlayerBase((api.player.model.ModelPlayer)renderPlayerAPI.getModelArmorChestplateField()); 113 | } 114 | 115 | @Override 116 | public IModelPlayer getPlayerModelBipedMain() 117 | { 118 | return SmartMoving.getPlayerBase((api.player.model.ModelPlayer)renderPlayerAPI.getModelBipedMainField()); 119 | } 120 | 121 | @Override 122 | public IModelPlayer[] getPlayerModels() 123 | { 124 | api.player.model.ModelPlayer[] modelPlayers = api.player.model.ModelPlayerAPI.getAllInstances(); 125 | if(allModelPlayers != null && (allModelPlayers == modelPlayers || modelPlayers.length == 0 && allModelPlayers.length == 0)) 126 | return allIModelPlayers; 127 | 128 | allModelPlayers = modelPlayers; 129 | allIModelPlayers = new IModelPlayer[modelPlayers.length]; 130 | for(int i=0; i> Starting test. Keep the game focused, and don't touch anything! I hope you're on a superflat world with a spawn-proof block.")); 32 | SmartMovingTestMod.instance.startTest(); 33 | return; 34 | } 35 | } 36 | throw new WrongUsageException(getCommandName() + " run"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/smart/moving/test/SmartMovingTestMod.java: -------------------------------------------------------------------------------- 1 | package net.smart.moving.test; 2 | 3 | import java.io.FileWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import java.util.Locale; 9 | import java.util.function.Function; 10 | 11 | import org.apache.logging.log4j.LogManager; 12 | import org.apache.logging.log4j.Logger; 13 | import org.lwjgl.input.Keyboard; 14 | 15 | import cpw.mods.fml.common.FMLCommonHandler; 16 | import cpw.mods.fml.common.Mod; 17 | import cpw.mods.fml.common.Mod.EventHandler; 18 | import cpw.mods.fml.common.event.FMLInitializationEvent; 19 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 20 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 21 | import cpw.mods.fml.common.gameevent.TickEvent.Phase; 22 | import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; 23 | import cpw.mods.fml.relauncher.ReflectionHelper; 24 | import cpw.mods.fml.relauncher.Side; 25 | import net.minecraft.client.Minecraft; 26 | import net.minecraft.client.audio.PositionedSoundRecord; 27 | import net.minecraft.client.settings.GameSettings; 28 | import net.minecraft.client.settings.KeyBinding; 29 | import net.minecraft.entity.player.EntityPlayer; 30 | import net.minecraft.util.ResourceLocation; 31 | import net.minecraftforge.client.ClientCommandHandler; 32 | 33 | @Mod(modid = "SmartMovingTestMod", version = "0.0") 34 | public class SmartMovingTestMod { 35 | 36 | public static final Logger LOGGER = LogManager.getLogger("smartmovingtest"); 37 | 38 | private static final int TEST_TICKS_PER_SECOND = Integer.parseInt(System.getProperty("smartMovingTest.ticksPerSecond", "20")); 39 | 40 | private double lastX; 41 | private double lastY; 42 | private double lastZ; 43 | private TestEvent lastEventRun; 44 | 45 | private boolean running; 46 | private int time; 47 | 48 | public static SmartMovingTestMod instance; 49 | private static Minecraft mc; 50 | 51 | FileWriter out; 52 | 53 | private static final List testEvents = Arrays.asList( 54 | new TestEvent("WAIT_BEFORE_WALK", 3, () -> mc.thePlayer.sendChatMessage("/effect @p clear")), 55 | new TestEvent("WALK_PRE", 4, new SetKeyState(gs -> gs.keyBindForward, true)), 56 | new TestEvent("WALK_JUMP", 8, new SetKeyState(gs -> gs.keyBindJump, true)), 57 | new TestEvent("WALK_END", 4, new SetKeyState(gs -> gs.keyBindJump, false)), 58 | new TestEvent("SPRINT_PREPARE", 2, new SetKeyState(gs -> gs.keyBindSprint, true)), 59 | new TestEvent("SPRINT_PRE", 4, new SetKeyState(gs -> gs.keyBindSprint, false)), 60 | new TestEvent("SPRINT_JUMP", 8, new SetKeyState(gs -> gs.keyBindJump, true)), 61 | new TestEvent("SPRINT_END", 4, new SetKeyState(gs -> gs.keyBindJump, false)), 62 | new TestEvent("WAIT_BEFORE_SWIFT", 3, new SetKeyState(gs -> gs.keyBindForward, false)), 63 | new TestEvent("SWIFT_PREPARE", 2, () -> mc.thePlayer.sendChatMessage("/effect @p 1 600 0")), 64 | new TestEvent("SWIFT_WALK_PRE", 4, new SetKeyState(gs -> gs.keyBindForward, true)), 65 | new TestEvent("SWIFT_WALK_JUMP", 8, new SetKeyState(gs -> gs.keyBindJump, true)), 66 | new TestEvent("SWIFT_WALK_END", 4, new SetKeyState(gs -> gs.keyBindJump, false)), 67 | new TestEvent("SWIFT_SPRINT_PREPARE", 2, new SetKeyState(gs -> gs.keyBindSprint, true)), 68 | new TestEvent("SWIFT_SPRINT_PRE", 4, new SetKeyState(gs -> gs.keyBindSprint, false)), 69 | new TestEvent("SWIFT_SPRINT_JUMP", 8, new SetKeyState(gs -> gs.keyBindJump, true)), 70 | new TestEvent("SWIFT_SPRINT_END", 4, new SetKeyState(gs -> gs.keyBindJump, false)), 71 | new TestEvent("WAIT_BEFORE_HIJUMP", 3, new SetKeyState(gs -> gs.keyBindForward, false)), 72 | new TestEvent("HIJUMP_PREPARE_1", 1, () -> mc.thePlayer.sendChatMessage("/effect @p clear")), 73 | new TestEvent("HIJUMP_PREPARE_2", 1, () -> mc.thePlayer.sendChatMessage("/effect @p 8 600 0")), 74 | new TestEvent("HIJUMP_WALK_PRE", 4, new SetKeyState(gs -> gs.keyBindForward, true)), 75 | new TestEvent("HIJUMP_JUMP", 8, new SetKeyState(gs -> gs.keyBindJump, true)), 76 | new TestEvent("HIJUMP_WALK_END", 4, new SetKeyState(gs -> gs.keyBindJump, false)), 77 | new TestEvent("WAIT_BEFORE_FINISH", 3, new SetKeyState(gs -> gs.keyBindForward, false)), 78 | new TestEvent("FINISH", 1, () -> mc.thePlayer.sendChatMessage("/effect @p clear")) 79 | ); 80 | 81 | private static class TestEvent { 82 | 83 | String name; 84 | int duration; 85 | Runnable[] actions; 86 | 87 | private TestEvent(String name, int duration, Runnable...actions) { 88 | this.name = name; 89 | this.duration = duration; 90 | this.actions = actions; 91 | } 92 | } 93 | 94 | private static class SetKeyState implements Runnable { 95 | 96 | private KeyBinding keyBind; 97 | private boolean state; 98 | 99 | public SetKeyState(Function keyFunction, boolean state) { 100 | keyBind = keyFunction.apply(Minecraft.getMinecraft().gameSettings); 101 | this.state = state; 102 | } 103 | 104 | @Override 105 | public void run() { 106 | // Not using KeyBinding.setKeyBindState because it doesn't work with conflicting keybinds 107 | ReflectionHelper.setPrivateValue(KeyBinding.class, keyBind, state, "pressed", "field_74513_e"); 108 | } 109 | 110 | } 111 | 112 | @EventHandler 113 | public void preinit(FMLPreInitializationEvent event) { 114 | instance = this; 115 | mc = Minecraft.getMinecraft(); 116 | FMLCommonHandler.instance().bus().register(this); 117 | } 118 | 119 | @EventHandler 120 | public void init(FMLInitializationEvent event) { 121 | ClientCommandHandler.instance.registerCommand(new SmartMovingTestCommand()); 122 | } 123 | 124 | @SubscribeEvent 125 | public void onTick(PlayerTickEvent event) { 126 | if(event.side == Side.CLIENT && event.phase == Phase.START && running) { 127 | if(Keyboard.isKeyDown(Keyboard.KEY_P)) { 128 | System.out.println("P key pressed, aborting test!"); 129 | running = false; 130 | } 131 | 132 | int timeCounter = 0; 133 | TestEvent eventRun = null; 134 | for(TestEvent e : testEvents) { 135 | if(time == timeCounter) { 136 | System.out.println("Running event " + e.name + " for " + e.duration + " seconds."); 137 | eventRun = e; 138 | for(Runnable a : e.actions) { 139 | a.run(); 140 | } 141 | break; 142 | } 143 | timeCounter += e.duration * TEST_TICKS_PER_SECOND; 144 | } 145 | if(time > timeCounter) { 146 | System.out.println("All test events executed!"); 147 | mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("random.levelup"), 1.0F)); 148 | running = false; 149 | } 150 | 151 | PlayerTickEvent pte = (PlayerTickEvent)event; 152 | double x = pte.player.posX; 153 | double y = pte.player.posY; 154 | double z = pte.player.posZ; 155 | 156 | String line = String.format(Locale.ROOT, "%12.4f%12.4f%12.4f", x-lastX, y-lastY, z-lastZ); 157 | ArrayList comments = new ArrayList<>(); 158 | if(time == 0) { 159 | if(TEST_TICKS_PER_SECOND != 20) { 160 | comments.add("note: ticks per second: " + TEST_TICKS_PER_SECOND); 161 | } 162 | } 163 | if(lastEventRun != null) { 164 | comments.add("start " + lastEventRun.name); 165 | } 166 | if(!comments.isEmpty()) { 167 | line += " # " + String.join("; ", comments); 168 | } 169 | line += "\n"; 170 | 171 | if(time != 0) { 172 | try { 173 | out.write(line); 174 | } catch (IOException e) { 175 | e.printStackTrace(); 176 | } 177 | } 178 | 179 | time++; 180 | 181 | lastX = x; 182 | lastY = y; 183 | lastZ = z; 184 | lastEventRun = eventRun; 185 | 186 | if(!running) { 187 | try { 188 | out.close(); 189 | } catch (IOException e) { 190 | e.printStackTrace(); 191 | } 192 | } 193 | } 194 | } 195 | 196 | public void startTest() { 197 | System.out.println("Tests will take " + testEvents.stream().mapToInt(e -> e.duration).sum() + " seconds in total."); 198 | 199 | EntityPlayer player = Minecraft.getMinecraft().thePlayer; 200 | player.rotationPitch = player.rotationYaw = 0; 201 | time = 0; 202 | try { 203 | out = new FileWriter("smart-moving-test-output.txt"); 204 | } catch (IOException e) { 205 | e.printStackTrace(); 206 | } 207 | running = true; 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /src/main/java/net/smart/utilities/Name.java: -------------------------------------------------------------------------------- 1 | // ================================================================== 2 | // This file is part of Smart Render and Smart Moving. 3 | // 4 | // Smart Render and Smart Moving is free software: you can 5 | // redistribute it and/or modify it under the terms of the GNU General 6 | // Public Licenses published by the Free Software Foundation, either 7 | // version 3 of the License, or (at your option) any later version. 8 | // 9 | // Smart Render and Smart Moving is distributed in the hope that it 10 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | // See the GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with Smart Render and Smart Moving. If not, see 16 | // . 17 | // ================================================================== 18 | 19 | package net.smart.utilities; 20 | 21 | public class Name 22 | { 23 | public final String obfuscated; 24 | public final String forgefuscated; 25 | public final String deobfuscated; 26 | 27 | public Name(String name) 28 | { 29 | this(name, null); 30 | } 31 | 32 | public Name(String deobfuscatedName, String obfuscatedName) 33 | { 34 | this(deobfuscatedName, null, obfuscatedName); 35 | } 36 | 37 | public Name(String deobfuscatedName, String forgefuscatedName, String obfuscatedName) 38 | { 39 | deobfuscated = deobfuscatedName; 40 | forgefuscated = forgefuscatedName; 41 | obfuscated = obfuscatedName; 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/resources/META-INF/smartmoving_at.cfg: -------------------------------------------------------------------------------- 1 | public net.minecraft.client.multiplayer.PlayerControllerMP field_78779_k #currentGameType 2 | -------------------------------------------------------------------------------- /src/main/resources/assets/smartmoving/gui/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/src/main/resources/assets/smartmoving/gui/icons.png -------------------------------------------------------------------------------- /src/main/resources/assets/smartmoving/lang/en_US.lang: -------------------------------------------------------------------------------- 1 | #===========# 2 | # Key Names # 3 | #===========# 4 | 5 | key.climb=Grab 6 | key.config.toggle=Change Configuration 7 | key.speed.increase=Increase Speed 8 | key.speed.decrease=Decrease Speed 9 | key.categories.smartmoving=Smart Moving 10 | 11 | 12 | 13 | #====================================# 14 | # Configuration change chat messages # 15 | #====================================# 16 | 17 | # Used to announce whether a global or local Smart Moving configuration is used 18 | move.config.chat.server.global.unnamed=Using Smart Moving server configuration 19 | move.config.chat.server.global.named=Using Smart Moving server configuration '%s' 20 | move.config.chat.server.local=Using local Smart Moving configurations 21 | 22 | # Used when the Smart Moving configuration is changed by the server 23 | move.config.chat.server.disable=Smart Moving was disabled by the server configuration 24 | move.config.chat.server.update.named=Smart Moving server configuration was set to '%s' 25 | move.config.chat.server.update.unnamed=Smart Moving server configuration was updated 26 | move.config.chat.server.enable=Smart Moving was enabled by the server configuration 27 | 28 | # Used when the Smart Moving configuration is changed by another player 29 | move.config.chat.server.disable.user=Smart Moving disabled by '%s' 30 | move.config.chat.server.update.named.user=Smart Moving set to '%s' by '%s' 31 | move.config.chat.server.update.unnamed.user=Smart Moving server configuration was updated by '%s' 32 | move.config.chat.server.enable.user=Smart Moving enabled by '%s' 33 | 34 | # Used when a player with no rights tries to change the Smart Moving configuration 35 | move.config.chat.server.illegal.remote=You have no rights to change the Smart Moving configuration on the remote server. 36 | move.config.chat.server.illegal.local=You have no rights to change the Smart Moving configuration on your local server. 37 | 38 | # Used when a player changes the Smart Moving configuration for himself alone 39 | move.config.chat.client.disabled=Smart Moving disabled 40 | move.config.chat.client.enabled=Smart Moving enabled 41 | move.config.chat.client.unnamed=Smart Moving set to key '%s' 42 | move.config.chat.client.named=Smart Moving set to '%s' 43 | move.config.chat.client.help=(switch by pressing '%s') 44 | 45 | # Used when a player changes the Smart Moving configuration for everybody 46 | move.config.chat.client.everyone.disabled=Smart Moving disabled for all players 47 | move.config.chat.client.everyone.enabled=Smart Moving enabled for all players 48 | move.config.chat.client.everyone.unnamed=Smart Moving set to key '%s' for all players 49 | move.config.chat.client.everyone.named=Smart Moving set to '%s' for all players 50 | 51 | 52 | 53 | #============================# 54 | # Speed change chat messages # 55 | #============================# 56 | 57 | # Used when the Smart Moving speed is changed by another player 58 | move.speed.chat.server.change=Smart Moving speed changed to %s%% by '%s' 59 | move.speed.chat.server.reset=Smart Moving speed changed to 100%% by '%s' 60 | 61 | # Used when a player with no rights tries to change the Smart Moving speed 62 | move.speed.chat.server.illegal.remote=You have no rights to change the Smart Moving speed on the remote server. 63 | move.speed.chat.server.illegal.local=You have no rights to change the Smart Moving speed on your local server. 64 | 65 | # Used when a player changes the Smart Moving speed for himself alone 66 | move.speed.chat.client.init=Smart Moving speed is %s%% 67 | move.speed.chat.client.help=(increase speed by pressing '%s', decrease by pressing '%s') 68 | move.speed.chat.client.change=Smart Moving speed changed to %s%% 69 | move.speed.chat.client.reset=Smart Moving speed changed to 100%% 70 | 71 | # Used when a player changes the Smart Moving speed for everybody 72 | move.speed.chat.client.everyone.change=Smart Moving speed changed to %s%% for all players 73 | move.speed.chat.client.everyone.reset=Smart Moving speed changed to 100%% for all players -------------------------------------------------------------------------------- /src/main/resources/assets/smartmoving/lang/nl_NL.lang: -------------------------------------------------------------------------------- 1 | # Translated by Dunncann 2 | 3 | #===========# 4 | # Key Names # 5 | #===========# 6 | 7 | key.climb=Grijp 8 | key.config.toggle=Configuratie Aanpassen 9 | key.speed.increase=Sneller 10 | key.speed.decrease=Langzamer 11 | 12 | 13 | 14 | #====================================# 15 | # Configuration change chat messages # 16 | #====================================# 17 | 18 | # Used to announce whether a global or local Smart Moving configuration is used 19 | move.config.chat.server.global.unnamed=Smart Moving server-configuratie wordt gebruikt 20 | move.config.chat.server.global.named=Smart Moving server-configuratie '%s' wordt gebruikt 21 | move.config.chat.server.local=Locale Smart Moving configuraties worden gebruikt 22 | 23 | # Used when the Smart Moving configuration is changed by the server 24 | move.config.chat.server.disable=Smart Moving is uitgeschakeld door de server-configuratie 25 | move.config.chat.server.update.named=Smart Moving server configuratie is ingesteld op '%s' 26 | move.config.chat.server.update.unnamed=Smart Moving server configuratie is geupdate 27 | move.config.chat.server.enable=Smart Moving is ingeschakeld door de server-configuratie 28 | 29 | # Used when the Smart Moving configuration is changed by another player 30 | move.config.chat.server.disable.user=Smart Moving uitgeschakeld door '%s' 31 | move.config.chat.server.update.named.user=Smart Moving ingesteld op '%s' door '%s' 32 | move.config.chat.server.update.unnamed.user=Smart Moving server-configuratie is geupdate door '%s' 33 | move.config.chat.server.enable.user=Smart Moving ingeschakeld door '%s' 34 | 35 | # Used when a player with no rights tries to change the Smart Moving configuration 36 | move.config.chat.server.illegal.remote=Je hebt geen toestemming in de Smart Moving configuratie op de remote-server aan te passen. 37 | move.config.chat.server.illegal.local=Je hebt geen toestemming in de Smart Moving configuratie op de locale server aan te passen. 38 | 39 | # Used when a player changes the Smart Moving configuration for himself alone 40 | move.config.chat.client.disabled=Smart Moving uitgeschakeld 41 | move.config.chat.client.enabled=Smart Moving ingeschakeld 42 | move.config.chat.client.unnamed=Smart Moving ingesteld op de knop '%s' 43 | move.config.chat.client.named=Smart Moving veranderd naar '%s' 44 | move.config.chat.client.help=(pas aan d.m.v. '%s') 45 | 46 | # Used when a player changes the Smart Moving configuration for everybody 47 | move.config.chat.client.everyone.disabled=Smart Moving uitgeschakeld voor alle spelers 48 | move.config.chat.client.everyone.enabled=Smart Moving ingeschakeld voor alle spelers 49 | move.config.chat.client.everyone.unnamed=Smart Moving veranderd naar de knop '%s' voor alle spelers 50 | move.config.chat.client.everyone.named=Smart Moving veranderd naar '%s' voor alle spelers 51 | 52 | 53 | 54 | #============================# 55 | # Speed change chat messages # 56 | #============================# 57 | 58 | # Used when the Smart Moving speed is changed by another player 59 | move.speed.chat.server.change=Smart Moving snelheid veranderd naar %s%% door '%s' 60 | move.speed.chat.server.reset=Smart Moving snelheid veranderd naar 100%% door '%s' 61 | 62 | # Used when a player with no rights tries to change the Smart Moving speed 63 | move.speed.chat.server.illegal.remote=Je hebt geen toestemming om de Smart Moving snelheid op de remote server aan te passen. 64 | move.speed.chat.server.illegal.local=Je hebt geen toestemming om de Smart Moving snelheid op de locale server aan te passen. 65 | 66 | # Used when a player changes the Smart Moving speed for himself alone 67 | move.speed.chat.client.init=Smart Moving snelheid is %s%% 68 | move.speed.chat.client.help=(verhoog de snelheid met '%s', verminder de snelheid met '%s') 69 | move.speed.chat.client.change=Smart Moving snelheid veranderd naar %s%% 70 | move.speed.chat.client.reset=Smart Moving veranderd naar 100%% 71 | 72 | # Used when a player changes the Smart Moving speed for everybody 73 | move.speed.chat.client.everyone.change=Smart Moving snelheid veranderd naar %s%% voor alle spelers 74 | move.speed.chat.client.everyone.reset=Smart Moving snelheid veranderd naar 100%% voor alle spelers -------------------------------------------------------------------------------- /src/main/resources/assets/smartmoving/lang/pt_BR.lang: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makamys/SmartMoving/4fe6a9dd080162859b3630b6a886bfe47d50f009/src/main/resources/assets/smartmoving/lang/pt_BR.lang -------------------------------------------------------------------------------- /src/main/resources/assets/smartmoving/lang/ru_RU.lang: -------------------------------------------------------------------------------- 1 | # Translated by _DarKShaM_ 2 | 3 | #===========# 4 | # Key Names # 5 | #===========# 6 | 7 | key.climb=Захват 8 | key.config.toggle=Изменение Конфигурации 9 | key.speed.increase=Увеличение Скорости 10 | key.speed.decrease=Снижение Скорости 11 | 12 | #====================================# 13 | # Configuration change chat messages # 14 | #====================================# 15 | 16 | # Используется, для объявления, какая конфигурация используется - серверная или локальная 17 | move.config.chat.server.global.unnamed=Используется серверная конфигурация Smart Moving 18 | move.config.chat.server.global.named=Используется серверная конфигурация Smart Moving '%s' 19 | move.config.chat.server.local=Используется локальная конфигурация Smart Moving 20 | 21 | # Используется, когда конфигурацию Smart Moving будет изменена сервером 22 | move.config.chat.server.disable=Smart Moving отключен настройками сервера 23 | move.config.chat.server.update.named=Конфигурация сервера Smart Moving установлена на '%s' 24 | move.config.chat.server.update.unnamed=Конфигурация сервера Smart Moving обновлена 25 | move.config.chat.server.enable=Smart Moving включен настройками сервера 26 | 27 | # Используется, когда конфигурацию Smart Moving будет изменена игроком 28 | move.config.chat.server.disable.user=Smart Moving отключен пользователем '%s' 29 | move.config.chat.server.update.named.user=Конфигурация сервера Smart Moving установлена с '%s' на '%s' 30 | move.config.chat.server.update.unnamed.user=Конфигурация сервера Smart Moving была обновлена пользователем '%s' 31 | move.config.chat.server.enable.user=Smart Moving включен пользователем '%s' 32 | 33 | # Используется, когда игрок, не обладающий необходимыми правами, пытается изменить конфигурацию Smart Moving 34 | move.config.chat.server.illegal.remote=У вас нет прав для изменения конфигурации Smart Moving на удаленном сервере. 35 | move.config.chat.server.illegal.local=У вас нет прав для изменения конфигурации Smart Moving на локальном сервере. 36 | 37 | # Используется, когда игрок меняет конфигурацию Smart Moving только для себя 38 | move.config.chat.client.disabled=Smart Moving отключен 39 | move.config.chat.client.enabled=Smart Moving включен 40 | move.config.chat.client.unnamed=Smart Moving установлен на конфигурацию '%s' 41 | move.config.chat.client.named=Smart Moving установлен на '%s' 42 | move.config.chat.client.help=(переключать при помощи '%s') 43 | 44 | # Используется, когда игрок меняет конфигурацию Smart Moving для всех 45 | move.config.chat.client.everyone.disabled=Smart Moving отключен для всех игроков 46 | move.config.chat.client.everyone.enabled=Smart Moving включен для всех игроков 47 | move.config.chat.client.everyone.unnamed=Smart Moving установлен на конфигурацию '%s' для всех игроков 48 | move.config.chat.client.everyone.named=Smart Moving установлен на '%s' для всех игроков 49 | 50 | 51 | 52 | #============================# 53 | # Speed change chat messages # 54 | #============================# 55 | 56 | # Используется, когда скорость движения для Smart Moving изменяется другим игроком 57 | move.speed.chat.server.change=Скорость движения для Smart Moving установлена на %s%% игроком '%s' 58 | move.speed.chat.server.reset=Скорость движения для Smart Moving установлена на 100%% игроком '%s' 59 | 60 | # Используется, когда игрок, не обладающий необходимыми правами, пытается изменить скорость движения для Smart Moving 61 | move.speed.chat.server.illegal.remote=У вас нет прав для изменения скорости движения Smart Moving на удаленном сервере. 62 | move.speed.chat.server.illegal.local=У вас нет прав для изменения скорости движения Smart Moving на локальном сервере. 63 | 64 | # Используется, когда игрок меняет скорость Smart Moving только для себя 65 | move.speed.chat.client.init=Скорость движения Smart Moving %s%% 66 | move.speed.chat.client.help=(Что бы увеличить скорость, нажмите '%s', для уменьшения - '%s') 67 | move.speed.chat.client.change=Скорость движения Smart Moving установлена на %s%% 68 | move.speed.chat.client.reset=Скорость движения Smart Moving установлена на 100%% 69 | 70 | # Используется, когда игрок меняет скорость Smart Moving для всех 71 | move.speed.chat.client.everyone.change=Скорость движения Smart Moving установлена на %s%% для всех игроков 72 | move.speed.chat.client.everyone.reset=Скорость движения Smart Moving установлена на 100%% для всех игроков -------------------------------------------------------------------------------- /src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | This minecraft mod, Smart Moving, including all parts herein, 2 | is licensed under the GNU General Public License Version 3 or later. 3 | 4 | Homepage: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1274224 5 | 6 | You should have received a copy of the GNU General Public License along with Smart Moving. 7 | If not, see . -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [{ 2 | "modid": "SmartMoving", 3 | "name": "Smart Moving", 4 | "version": "${modVersion}", 5 | "mcversion": "${minecraftVersion}", 6 | "description": "The Smart Moving mod provides various additional moving possibilities:\n\n * Climbing only via gaps in the walls\n * Climbing ladders with different speeds depending on ladder coverage and/or neighbour blocks\n * Alternative animations for flying and falling\n * Climbing along ceilings and up vines\n * Jumping up & back while climbing\n * Configurable sneaking\n * Alternative swimming\n * Alternative diving\n * Alternative flying\n * Faster sprinting\n * Side & Back jumps\n * Charged jumps\n * Wall jumping\n * Head jumps\n * Crawling\n * Sliding", 7 | "credits": "_DarKShaM_, Cassiobsk8, Dunncann for translations", 8 | "url": "https://github.com/makamys/SmartMoving", 9 | "authors": [ "Divisor" ], 10 | "dependencies": [ "SmartRender", "SmartCore" ] 11 | }] --------------------------------------------------------------------------------