├── .github └── workflows │ └── main.yml ├── .gitignore ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java ├── de │ └── enzaxd │ │ └── viaforge │ │ ├── ViaForge.java │ │ ├── gui │ │ └── GuiProtocolSelector.java │ │ ├── handler │ │ ├── CommonTransformer.java │ │ ├── VRDecodeHandler.java │ │ └── VREncodeHandler.java │ │ ├── loader │ │ ├── VRBackwardsLoader.java │ │ └── VRProviderLoader.java │ │ ├── platform │ │ ├── VRInjector.java │ │ ├── VRPlatform.java │ │ ├── VRViaAPI.java │ │ └── VRViaConfig.java │ │ ├── protocols │ │ └── ProtocolCollection.java │ │ └── utils │ │ ├── FutureTaskId.java │ │ └── JLoggerToLog4j.java └── dev │ └── zihasz │ └── anarchtilities │ ├── Anarchtilities.java │ ├── core │ ├── Loader.java │ ├── ModConfig.java │ └── mixin │ │ ├── MixinFontRenderer.java │ │ ├── MixinGuiConnecting.java │ │ ├── MixinGuiDisconnected.java │ │ ├── MixinGuiMainMenu.java │ │ ├── MixinGuiMultiplayer.java │ │ ├── MixinGuiPlayerTabOverlay.java │ │ ├── MixinMinecraft.java │ │ ├── MixinNetworkManagerChInit.java │ │ └── accessor │ │ └── IMinecraft.java │ ├── ui │ ├── elements │ │ └── GuiPasswordField.java │ └── thealtening │ │ └── GuiTheAltening.java │ └── utils │ ├── SessionType.java │ └── Util.java └── resources ├── anarchtilities_at.cfg ├── mcmod.info └── mixins.anarchtilities.json /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Gradle Build 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Set up JDK 8 17 | uses: actions/setup-java@v2 18 | with: 19 | java-version: '8' 20 | distribution: 'adopt' 21 | - name: Grant execute permission for gradlew 22 | run: chmod +x gradlew 23 | - name: Setup Minecraft workspace 24 | run: ./gradlew setupDecompWorkspace 25 | - name: Build with Gradle 26 | run: ./gradlew build 27 | - name: Upload artifact 28 | uses: actions/upload-artifact@v2 29 | with: 30 | name: Anarchtilities 31 | path: ./build/libs/*.* 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | # mpeltonen/sbt-idea plugin 11 | .idea_modules/ 12 | 13 | # JIRA plugin 14 | atlassian-ide-plugin.xml 15 | 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # BlueJ files 23 | *.ctxt 24 | 25 | # Package Files # 26 | *.jar 27 | *.war 28 | *.nar 29 | *.ear 30 | *.zip 31 | *.tar.gz 32 | *.rar 33 | 34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 35 | hs_err_pid* 36 | 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | # General 52 | .DS_Store 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # Windows thumbnail cache files 79 | Thumbs.db 80 | Thumbs.db:encryptable 81 | ehthumbs.db 82 | ehthumbs_vista.db 83 | 84 | # Dump file 85 | *.stackdump 86 | 87 | # Folder config file 88 | [Dd]esktop.ini 89 | 90 | # Recycle Bin used on file shares 91 | $RECYCLE.BIN/ 92 | 93 | # Windows Installer files 94 | *.cab 95 | *.msi 96 | *.msix 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | 103 | .gradle 104 | build/ 105 | 106 | # Ignore Gradle GUI config 107 | gradle-app.setting 108 | 109 | # Cache of project 110 | .gradletasknamecache 111 | 112 | **/build/ 113 | 114 | # Common working directory 115 | run/ 116 | 117 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 118 | !gradle-wrapper.jar 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Anarchtilities 2 | 3 | ## TODO 4 | 5 | * [x] Connect/Disconnect screen 6 | * [ ] TheAltening 7 | * [x] ViaForge 8 | * [x] Clans 9 | * [x] Emojis 10 | * [ ] Proxy 11 | * [ ] PingBypass 12 | * [ ] VPN 13 | * [ ] AltManager -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | maven { url = 'https://repo.spongepowered.org/maven' } 5 | } 6 | 7 | dependencies { 8 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' 9 | classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' 11 | } 12 | } 13 | 14 | apply plugin: 'java' 15 | apply plugin: 'net.minecraftforge.gradle.forge' 16 | apply plugin: 'org.spongepowered.mixin' 17 | apply plugin: 'com.github.johnrengelman.shadow' 18 | 19 | group = project.modGroup 20 | version = project.modVersion 21 | 22 | compileJava { 23 | targetCompatibility = JavaVersion.VERSION_1_8 24 | sourceCompatibility = JavaVersion.VERSION_1_8 25 | options.encoding = 'UTF-8' 26 | } 27 | 28 | minecraft { 29 | version = project.forgeVersion 30 | mappings = project.mcpVersion 31 | runDir = 'run' 32 | coreMod = 'dev.zihasz.anarchtilities.core.Loader' 33 | makeObfSourceJar = false 34 | } 35 | 36 | repositories { 37 | mavenCentral() 38 | maven { url = 'https://jitpack.io' } 39 | maven { url = 'https://repo.spongepowered.org/maven/' } 40 | maven { url = 'https://repo.viaversion.com' } 41 | } 42 | 43 | dependencies { 44 | compile('org.spongepowered:mixin:0.8.2') { 45 | exclude module: 'launchwrapper' 46 | exclude module: 'guava' 47 | exclude module: 'gson' 48 | exclude module: 'commons-io' 49 | } 50 | 51 | compile 'com.github.2b2t-Utilities:emoji-api:master-SNAPSHOT' 52 | compile 'com.github.2b2t-Utilities:2b2tclantags-api:master-SNAPSHOT' 53 | 54 | compile 'com.thealtening.auth:auth:3.0.2' 55 | compile 'com.thealtening.api:api:4.1.0' 56 | 57 | compile 'com.viaversion:viaversion:4.0.1' 58 | compile 'com.viaversion:viabackwards:4.0.1' 59 | compile 'org.yaml:snakeyaml:1.29' 60 | } 61 | 62 | processResources { 63 | inputs.property 'version', project.version 64 | inputs.property 'mcversion', project.minecraft.version 65 | 66 | from(sourceSets.main.resources.srcDirs) { 67 | include 'mcmod.info' 68 | expand 'version': project.version, 'mcversion': project.minecraft.version 69 | } 70 | 71 | from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } 72 | 73 | rename '(.+_at.cfg)', 'META-INF/$1' 74 | } 75 | 76 | shadowJar { 77 | dependencies { 78 | include('org.spongepowered:mixin') 79 | include('com.github.2b2t-Utilities:emoji-api') 80 | include('com.github.2b2t-Utilities:2b2tclantags-api') 81 | include('com.thealtening.auth:auth') 82 | include('com.thealtening.api') 83 | include('com.viaversion:viaversion') 84 | include('com.viaversion:viabackwards') 85 | include('org.yaml:snakeyaml') 86 | } 87 | exclude 'dummyThing' 88 | exclude 'LICENSE' 89 | classifier = 'release' 90 | } 91 | 92 | mixin { 93 | defaultObfuscationEnv searge 94 | add sourceSets.main, 'mixins.anarchtilities.refmap.json' 95 | } 96 | 97 | reobf { 98 | shadowJar { 99 | mappingType = 'SEARGE' 100 | classpath = sourceSets.main.compileClasspath 101 | } 102 | } 103 | 104 | jar { 105 | manifest { 106 | attributes( 107 | 'MixinConfigs': 'mixins.anarchtilities.json', 108 | 'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker', 109 | 'TweakOrder': 0, 110 | 'FMLCorePluginContainsFMLMod': 'true', 111 | 'FMLCorePlugin': 'dev.zihasz.anarchtilities.core.Loader', 112 | 'ForceLoadAsMod': 'true', 113 | 'FMLAT': 'anarchtilities_at.cfg' 114 | ) 115 | } 116 | } 117 | 118 | build.dependsOn(shadowJar) 119 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx3G 2 | org.gradle.daemon=false 3 | 4 | modGroup=dev.zihasz.anarchtilities 5 | modVersion=1.0.0 6 | mcpVersion=snapshot_20180814 7 | forgeVersion=1.12.2-14.23.5.2768 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZWareDevelopment/Anarchtilities/e0a20b6ae6708912bb29eabd02a7acf7dbede16b/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-4.10.3-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 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /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 Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Anarchtilities' 2 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/ViaForge.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge; 2 | 3 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 4 | import com.viaversion.viaversion.ViaManagerImpl; 5 | import com.viaversion.viaversion.api.Via; 6 | import com.viaversion.viaversion.api.data.MappingDataLoader; 7 | import de.enzaxd.viaforge.loader.VRBackwardsLoader; 8 | import de.enzaxd.viaforge.loader.VRProviderLoader; 9 | import de.enzaxd.viaforge.platform.VRInjector; 10 | import de.enzaxd.viaforge.platform.VRPlatform; 11 | import de.enzaxd.viaforge.utils.JLoggerToLog4j; 12 | import io.netty.channel.EventLoop; 13 | import io.netty.channel.local.LocalEventLoopGroup; 14 | import org.apache.logging.log4j.LogManager; 15 | 16 | import java.io.File; 17 | import java.util.concurrent.CompletableFuture; 18 | import java.util.concurrent.ExecutorService; 19 | import java.util.concurrent.Executors; 20 | import java.util.concurrent.ThreadFactory; 21 | import java.util.logging.Logger; 22 | 23 | public class ViaForge { 24 | 25 | public final static int SHARED_VERSION = 340; 26 | 27 | private static final ViaForge instance = new ViaForge(); 28 | 29 | public static ViaForge getInstance() { 30 | return instance; 31 | } 32 | 33 | private final Logger jLogger = new JLoggerToLog4j(LogManager.getLogger("ViaForge")); 34 | private final CompletableFuture initFuture = new CompletableFuture<>(); 35 | 36 | private ExecutorService asyncExecutor; 37 | private EventLoop eventLoop; 38 | 39 | private File file; 40 | private int version; 41 | private String lastServer; 42 | 43 | public void start() { 44 | ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaForge-%d").build(); 45 | asyncExecutor = Executors.newFixedThreadPool(8, factory); 46 | 47 | eventLoop = new LocalEventLoopGroup(1, factory).next(); 48 | eventLoop.submit(initFuture::join); 49 | 50 | setVersion(SHARED_VERSION); 51 | this.file = new File("ViaForge"); 52 | if (this.file.mkdir()) 53 | this.getjLogger().info("Creating ViaForge Folder"); 54 | 55 | Via.init( 56 | ViaManagerImpl.builder() 57 | .injector(new VRInjector()) 58 | .loader(new VRProviderLoader()) 59 | .platform(new VRPlatform(file)) 60 | .build() 61 | ); 62 | 63 | MappingDataLoader.enableMappingsCache(); 64 | ((ViaManagerImpl) Via.getManager()).init(); 65 | 66 | new VRBackwardsLoader(file); 67 | 68 | initFuture.complete(null); 69 | } 70 | 71 | public Logger getjLogger() { 72 | return jLogger; 73 | } 74 | 75 | public CompletableFuture getInitFuture() { 76 | return initFuture; 77 | } 78 | 79 | public ExecutorService getAsyncExecutor() { 80 | return asyncExecutor; 81 | } 82 | 83 | public EventLoop getEventLoop() { 84 | return eventLoop; 85 | } 86 | 87 | public File getFile() { 88 | return file; 89 | } 90 | 91 | public String getLastServer() { 92 | return lastServer; 93 | } 94 | 95 | public int getVersion() { 96 | return version; 97 | } 98 | public void setVersion(int version) { 99 | this.version = version; 100 | } 101 | 102 | public void setFile(File file) { 103 | this.file = file; 104 | } 105 | 106 | public void setLastServer(String lastServer) { 107 | this.lastServer = lastServer; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/gui/GuiProtocolSelector.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.gui; 2 | 3 | import com.mojang.realmsclient.gui.ChatFormatting; 4 | import de.enzaxd.viaforge.ViaForge; 5 | import de.enzaxd.viaforge.protocols.ProtocolCollection; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.GuiButton; 8 | import net.minecraft.client.gui.GuiScreen; 9 | import net.minecraft.client.gui.GuiSlot; 10 | import org.lwjgl.opengl.GL11; 11 | 12 | import java.io.IOException; 13 | 14 | public class GuiProtocolSelector extends GuiScreen { 15 | 16 | public SlotList list; 17 | 18 | private GuiScreen parent; 19 | 20 | public GuiProtocolSelector(GuiScreen parent) { 21 | this.parent = parent; 22 | } 23 | 24 | @Override 25 | public void initGui() { 26 | super.initGui(); 27 | buttonList.add(new GuiButton(1, width / 2 - 100, height - 27, 200, 28 | 20, "Back")); 29 | 30 | list = new SlotList(mc, width, height, 32, height - 32, 10); 31 | } 32 | 33 | @Override 34 | protected void actionPerformed(GuiButton p_actionPerformed_1_) throws IOException { 35 | list.actionPerformed(p_actionPerformed_1_); 36 | 37 | if (p_actionPerformed_1_.id == 1) 38 | mc.displayGuiScreen(parent); 39 | } 40 | 41 | @Override 42 | public void handleMouseInput() throws IOException { 43 | list.handleMouseInput(); 44 | super.handleMouseInput(); 45 | } 46 | 47 | @Override 48 | public void drawScreen(int p_drawScreen_1_, int p_drawScreen_2_, float p_drawScreen_3_) { 49 | list.drawScreen(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_); 50 | 51 | GL11.glPushMatrix(); 52 | GL11.glScalef(2.0F, 2.0F, 2.0F); 53 | this.drawCenteredString(this.fontRenderer, ChatFormatting.GOLD.toString() + "ViaForge", 54 | this.width / 4, 6, 16777215); 55 | GL11.glPopMatrix(); 56 | 57 | drawString(this.fontRenderer, "by EnZaXD/Flori2007", 1, 1, -1); 58 | drawString(this.fontRenderer, "Discord: EnZaXD#6257", 1, 11, -1); 59 | 60 | super.drawScreen(p_drawScreen_1_, p_drawScreen_2_, p_drawScreen_3_); 61 | } 62 | 63 | class SlotList extends GuiSlot { 64 | 65 | 66 | public SlotList(Minecraft p_i1052_1_, int p_i1052_2_, int p_i1052_3_, int p_i1052_4_, int p_i1052_5_, int p_i1052_6_) { 67 | super(p_i1052_1_, p_i1052_2_, p_i1052_3_, p_i1052_4_, p_i1052_5_, p_i1052_6_); 68 | } 69 | 70 | @Override 71 | protected int getSize() { 72 | return ProtocolCollection.values().length; 73 | } 74 | 75 | @Override 76 | protected void elementClicked(int i, boolean b, int i1, int i2) { 77 | ViaForge.getInstance().setVersion(ProtocolCollection.values()[i].getVersion().getVersion()); 78 | } 79 | 80 | @Override 81 | protected boolean isSelected(int i) { 82 | return false; 83 | } 84 | 85 | @Override 86 | protected void drawBackground() { 87 | drawDefaultBackground(); 88 | } 89 | 90 | @Override 91 | protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) { 92 | drawCenteredString(mc.fontRenderer,(ViaForge.getInstance().getVersion() == 93 | ProtocolCollection.values()[i].getVersion().getVersion() ? ChatFormatting.GREEN.toString() : 94 | ChatFormatting.DARK_RED.toString()) + ProtocolCollection.getProtocolById( 95 | ProtocolCollection.values()[i].getVersion().getVersion()).getName(), 96 | width / 2, i2 + 2, -1); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/handler/CommonTransformer.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.handler; 2 | 3 | import com.viaversion.viaversion.util.PipelineUtil; 4 | import io.netty.buffer.ByteBuf; 5 | import io.netty.channel.ChannelHandler; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.ByteToMessageDecoder; 8 | import io.netty.handler.codec.MessageToByteEncoder; 9 | import io.netty.handler.codec.MessageToMessageDecoder; 10 | 11 | import java.lang.reflect.InvocationTargetException; 12 | 13 | public class CommonTransformer { 14 | public static final String HANDLER_DECODER_NAME = "via-decoder"; 15 | public static final String HANDLER_ENCODER_NAME = "via-encoder"; 16 | 17 | public static void decompress(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException { 18 | ChannelHandler handler = ctx.pipeline().get("decompress"); 19 | ByteBuf decompressed = handler instanceof MessageToMessageDecoder 20 | ? (ByteBuf) PipelineUtil.callDecode((MessageToMessageDecoder) handler, ctx, buf).get(0) 21 | : (ByteBuf) PipelineUtil.callDecode((ByteToMessageDecoder) handler, ctx, buf).get(0); 22 | try { 23 | buf.clear().writeBytes(decompressed); 24 | } finally { 25 | decompressed.release(); 26 | } 27 | } 28 | 29 | public static void compress(ChannelHandlerContext ctx, ByteBuf buf) throws Exception { 30 | ByteBuf compressed = ctx.alloc().buffer(); 31 | try { 32 | PipelineUtil.callEncode((MessageToByteEncoder) ctx.pipeline().get("compress"), ctx, buf, compressed); 33 | buf.clear().writeBytes(compressed); 34 | } finally { 35 | compressed.release(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/handler/VRDecodeHandler.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.handler; 2 | 3 | import com.viaversion.viaversion.api.connection.UserConnection; 4 | import com.viaversion.viaversion.exception.CancelCodecException; 5 | import com.viaversion.viaversion.exception.CancelDecoderException; 6 | import com.viaversion.viaversion.util.PipelineUtil; 7 | import io.netty.buffer.ByteBuf; 8 | import io.netty.channel.ChannelHandler; 9 | import io.netty.channel.ChannelHandlerContext; 10 | import io.netty.handler.codec.MessageToMessageDecoder; 11 | 12 | import java.lang.reflect.InvocationTargetException; 13 | import java.util.List; 14 | 15 | @ChannelHandler.Sharable 16 | public class VRDecodeHandler extends MessageToMessageDecoder { 17 | private final UserConnection info; 18 | private boolean handledCompression; 19 | private boolean skipDoubleTransform; 20 | 21 | public VRDecodeHandler(UserConnection info) { 22 | this.info = info; 23 | } 24 | 25 | public UserConnection getInfo() { 26 | return info; 27 | } 28 | 29 | // https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java 30 | @Override 31 | protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { 32 | if (skipDoubleTransform) { 33 | skipDoubleTransform = false; 34 | out.add(bytebuf.retain()); 35 | return; 36 | } 37 | 38 | if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null); 39 | if (!info.shouldTransformPacket()) { 40 | out.add(bytebuf.retain()); 41 | return; 42 | } 43 | 44 | ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); 45 | try { 46 | boolean needsCompress = handleCompressionOrder(ctx, transformedBuf); 47 | 48 | info.transformIncoming(transformedBuf, CancelDecoderException::generate); 49 | 50 | if (needsCompress) { 51 | CommonTransformer.compress(ctx, transformedBuf); 52 | skipDoubleTransform = true; 53 | } 54 | out.add(transformedBuf.retain()); 55 | } finally { 56 | transformedBuf.release(); 57 | } 58 | } 59 | 60 | private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException { 61 | if (handledCompression) return false; 62 | 63 | int decoderIndex = ctx.pipeline().names().indexOf("decompress"); 64 | if (decoderIndex == -1) return false; 65 | handledCompression = true; 66 | if (decoderIndex > ctx.pipeline().names().indexOf("via-decoder")) { 67 | // Need to decompress this packet due to bad order 68 | CommonTransformer.decompress(ctx, buf); 69 | ChannelHandler encoder = ctx.pipeline().get("via-encoder"); 70 | ChannelHandler decoder = ctx.pipeline().get("via-decoder"); 71 | ctx.pipeline().remove(encoder); 72 | ctx.pipeline().remove(decoder); 73 | ctx.pipeline().addAfter("compress", "via-encoder", encoder); 74 | ctx.pipeline().addAfter("decompress", "via-decoder", decoder); 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | @Override 81 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 82 | if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; 83 | super.exceptionCaught(ctx, cause); 84 | } 85 | } -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/handler/VREncodeHandler.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.handler; 2 | 3 | import com.viaversion.viaversion.api.connection.UserConnection; 4 | import com.viaversion.viaversion.exception.CancelCodecException; 5 | import com.viaversion.viaversion.exception.CancelEncoderException; 6 | import com.viaversion.viaversion.util.PipelineUtil; 7 | import io.netty.buffer.ByteBuf; 8 | import io.netty.channel.ChannelHandler; 9 | import io.netty.channel.ChannelHandlerContext; 10 | import io.netty.handler.codec.MessageToMessageEncoder; 11 | 12 | import java.lang.reflect.InvocationTargetException; 13 | import java.util.List; 14 | 15 | @ChannelHandler.Sharable 16 | public class VREncodeHandler extends MessageToMessageEncoder { 17 | private final UserConnection info; 18 | private boolean handledCompression; 19 | 20 | public VREncodeHandler(UserConnection info) { 21 | this.info = info; 22 | } 23 | 24 | @Override 25 | protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { 26 | if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null); 27 | if (!info.shouldTransformPacket()) { 28 | out.add(bytebuf.retain()); 29 | return; 30 | } 31 | 32 | ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); 33 | try { 34 | boolean needsCompress = handleCompressionOrder(ctx, transformedBuf); 35 | 36 | info.transformOutgoing(transformedBuf, CancelEncoderException::generate); 37 | 38 | if (needsCompress) { 39 | CommonTransformer.compress(ctx, transformedBuf); 40 | } 41 | out.add(transformedBuf.retain()); 42 | } finally { 43 | transformedBuf.release(); 44 | } 45 | } 46 | 47 | private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException { 48 | if (handledCompression) return false; 49 | 50 | int encoderIndex = ctx.pipeline().names().indexOf("compress"); 51 | if (encoderIndex == -1) return false; 52 | handledCompression = true; 53 | if (encoderIndex > ctx.pipeline().names().indexOf("via-encoder")) { 54 | // Need to decompress this packet due to bad order 55 | CommonTransformer.decompress(ctx, buf); 56 | ChannelHandler encoder = ctx.pipeline().get("via-encoder"); 57 | ChannelHandler decoder = ctx.pipeline().get("via-decoder"); 58 | ctx.pipeline().remove(encoder); 59 | ctx.pipeline().remove(decoder); 60 | ctx.pipeline().addAfter("compress", "via-encoder", encoder); 61 | ctx.pipeline().addAfter("decompress", "via-decoder", decoder); 62 | return true; 63 | } 64 | return false; 65 | } 66 | 67 | @Override 68 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { 69 | if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return; 70 | super.exceptionCaught(ctx, cause); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/loader/VRBackwardsLoader.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.loader; 2 | 3 | import com.viaversion.viabackwards.api.ViaBackwardsPlatform; 4 | import de.enzaxd.viaforge.ViaForge; 5 | 6 | import java.io.File; 7 | import java.util.logging.Logger; 8 | 9 | public class VRBackwardsLoader implements ViaBackwardsPlatform { 10 | private final File file; 11 | 12 | public VRBackwardsLoader(final File file) { 13 | this.init(this.file = new File(file, "ViaBackwards")); 14 | } 15 | 16 | @Override 17 | public Logger getLogger() { 18 | return ViaForge.getInstance().getjLogger(); 19 | } 20 | 21 | @Override 22 | public void disable() { 23 | } 24 | 25 | @Override 26 | public boolean isOutdated() { 27 | return false; 28 | } 29 | 30 | @Override 31 | public File getDataFolder() { 32 | return new File(this.file, "config.yml"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/loader/VRProviderLoader.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.loader; 2 | 3 | import com.viaversion.viaversion.api.Via; 4 | import com.viaversion.viaversion.api.connection.UserConnection; 5 | import com.viaversion.viaversion.api.platform.ViaPlatformLoader; 6 | import com.viaversion.viaversion.api.protocol.version.VersionProvider; 7 | import com.viaversion.viaversion.bungee.providers.BungeeMovementTransmitter; 8 | import com.viaversion.viaversion.protocols.base.BaseVersionProvider; 9 | import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; 10 | import de.enzaxd.viaforge.ViaForge; 11 | 12 | public class VRProviderLoader implements ViaPlatformLoader { 13 | 14 | @Override 15 | public void load() { 16 | Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); 17 | Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() { 18 | @Override 19 | public int getClosestServerProtocol(UserConnection connection) throws Exception { 20 | if (connection.isClientSide()) 21 | return ViaForge.getInstance().getVersion(); 22 | return super.getClosestServerProtocol(connection); 23 | } 24 | }); 25 | } 26 | 27 | @Override 28 | public void unload() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/platform/VRInjector.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.platform; 2 | 3 | import com.viaversion.viaversion.api.platform.ViaInjector; 4 | import com.viaversion.viaversion.libs.gson.JsonObject; 5 | import de.enzaxd.viaforge.ViaForge; 6 | import de.enzaxd.viaforge.handler.CommonTransformer; 7 | 8 | public class VRInjector implements ViaInjector { 9 | 10 | @Override 11 | public void inject() { 12 | } 13 | 14 | @Override 15 | public void uninject() { 16 | } 17 | 18 | @Override 19 | public int getServerProtocolVersion() { 20 | return ViaForge.SHARED_VERSION; 21 | } 22 | 23 | @Override 24 | public String getEncoderName() { 25 | return CommonTransformer.HANDLER_ENCODER_NAME; 26 | } 27 | 28 | @Override 29 | public String getDecoderName() { 30 | return CommonTransformer.HANDLER_DECODER_NAME; 31 | } 32 | 33 | @Override 34 | public JsonObject getDump() { 35 | JsonObject obj = new JsonObject(); 36 | return obj; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/platform/VRPlatform.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.platform; 2 | 3 | import com.viaversion.viaversion.api.ViaAPI; 4 | import com.viaversion.viaversion.api.command.ViaCommandSender; 5 | import com.viaversion.viaversion.api.configuration.ConfigurationProvider; 6 | import com.viaversion.viaversion.api.configuration.ViaVersionConfig; 7 | import com.viaversion.viaversion.api.platform.PlatformTask; 8 | import com.viaversion.viaversion.api.platform.ViaPlatform; 9 | import com.viaversion.viaversion.libs.gson.JsonObject; 10 | import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 11 | import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 12 | import de.enzaxd.viaforge.ViaForge; 13 | import de.enzaxd.viaforge.utils.FutureTaskId; 14 | import de.enzaxd.viaforge.utils.JLoggerToLog4j; 15 | import io.netty.util.concurrent.Future; 16 | import io.netty.util.concurrent.GenericFutureListener; 17 | import org.apache.logging.log4j.LogManager; 18 | 19 | import java.io.File; 20 | import java.nio.file.Path; 21 | import java.util.UUID; 22 | import java.util.concurrent.CancellationException; 23 | import java.util.concurrent.CompletableFuture; 24 | import java.util.concurrent.TimeUnit; 25 | import java.util.logging.Logger; 26 | 27 | public class VRPlatform implements ViaPlatform { 28 | 29 | private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion")); 30 | 31 | private final VRViaConfig config; 32 | private final File dataFolder; 33 | private final ViaAPI api; 34 | 35 | public VRPlatform(File dataFolder) { 36 | Path configDir = dataFolder.toPath().resolve("ViaVersion"); 37 | config = new VRViaConfig(configDir.resolve("viaversion.yml").toFile()); 38 | this.dataFolder = configDir.toFile(); 39 | api = new VRViaAPI(); 40 | } 41 | 42 | public static String legacyToJson(String legacy) { 43 | return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy)); 44 | } 45 | 46 | @Override 47 | public Logger getLogger() { 48 | return logger; 49 | } 50 | 51 | @Override 52 | public String getPlatformName() { 53 | return "ViaForge"; 54 | } 55 | 56 | @Override 57 | public String getPlatformVersion() { 58 | return ViaForge.SHARED_VERSION+""; 59 | } 60 | 61 | @Override 62 | public String getPluginVersion() { 63 | return "4.0.0"; 64 | } 65 | 66 | @Override 67 | public FutureTaskId runAsync(Runnable runnable) { 68 | return new FutureTaskId(CompletableFuture 69 | .runAsync(runnable, ViaForge.getInstance().getAsyncExecutor()) 70 | .exceptionally(throwable -> { 71 | if (!(throwable instanceof CancellationException)) { 72 | throwable.printStackTrace(); 73 | } 74 | return null; 75 | }) 76 | ); 77 | } 78 | 79 | @Override 80 | public FutureTaskId runSync(Runnable runnable) { 81 | return new FutureTaskId(ViaForge.getInstance().getEventLoop().submit(runnable).addListener(errorLogger())); 82 | } 83 | 84 | @Override 85 | public PlatformTask runSync(Runnable runnable, long ticks) { 86 | return new FutureTaskId(ViaForge.getInstance().getEventLoop().schedule(() -> runSync(runnable), ticks * 87 | 50, TimeUnit.MILLISECONDS).addListener(errorLogger())); 88 | } 89 | 90 | @Override 91 | public PlatformTask runRepeatingSync(Runnable runnable, long ticks) { 92 | return new FutureTaskId(ViaForge.getInstance().getEventLoop().scheduleAtFixedRate(() -> runSync(runnable), 93 | 0, ticks * 50, TimeUnit.MILLISECONDS).addListener(errorLogger())); 94 | } 95 | 96 | private > GenericFutureListener errorLogger() { 97 | return future -> { 98 | if (!future.isCancelled() && future.cause() != null) { 99 | future.cause().printStackTrace(); 100 | } 101 | }; 102 | } 103 | 104 | @Override 105 | public ViaCommandSender[] getOnlinePlayers() { 106 | return new ViaCommandSender[1337]; 107 | } 108 | 109 | private ViaCommandSender[] getServerPlayers() { 110 | return new ViaCommandSender[1337]; 111 | } 112 | 113 | @Override 114 | public void sendMessage(UUID uuid, String s) { 115 | } 116 | 117 | @Override 118 | public boolean kickPlayer(UUID uuid, String s) { 119 | return false; 120 | } 121 | 122 | @Override 123 | public boolean isPluginEnabled() { 124 | return true; 125 | } 126 | 127 | @Override 128 | public ViaAPI getApi() { 129 | return api; 130 | } 131 | 132 | @Override 133 | public ViaVersionConfig getConf() { 134 | return config; 135 | } 136 | 137 | @Override 138 | public ConfigurationProvider getConfigurationProvider() { 139 | return config; 140 | } 141 | 142 | @Override 143 | public File getDataFolder() { 144 | return dataFolder; 145 | } 146 | 147 | @Override 148 | public void onReload() { 149 | } 150 | 151 | @Override 152 | public JsonObject getDump() { 153 | JsonObject platformSpecific = new JsonObject(); 154 | return platformSpecific; 155 | } 156 | 157 | @Override 158 | public boolean isOldClientsAllowed() { 159 | return true; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/platform/VRViaAPI.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.platform; 2 | 3 | import com.viaversion.viaversion.ViaAPIBase; 4 | 5 | import java.util.UUID; 6 | 7 | public class VRViaAPI extends ViaAPIBase { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/platform/VRViaConfig.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.platform; 2 | 3 | import com.viaversion.viaversion.configuration.AbstractViaConfig; 4 | 5 | import java.io.File; 6 | import java.net.URL; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class VRViaConfig extends AbstractViaConfig { 12 | // Based on Sponge ViaVersion 13 | private static List UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", 14 | "bungee-ping-save", "bungee-servers", "quick-move-action-fix", "nms-player-ticking", 15 | "velocity-ping-interval", "velocity-ping-save", "velocity-servers", 16 | "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); 17 | 18 | public VRViaConfig(File configFile) { 19 | super(configFile); 20 | // Load config 21 | reloadConfig(); 22 | } 23 | 24 | @Override 25 | public URL getDefaultConfigURL() { 26 | return getClass().getClassLoader().getResource("assets/viaversion/config.yml"); 27 | } 28 | 29 | @Override 30 | protected void handleConfig(Map config) { 31 | // Nothing Currently 32 | } 33 | 34 | @Override 35 | public List getUnsupportedOptions() { 36 | return UNSUPPORTED; 37 | } 38 | 39 | @Override 40 | public boolean isAntiXRay() { 41 | return false; 42 | } 43 | 44 | @Override 45 | public boolean isNMSPlayerTicking() { 46 | return false; 47 | } 48 | 49 | @Override 50 | public boolean is1_12QuickMoveActionFix() { 51 | return false; 52 | } 53 | 54 | @Override 55 | public String getBlockConnectionMethod() { 56 | return "packet"; 57 | } 58 | 59 | @Override 60 | public boolean is1_9HitboxFix() { 61 | return false; 62 | } 63 | 64 | @Override 65 | public boolean is1_14HitboxFix() { 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/protocols/ProtocolCollection.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.protocols; 2 | 3 | import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; 4 | 5 | public enum ProtocolCollection { 6 | 7 | R1_17_1(new ProtocolVersion(756, "1.17.1")), 8 | R1_17(new ProtocolVersion(755, "1.17")), 9 | 10 | R1_16_5(new ProtocolVersion(754, "1.16.4-1.16.5")), 11 | R1_16_3(new ProtocolVersion(753, "1.16.3")), 12 | R1_16_2(new ProtocolVersion(751, "1.16.2")), 13 | R1_16_1(new ProtocolVersion(736, "1.16.1")), 14 | R1_16(new ProtocolVersion(735, "1.16")), 15 | 16 | R1_15_2(new ProtocolVersion(578, "1.15.2")), 17 | R1_15_1(new ProtocolVersion(575, "1.15.1")), 18 | R1_15(new ProtocolVersion(573, "1.15")), 19 | 20 | R1_14_4(new ProtocolVersion(498, "1.14.4")), 21 | R1_14_3(new ProtocolVersion(490, "1.14.3")), 22 | R1_14_2(new ProtocolVersion(485, "1.14.2")), 23 | R1_14_1(new ProtocolVersion(480, "1.14.1")), 24 | R1_14(new ProtocolVersion(477, "1.14")), 25 | 26 | R1_13_2(new ProtocolVersion(404, "1.13.2")), 27 | R1_13_1(new ProtocolVersion(401, "1.13.1")), 28 | R1_13(new ProtocolVersion(393, "1.13")), 29 | 30 | R1_12_2(new ProtocolVersion(340, "1.12.2")), 31 | R1_12_1(new ProtocolVersion(338, "1.12.1")), 32 | R1_12(new ProtocolVersion(335, "1.12")), 33 | 34 | R1_11_1(new ProtocolVersion(316, "1.11.1-1.11.2")), 35 | R1_11(new ProtocolVersion(315, "1.11")), 36 | 37 | R1_10(new ProtocolVersion(210, "1.10.x")), 38 | 39 | R1_9_4(new ProtocolVersion(110, "1.9.3-1.9.4")), 40 | R1_9_2(new ProtocolVersion(109, "1.9.2")), 41 | R1_9_1(new ProtocolVersion(108, "1.9.1")), 42 | R1_9(new ProtocolVersion(107, "1.9")), 43 | 44 | R1_8(new ProtocolVersion(47, "1.8.x")); 45 | 46 | private ProtocolVersion version; 47 | 48 | private ProtocolCollection(ProtocolVersion version) { 49 | this.version = version; 50 | } 51 | 52 | public ProtocolVersion getVersion() { 53 | return version; 54 | } 55 | 56 | public static ProtocolVersion getProtocolById(int id) { 57 | for (ProtocolCollection coll : values()) 58 | if (coll.getVersion().getVersion() == id) 59 | return coll.getVersion(); 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/utils/FutureTaskId.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.utils; 2 | 3 | import com.viaversion.viaversion.api.platform.PlatformTask; 4 | 5 | import java.util.concurrent.Future; 6 | 7 | public class FutureTaskId implements PlatformTask> { 8 | private final Future object; 9 | 10 | public FutureTaskId(Future object) { 11 | this.object = object; 12 | } 13 | 14 | @Override 15 | public Future getObject() { 16 | return object; 17 | } 18 | 19 | @Override 20 | public void cancel() { 21 | object.cancel(false); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/enzaxd/viaforge/utils/JLoggerToLog4j.java: -------------------------------------------------------------------------------- 1 | package de.enzaxd.viaforge.utils; 2 | 3 | import java.text.MessageFormat; 4 | import java.util.logging.Level; 5 | import java.util.logging.LogRecord; 6 | import java.util.logging.Logger; 7 | 8 | public class JLoggerToLog4j extends Logger { 9 | private final org.apache.logging.log4j.Logger base; 10 | 11 | public JLoggerToLog4j(org.apache.logging.log4j.Logger logger) { 12 | super("logger", null); 13 | this.base = logger; 14 | } 15 | 16 | public void log(LogRecord record) { 17 | this.log(record.getLevel(), record.getMessage()); 18 | } 19 | 20 | public void log(Level level, String msg) { 21 | if (level == Level.FINE) { 22 | this.base.debug(msg); 23 | } else if (level == Level.WARNING) { 24 | this.base.warn(msg); 25 | } else if (level == Level.SEVERE) { 26 | this.base.error(msg); 27 | } else if (level == Level.INFO) { 28 | this.base.info(msg); 29 | } else { 30 | this.base.trace(msg); 31 | } 32 | 33 | } 34 | 35 | public void log(Level level, String msg, Object param1) { 36 | if (level == Level.FINE) { 37 | this.base.debug(msg, param1); 38 | } else if (level == Level.WARNING) { 39 | this.base.warn(msg, param1); 40 | } else if (level == Level.SEVERE) { 41 | this.base.error(msg, param1); 42 | } else if (level == Level.INFO) { 43 | this.base.info(msg, param1); 44 | } else { 45 | this.base.trace(msg, param1); 46 | } 47 | 48 | } 49 | 50 | public void log(Level level, String msg, Object[] params) { 51 | log(level, MessageFormat.format(msg, params)); 52 | } 53 | 54 | public void log(Level level, String msg, Throwable params) { 55 | if (level == Level.FINE) { 56 | this.base.debug(msg, params); 57 | } else if (level == Level.WARNING) { 58 | this.base.warn(msg, params); 59 | } else if (level == Level.SEVERE) { 60 | this.base.error(msg, params); 61 | } else if (level == Level.INFO) { 62 | this.base.info(msg, params); 63 | } else { 64 | this.base.trace(msg, params); 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/Anarchtilities.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities; 2 | 3 | import dev.tigr.clantags.api.ClanTags; 4 | import dev.tigr.emojiapi.Emojis; 5 | import net.minecraftforge.client.ClientCommandHandler; 6 | import net.minecraftforge.client.event.ClientChatEvent; 7 | import net.minecraftforge.client.event.ClientChatReceivedEvent; 8 | import net.minecraftforge.common.MinecraftForge; 9 | import net.minecraftforge.fml.common.Mod; 10 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 11 | import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 12 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 13 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 14 | 15 | import java.lang.reflect.Field; 16 | import java.lang.reflect.InvocationTargetException; 17 | import java.lang.reflect.Method; 18 | 19 | @Mod( 20 | modid = Anarchtilities.MOD_ID, 21 | name = Anarchtilities.MOD_NAME, 22 | version = Anarchtilities.VERSION, 23 | clientSideOnly = true, 24 | useMetadata = true, 25 | updateJSON = "https://anarchtilities.zihasz.dev/update/update.json" 26 | ) 27 | public class Anarchtilities { 28 | 29 | public static final String MOD_ID = "anarchtilities"; 30 | public static final String MOD_NAME = "Anarchtilities"; 31 | public static final String VERSION = "1.0.0"; 32 | 33 | @Mod.Instance(MOD_ID) 34 | public static Anarchtilities INSTANCE; 35 | 36 | @Mod.EventHandler 37 | public void preInit(FMLPreInitializationEvent event) { 38 | 39 | } 40 | 41 | @Mod.EventHandler 42 | public void init(FMLInitializationEvent event) { 43 | MinecraftForge.EVENT_BUS.register(this); 44 | 45 | try { 46 | Method method = Emojis.class.getDeclaredMethod("load"); 47 | method.setAccessible(true); 48 | method.invoke(null); 49 | } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { 50 | e.printStackTrace(); 51 | } 52 | 53 | ClanTags.load(); 54 | ClanTags.PREFIX = "/"; 55 | ClientCommandHandler.instance.registerCommand(ClanTags.INFO_COMMAND); 56 | ClientCommandHandler.instance.registerCommand(ClanTags.CLANS_COMMAND); 57 | 58 | } 59 | 60 | 61 | @Mod.EventHandler 62 | public void postInit(FMLPostInitializationEvent event) { 63 | 64 | } 65 | 66 | @SubscribeEvent 67 | public void onChatMessage(ClientChatReceivedEvent event) { 68 | ClanTags.handleClientChatReceivedEvent(event); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/Loader.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core; 2 | 3 | import dev.zihasz.anarchtilities.Anarchtilities; 4 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 5 | import org.spongepowered.asm.launch.MixinBootstrap; 6 | import org.spongepowered.asm.mixin.Mixins; 7 | 8 | import javax.annotation.Nullable; 9 | import java.util.Map; 10 | 11 | @IFMLLoadingPlugin.Name(Anarchtilities.MOD_ID) 12 | @IFMLLoadingPlugin.MCVersion("1.12.2") 13 | public class Loader implements IFMLLoadingPlugin { 14 | 15 | public Loader() { 16 | MixinBootstrap.init(); // Init mixins 17 | Mixins.addConfiguration("mixins.anarchtilities.json"); // Add our own mixins 18 | } 19 | 20 | @Override 21 | public String[] getASMTransformerClass() { 22 | return new String[0]; 23 | } 24 | 25 | @Override 26 | public String getModContainerClass() { 27 | return null; 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public String getSetupClass() { 33 | return null; 34 | } 35 | 36 | @Override 37 | public void injectData(Map data) { 38 | 39 | } 40 | 41 | @Override 42 | public String getAccessTransformerClass() { 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/ModConfig.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core; 2 | 3 | import dev.zihasz.anarchtilities.Anarchtilities; 4 | import net.minecraftforge.common.config.Config; 5 | 6 | @Config(modid = Anarchtilities.MOD_ID) 7 | public class ModConfig { 8 | 9 | @Config.Name("Name Protect") 10 | public static boolean name_protect = false; 11 | 12 | @Config.Name("Fake Name") 13 | @Config.Comment("The name for Name Protect") 14 | public static String name_protect_fake_name = ""; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinFontRenderer.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import dev.tigr.emojiapi.Emoji; 4 | import dev.tigr.emojiapi.Emojis; 5 | import dev.zihasz.anarchtilities.core.ModConfig; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.FontRenderer; 8 | import net.minecraft.client.gui.Gui; 9 | import net.minecraft.client.renderer.GlStateManager; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Overwrite; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.Locale; 21 | import java.util.Random; 22 | 23 | @Mixin(FontRenderer.class) 24 | public abstract class MixinFontRenderer { 25 | 26 | @Shadow public Random fontRandom; 27 | @Shadow protected float posX; 28 | @Shadow protected float posY; 29 | @Shadow private boolean randomStyle; 30 | @Shadow private boolean boldStyle; 31 | @Shadow private boolean strikethroughStyle; 32 | @Shadow private boolean underlineStyle; 33 | @Shadow private boolean italicStyle; 34 | @Shadow private boolean unicodeFlag; 35 | @Shadow private int textColor; 36 | @Shadow private float red; 37 | @Shadow private float green; 38 | @Shadow private float blue; 39 | @Shadow private float alpha; 40 | @Final @Shadow private int[] colorCode; 41 | 42 | @Shadow protected abstract void setColor(float r, float g, float b, float a); 43 | @Shadow public abstract int getCharWidth(char character); 44 | @Shadow protected abstract float renderChar(char ch, boolean italic); 45 | @Shadow protected abstract void doDraw(float f); 46 | 47 | @Inject(method = "renderStringAtPos(Ljava/lang/String;Z)V", at = @At("HEAD")) 48 | private void renderString(String text, boolean shadow, CallbackInfo ci) { 49 | if (ModConfig.name_protect) 50 | text.replace(Minecraft.getMinecraft().getSession().getUsername(), ModConfig.name_protect_fake_name); 51 | } 52 | 53 | /** 54 | * @author Tigermouthbear 55 | */ 56 | @Overwrite 57 | private void renderStringAtPos(String text, boolean shadow) { 58 | int size = getStringWidth(" "); 59 | List emojis = new ArrayList<>(); 60 | 61 | for (String possile : text.split(":")) { 62 | if (Emojis.isEmoji(possile)) emojis.add(new Emoji(possile)); 63 | } 64 | 65 | for (Emoji emoji : emojis) { 66 | if (!shadow) { 67 | int index = text.indexOf(":" + emoji.getName() + ":"); 68 | if (index == -1) continue; 69 | int x = getStringWidth(text.substring(0, index)); 70 | 71 | Minecraft.getMinecraft().getTextureManager().bindTexture(Emojis.getEmoji(emoji)); 72 | GlStateManager.color(1, 1, 1, alpha); 73 | Gui.drawScaledCustomSizeModalRect((int) (posX + x), (int) posY, 0, 0, size, size, size, size, size, size); 74 | } 75 | 76 | text = text.replaceFirst(":" + emoji.getName() + ":", " "); 77 | } 78 | 79 | for (int i = 0; i < text.length(); ++i) { 80 | char c0 = text.charAt(i); 81 | 82 | if (c0 == 167 && i + 1 < text.length()) { 83 | int i1 = "0123456789abcdefklmnor".indexOf(String.valueOf(text.charAt(i + 1)).toLowerCase(Locale.ROOT).charAt(0)); 84 | 85 | if (i1 < 16) { 86 | this.randomStyle = false; 87 | this.boldStyle = false; 88 | this.strikethroughStyle = false; 89 | this.underlineStyle = false; 90 | this.italicStyle = false; 91 | 92 | if (i1 < 0) { 93 | i1 = 15; 94 | } 95 | 96 | if (shadow) { 97 | i1 += 16; 98 | } 99 | 100 | int j1 = this.colorCode[i1]; 101 | this.textColor = j1; 102 | setColor((float) (j1 >> 16) / 255.0F, (float) (j1 >> 8 & 255) / 255.0F, (float) (j1 & 255) / 255.0F, this.alpha); 103 | } else if (i1 == 16) { 104 | this.randomStyle = true; 105 | } else if (i1 == 17) { 106 | this.boldStyle = true; 107 | } else if (i1 == 18) { 108 | this.strikethroughStyle = true; 109 | } else if (i1 == 19) { 110 | this.underlineStyle = true; 111 | } else if (i1 == 20) { 112 | this.italicStyle = true; 113 | } else { 114 | this.randomStyle = false; 115 | this.boldStyle = false; 116 | this.strikethroughStyle = false; 117 | this.underlineStyle = false; 118 | this.italicStyle = false; 119 | setColor(this.red, this.blue, this.green, this.alpha); 120 | } 121 | 122 | ++i; 123 | } else { 124 | int j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); 125 | 126 | if (this.randomStyle && j != -1) { 127 | int k = this.getCharWidth(c0); 128 | char c1; 129 | 130 | do { 131 | j = this.fontRandom.nextInt("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".length()); 132 | c1 = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".charAt(j); 133 | 134 | } while (k != this.getCharWidth(c1)); 135 | 136 | c0 = c1; 137 | } 138 | 139 | float f1 = j == -1 || this.unicodeFlag ? 0.5f : 1f; 140 | boolean flag = (c0 == 0 || j == -1 || this.unicodeFlag) && shadow; 141 | 142 | if (flag) { 143 | this.posX -= f1; 144 | this.posY -= f1; 145 | } 146 | 147 | float f = this.renderChar(c0, this.italicStyle); 148 | 149 | if (flag) { 150 | this.posX += f1; 151 | this.posY += f1; 152 | } 153 | 154 | if (this.boldStyle) { 155 | this.posX += f1; 156 | 157 | if (flag) { 158 | this.posX -= f1; 159 | this.posY -= f1; 160 | } 161 | 162 | this.renderChar(c0, this.italicStyle); 163 | this.posX -= f1; 164 | 165 | if (flag) { 166 | this.posX += f1; 167 | this.posY += f1; 168 | } 169 | 170 | ++f; 171 | } 172 | doDraw(f); 173 | } 174 | } 175 | } 176 | 177 | /** 178 | * @author cats 179 | * this fixes the issue with string width 180 | */ 181 | @Overwrite 182 | public int getStringWidth(String text) { 183 | if (text == null) { 184 | return 0; 185 | } else { 186 | // As is done in the rendering, replace the emoji text with two spaces before getting width 187 | for (String possibleEmoji : text.split(":")) { 188 | if (Emojis.isEmoji(possibleEmoji)) { 189 | text = text.replaceFirst(":" + possibleEmoji + ":", " "); 190 | } 191 | } 192 | 193 | int i = 0; 194 | boolean flag = false; 195 | 196 | for (int j = 0; j < text.length(); ++j) { 197 | char c0 = text.charAt(j); 198 | int k = this.getCharWidth(c0); 199 | 200 | if (k < 0 && j < text.length() - 1) { 201 | ++j; 202 | c0 = text.charAt(j); 203 | 204 | if (c0 != 'l' && c0 != 'L') { 205 | if (c0 == 'r' || c0 == 'R') { 206 | flag = false; 207 | } 208 | } else { 209 | flag = true; 210 | } 211 | 212 | k = 0; 213 | } 214 | 215 | i += k; 216 | 217 | if (flag && k > 0) { 218 | ++i; 219 | } 220 | } 221 | 222 | return i; 223 | } 224 | } 225 | 226 | } 227 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinGuiConnecting.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import de.enzaxd.viaforge.ViaForge; 4 | import net.minecraft.client.gui.GuiScreen; 5 | import net.minecraft.client.multiplayer.GuiConnecting; 6 | import net.minecraft.client.multiplayer.ServerData; 7 | import net.minecraft.client.resources.I18n; 8 | import net.minecraft.network.NetworkManager; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Overwrite; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(GuiConnecting.class) 17 | public abstract class MixinGuiConnecting extends GuiScreen { 18 | 19 | @Shadow 20 | private NetworkManager networkManager; 21 | 22 | public MixinGuiConnecting() { 23 | super(); 24 | } 25 | 26 | /** 27 | * @author Zihasz 28 | */ 29 | @Overwrite 30 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 31 | this.drawDefaultBackground(); 32 | 33 | String host = "unknown"; 34 | String ping = "unknown"; 35 | ServerData data = mc.getCurrentServerData(); 36 | 37 | if (data != null && data.serverIP != null) 38 | host = data.serverIP; 39 | 40 | 41 | if (this.networkManager == null) { 42 | this.drawCenteredString(this.fontRenderer, String.format("Connecting to %s...", host), this.width / 2, this.height / 2 - 50, 16777215); 43 | } else { 44 | this.drawCenteredString(this.fontRenderer, String.format("Logging in to %s...", host), this.width / 2, this.height / 2 - 50, 16777215); 45 | } 46 | 47 | this.drawCenteredString(this.fontRenderer, String.format("Ping to %s: %s", host, ping), this.width / 2, this.height / 2 - 40, 16777215); 48 | 49 | super.drawScreen(mouseX, mouseY, partialTicks); 50 | } 51 | 52 | @Inject(method = "connect", at = @At("HEAD")) 53 | public void injectConnect(String ip, int port, CallbackInfo ci) { 54 | ViaForge.getInstance().setLastServer(ip + ":" + port); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinGuiDisconnected.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import de.enzaxd.viaforge.ViaForge; 4 | import de.enzaxd.viaforge.gui.GuiProtocolSelector; 5 | import de.enzaxd.viaforge.protocols.ProtocolCollection; 6 | import net.minecraft.client.gui.*; 7 | import net.minecraft.client.multiplayer.GuiConnecting; 8 | import net.minecraft.client.multiplayer.ServerData; 9 | import net.minecraft.client.resources.I18n; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(GuiDisconnected.class) 17 | public abstract class MixinGuiDisconnected extends GuiScreen { 18 | 19 | @Shadow 20 | private int textHeight; 21 | 22 | @Inject(method = "initGui", at = @At("RETURN")) 23 | public void injectInitGui(CallbackInfo ci) { 24 | buttonList.add(new GuiButton(101, 5, 6, 98, 20, ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName())); 25 | this.buttonList.add(new GuiButton(102, this.width / 2 - 100, Math.min(this.height / 2 + this.textHeight / 2 + this.fontRenderer.FONT_HEIGHT, this.height - 30) + 25, "Reconnect")); 26 | } 27 | 28 | @Inject(method = "actionPerformed", at = @At("RETURN")) 29 | public void injectActionPerformed(GuiButton button, CallbackInfo ci) { 30 | if (button.id == 101) 31 | mc.displayGuiScreen(new GuiProtocolSelector(this)); 32 | if (button.id == 102) 33 | mc.displayGuiScreen(new GuiConnecting(new GuiMultiplayer(new GuiMainMenu()), mc, new ServerData(ViaForge.getInstance().getLastServer(), ViaForge.getInstance().getLastServer(), false))); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinGuiMainMenu.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import de.enzaxd.viaforge.ViaForge; 4 | import de.enzaxd.viaforge.gui.GuiProtocolSelector; 5 | import de.enzaxd.viaforge.protocols.ProtocolCollection; 6 | import net.minecraft.client.gui.*; 7 | import net.minecraft.client.resources.I18n; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Overwrite; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @Mixin(GuiMainMenu.class) 16 | public abstract class MixinGuiMainMenu extends GuiScreen { 17 | 18 | @Shadow 19 | private GuiButton modButton; 20 | 21 | /** 22 | * @author Zihasz 23 | */ 24 | @Overwrite 25 | public void addSingleplayerMultiplayerButtons(int p_73969_1_, int p_73969_2_) { 26 | this.buttonList.add(new GuiButton(1, this.width / 2 - 100, p_73969_1_, I18n.format("menu.singleplayer"))); 27 | this.buttonList.add(new GuiButton(2, this.width / 2 - 100, p_73969_1_ + p_73969_2_, I18n.format("menu.multiplayer"))); 28 | this.buttonList.add(this.modButton = new GuiButton(6, this.width / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.format("fml.menu.mods"))); 29 | this.buttonList.add(new GuiButton(101, this.width / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, "Alt Manager")); 30 | this.buttonList.add(new GuiButton(102, 5, 6, 98, 20, ProtocolCollection.getProtocolById(ViaForge.getInstance().getVersion()).getName())); 31 | } 32 | 33 | @Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", at = @At("TAIL")) 34 | public void actionPerformed(GuiButton button, CallbackInfo ci) { 35 | if (button.id == 101) { 36 | // TODO: Display actual AltManager screen 37 | mc.displayGuiScreen(new GuiMultiplayer(this)); 38 | } 39 | if (button.id == 102) { 40 | mc.displayGuiScreen(new GuiProtocolSelector(this)); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinGuiMultiplayer.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import de.enzaxd.viaforge.gui.GuiProtocolSelector; 4 | import dev.zihasz.anarchtilities.ui.thealtening.GuiTheAltening; 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.gui.GuiMultiplayer; 7 | import net.minecraft.client.gui.GuiScreen; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(GuiMultiplayer.class) 14 | public abstract class MixinGuiMultiplayer extends GuiScreen { 15 | 16 | @Inject(method = "initGui", at = @At("RETURN")) 17 | public void initGui(CallbackInfo callbackInfo) { 18 | this.buttonList.add(new GuiButton(101, 7, 7, 100, 20, "ViaForge")); 19 | this.buttonList.add(new GuiButton(102, 114, 7, 100, 20, "TheAltening")); 20 | this.buttonList.add(new GuiButton(103, this.width - 107, 7, 100, 20, "PingBypass")); 21 | this.buttonList.add(new GuiButton(104, this.width - 214, 7, 100, 20, "Proxy / VPN")); 22 | } 23 | 24 | @Inject(method = "actionPerformed", at = @At("RETURN")) 25 | protected void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { 26 | if (button.id == 101) mc.displayGuiScreen(new GuiProtocolSelector(this)); 27 | if (button.id == 102) mc.displayGuiScreen(new GuiTheAltening(this)); 28 | if (button.id == 103) mc.displayGuiScreen(new GuiMultiplayer(this)); 29 | if (button.id == 104) mc.displayGuiScreen(new GuiMultiplayer(this)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinGuiPlayerTabOverlay.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import dev.tigr.clantags.api.ClanTags; 4 | import net.minecraft.client.gui.GuiPlayerTabOverlay; 5 | import net.minecraft.client.network.NetworkPlayerInfo; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(GuiPlayerTabOverlay.class) 12 | public abstract class MixinGuiPlayerTabOverlay { 13 | 14 | /** 15 | * Adds clantags to tab overlay 16 | * 17 | * @author Tigermouthbear 18 | */ 19 | @Inject(method = "getPlayerName", at = @At("RETURN"), cancellable = true) 20 | public void playerNameWrapper(NetworkPlayerInfo networkPlayerInfoIn, CallbackInfoReturnable cir) { 21 | cir.setReturnValue(ClanTags.handlePlayerTab(networkPlayerInfoIn)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinMinecraft.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import de.enzaxd.viaforge.ViaForge; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.main.GameConfiguration; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(Minecraft.class) 12 | public abstract class MixinMinecraft { 13 | 14 | @Inject(method = "", at = @At("RETURN")) 15 | public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) { 16 | try { 17 | ViaForge.getInstance().start(); 18 | } catch (Exception e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/MixinNetworkManagerChInit.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin; 2 | 3 | import com.viaversion.viaversion.api.connection.UserConnection; 4 | import com.viaversion.viaversion.connection.UserConnectionImpl; 5 | import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; 6 | import de.enzaxd.viaforge.ViaForge; 7 | import de.enzaxd.viaforge.handler.CommonTransformer; 8 | import de.enzaxd.viaforge.handler.VRDecodeHandler; 9 | import de.enzaxd.viaforge.handler.VREncodeHandler; 10 | import io.netty.channel.Channel; 11 | import io.netty.channel.socket.SocketChannel; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | @Mixin(targets = "net.minecraft.network.NetworkManager$5") 18 | public abstract class MixinNetworkManagerChInit { 19 | 20 | @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) 21 | private void onInitChannel(Channel channel, CallbackInfo ci) { 22 | if (channel instanceof SocketChannel && ViaForge.getInstance().getVersion() != ViaForge.SHARED_VERSION) { 23 | 24 | UserConnection user = new UserConnectionImpl(channel, true); 25 | new ProtocolPipelineImpl(user); 26 | 27 | channel.pipeline() 28 | .addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new VREncodeHandler(user)) 29 | .addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new VRDecodeHandler(user)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/core/mixin/accessor/IMinecraft.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.core.mixin.accessor; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.Session; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(Minecraft.class) 9 | public interface IMinecraft { 10 | 11 | @Accessor("session") 12 | public void setSession(Session session); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/ui/elements/GuiPasswordField.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.ui.elements; 2 | 3 | import net.minecraft.client.gui.Gui; 4 | 5 | public class GuiPasswordField extends Gui { 6 | 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/ui/thealtening/GuiTheAltening.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.ui.thealtening; 2 | 3 | import com.mojang.authlib.Agent; 4 | import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; 5 | import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; 6 | import com.thealtening.api.TheAlteningException; 7 | import com.thealtening.api.response.Account; 8 | import com.thealtening.api.retriever.BasicDataRetriever; 9 | import com.thealtening.auth.TheAlteningAuthentication; 10 | import com.thealtening.auth.service.AlteningServiceType; 11 | import dev.zihasz.anarchtilities.core.mixin.accessor.IMinecraft; 12 | import dev.zihasz.anarchtilities.utils.SessionType; 13 | import net.minecraft.client.gui.GuiButton; 14 | import net.minecraft.client.gui.GuiScreen; 15 | import net.minecraft.client.gui.GuiTextField; 16 | import net.minecraft.util.Session; 17 | import org.lwjgl.opengl.GL11; 18 | 19 | import java.io.IOException; 20 | import java.lang.reflect.AccessibleObject; 21 | import java.net.Proxy; 22 | 23 | public class GuiTheAltening extends GuiScreen { 24 | 25 | public static TheAlteningAuthentication authentication = TheAlteningAuthentication.mojang(); 26 | public static BasicDataRetriever dataRetriever; 27 | private static String currentUsername; 28 | 29 | private final GuiScreen parentScreen; 30 | 31 | private GuiTextField txtToken; 32 | private GuiTextField txtApiKey; 33 | 34 | public GuiTheAltening(final GuiScreen parentScreen) { 35 | this.parentScreen = parentScreen; 36 | } 37 | 38 | public void initGui() { 39 | this.txtToken = new GuiTextField(0, mc.fontRenderer, this.width / 2 - 100, this.height / 2 - (this.width / 8), 200, 20); 40 | this.txtApiKey = new GuiTextField(1, mc.fontRenderer, this.width / 2 - 100, this.height / 2 + (this.width / 8), 200, 20); 41 | 42 | this.addButton(new GuiButton(101, this.width / 2 - 100, this.height / 2 - (this.width / 8) + 25, "Login")); 43 | this.addButton(new GuiButton(103, this.width / 2 - 100, this.height / 2 + (this.width / 8) + 25, dataRetriever == null ? "Check" : "Generate")); 44 | 45 | this.addButton(new GuiButton(110, this.width / 2 - 100, this.height - (this.height / 8), "Back")); 46 | 47 | super.initGui(); 48 | } 49 | 50 | public void updateScreen() { 51 | this.txtToken.updateCursorCounter(); 52 | 53 | super.updateScreen(); 54 | } 55 | 56 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 57 | this.drawDefaultBackground(); 58 | 59 | GL11.glPushMatrix(); 60 | GL11.glScalef(2.0F, 2.0F, 2.0F); 61 | this.drawCenteredString(this.fontRenderer, "TheAltening", this.width / 4, 7, 16777215); 62 | GL11.glPopMatrix(); 63 | 64 | this.drawCenteredString(this.fontRenderer, "Username: " + currentUsername, this.width / 2, this.height / 8, 16777215); 65 | 66 | this.drawCenteredString(mc.fontRenderer, "Token", this.width / 2, this.height / 2 - (this.width / 8) - 15, 16777215); 67 | this.txtToken.drawTextBox(); 68 | 69 | this.drawCenteredString(mc.fontRenderer, "API Key", this.width / 2, this.height / 2 + (this.width / 8) - 15, 16777215); 70 | this.txtApiKey.drawTextBox(); 71 | 72 | super.drawScreen(mouseX, mouseY, partialTicks); 73 | } 74 | 75 | protected void actionPerformed(GuiButton button) throws IOException { 76 | if (button.id == 101) 77 | this.loginWithAlteningToken(this.txtToken.getText()); 78 | if (button.id == 101) { 79 | if (dataRetriever == null) createRetriever(this.txtApiKey.getText()); 80 | else generateAccount(); 81 | } 82 | 83 | if (button.id == 110) 84 | mc.displayGuiScreen(parentScreen); 85 | 86 | super.actionPerformed(button); 87 | } 88 | 89 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 90 | this.txtToken.mouseClicked(mouseX, mouseY, mouseButton); 91 | 92 | super.mouseClicked(mouseX, mouseY, mouseButton); 93 | } 94 | 95 | protected void keyTyped(char typedChar, int keyCode) throws IOException { 96 | this.txtToken.textboxKeyTyped(typedChar, keyCode); 97 | 98 | super.keyTyped(typedChar, keyCode); 99 | } 100 | 101 | public void loginWithAlteningToken(String token) { 102 | if (token.isEmpty()) 103 | throw new IllegalArgumentException("Empty token!"); 104 | 105 | try { 106 | authentication.updateService(AlteningServiceType.THEALTENING); 107 | 108 | YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""); 109 | YggdrasilUserAuthentication user = (YggdrasilUserAuthentication) service.createUserAuthentication(Agent.MINECRAFT); 110 | user.setUsername(token); 111 | user.setPassword(token); 112 | user.logIn(); 113 | 114 | Session session = new Session( 115 | user.getSelectedProfile().getName(), 116 | user.getSelectedProfile().getId().toString(), 117 | user.getAuthenticatedToken(), 118 | SessionType.LEGACY 119 | ); 120 | this.setSession(session); 121 | } catch (Exception e) { 122 | e.printStackTrace(); 123 | } 124 | } 125 | public void loginWithUsernamePassword(String username, String password) { 126 | if (username.isEmpty() || password.isEmpty()) 127 | throw new IllegalArgumentException("Username or password is empty"); 128 | 129 | try { 130 | YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""); 131 | YggdrasilUserAuthentication user = (YggdrasilUserAuthentication) service.createUserAuthentication(Agent.MINECRAFT); 132 | user.setUsername(username); 133 | user.setPassword(password); 134 | user.logIn(); 135 | 136 | Session session = new Session( 137 | user.getSelectedProfile().getName(), 138 | user.getSelectedProfile().getId().toString(), 139 | user.getAuthenticatedToken(), 140 | SessionType.LEGACY 141 | ); 142 | this.setSession(session); 143 | } catch (Exception e) { 144 | e.printStackTrace(); 145 | } 146 | } 147 | public void loginWithSession(AlteningServiceType serviceType, Session session) { 148 | if (session == null) 149 | throw new IllegalArgumentException("Session is null!"); 150 | 151 | authentication.updateService(serviceType); 152 | this.setSession(session); 153 | } 154 | 155 | private void createRetriever(String apiKey) { 156 | try { 157 | dataRetriever = new BasicDataRetriever(apiKey); 158 | } catch (TheAlteningException e) { 159 | e.printStackTrace(); 160 | } 161 | } 162 | private void generateAccount() { 163 | if (dataRetriever == null) 164 | throw new IllegalStateException("DataRetriever not initialised!"); 165 | 166 | try { 167 | Account account = dataRetriever.getAccount(); 168 | this.loginWithAlteningToken(account.getToken()); 169 | // this.loginWithUsernamePassword(account.getUsername(), account.getPassword()); 170 | } catch (Exception e) { 171 | e.printStackTrace(); 172 | } 173 | } 174 | 175 | private void setSession(Session session) { 176 | ((IMinecraft) mc).setSession(session); 177 | currentUsername = session.getUsername(); 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/utils/SessionType.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.utils; 2 | 3 | public class SessionType { 4 | 5 | public static final String LEGACY = "LEGACY"; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/dev/zihasz/anarchtilities/utils/Util.java: -------------------------------------------------------------------------------- 1 | package dev.zihasz.anarchtilities.utils; 2 | 3 | import net.minecraft.client.Minecraft; 4 | 5 | public interface Util { 6 | 7 | Minecraft mc = Minecraft.getMinecraft(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/resources/anarchtilities_at.cfg: -------------------------------------------------------------------------------- 1 | public net.minecraft.client.Minecraft * 2 | public net.minecraft.client.Minecraft *() -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "anarchtilities", 4 | "name": "Anarchtilities", 5 | "description": "Utilities for Anarchy servers.", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "zihasz.dev", 9 | "updateUrl": "", 10 | "authorList": [ 11 | "Zihasz" 12 | ], 13 | "credits": "", 14 | "logoFile": "", 15 | "screenshots": [], 16 | "dependencies": [] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /src/main/resources/mixins.anarchtilities.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "dev.zihasz.anarchtilities.core.mixin", 4 | "refmap": "mixins.anarchtilities.refmap.json", 5 | "compatibilityLevel": "JAVA_8", 6 | "minVersion": "0.8", 7 | "mixins": [ 8 | "MixinFontRenderer", 9 | "MixinGuiConnecting", 10 | "MixinGuiDisconnected", 11 | "MixinGuiMainMenu", 12 | "MixinGuiMultiplayer", 13 | "MixinGuiPlayerTabOverlay", 14 | "MixinMinecraft", 15 | "MixinNetworkManagerChInit", 16 | "accessor.IMinecraft" 17 | ], 18 | "injectors": { 19 | "defaultRequire": 1 20 | } 21 | } --------------------------------------------------------------------------------