├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── client ├── java │ └── net │ │ └── earthcomputer │ │ └── viavanillaplus │ │ └── ViaVanillaPlusClient.java └── resources │ └── viavanillaplus.client.mixins.json └── main ├── java └── net │ └── earthcomputer │ └── viavanillaplus │ ├── ViaVanillaPlus.java │ └── mixin │ ├── carpet │ └── Protocol1_20_2To1_20Mixin.java │ └── syncmatica │ └── Protocol1_20_2To1_20Mixin.java └── resources ├── assets └── viavanillaplus │ └── icon.png ├── fabric.mod.json └── viavanillaplus.mixins.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Automatically build the project and run any configured tests for every push 2 | # and submitted pull request. This can help catch issues that only occur on 3 | # certain platforms or Java versions, and provides a first line of defence 4 | # against bad commits. 5 | 6 | name: build 7 | on: [pull_request, push] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | # Use these Java versions 14 | java: [ 15 | 17, # Current Java LTS & minimum supported by Minecraft 16 | ] 17 | # and run on both Linux and Windows 18 | os: [ubuntu-22.04, windows-2022] 19 | runs-on: ${{ matrix.os }} 20 | steps: 21 | - name: checkout repository 22 | uses: actions/checkout@v3 23 | - name: validate gradle wrapper 24 | uses: gradle/wrapper-validation-action@v1 25 | - name: setup jdk ${{ matrix.java }} 26 | uses: actions/setup-java@v3 27 | with: 28 | java-version: ${{ matrix.java }} 29 | distribution: 'microsoft' 30 | - name: make gradle wrapper executable 31 | if: ${{ runner.os != 'Windows' }} 32 | run: chmod +x ./gradlew 33 | - name: build 34 | run: ./gradlew build 35 | - name: capture build artifacts 36 | if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS 37 | uses: actions/upload-artifact@v3 38 | with: 39 | name: Artifacts 40 | path: build/libs/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | 35 | # java 36 | 37 | hs_err_*.log 38 | replay_*.log 39 | *.hprof 40 | *.jfr 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT license below applies to all files in this project except for those under the via-translator directory. Those 2 | files are instead licensed under GPLv3, specified in the license file in that directory. 3 | 4 | MIT License 5 | 6 | Copyright (c) 2023 Joseph Burton (Earthcomputer) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ViaVanillaPlus 2 | 3 | ![Icon](src/main/resources/assets/viavanillaplus/icon.png) 4 | 5 | Handles protocol changes in Vanilla+ mods, intended as an addon to ViaFabricPlus. 6 | 7 | Currently supported mods are: 8 | - [Carpet](https://modrinth.com/mod/carpet) 9 | - [Syncmatica](https://modrinth.com/mod/syncmatica) 10 | 11 | Available on Modrinth at [https://modrinth.com/mod/viavanillaplus]. 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '1.4-SNAPSHOT' 3 | id 'maven-publish' 4 | id 'com.modrinth.minotaur' version '2.+' 5 | } 6 | 7 | version = "${project.mod_version}+mc${project.minecraft_version}" 8 | group = project.maven_group 9 | 10 | base { 11 | archivesName = project.archives_base_name 12 | } 13 | 14 | repositories { 15 | exclusiveContent { 16 | forRepository { 17 | maven { 18 | name = 'Modrinth' 19 | url = 'https://api.modrinth.com/maven' 20 | } 21 | } 22 | filter { 23 | includeGroup 'maven.modrinth' 24 | } 25 | } 26 | 27 | maven { 28 | name = "Jitpack" 29 | url = "https://jitpack.io" 30 | } 31 | maven { 32 | name = 'ViaVersion' 33 | url = 'https://repo.viaversion.com/' 34 | } 35 | maven { 36 | name = "Lenni0451" 37 | url = "https://maven.lenni0451.net/everything" 38 | } 39 | maven { 40 | name = "TerraformersMC" 41 | url = "https://maven.terraformersmc.com/releases" 42 | } 43 | maven { 44 | name = "OpenCollab Snapshots" 45 | url = "https://repo.opencollab.dev/maven-snapshots/" 46 | } 47 | 48 | maven { 49 | url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" 50 | } 51 | } 52 | 53 | loom { 54 | splitEnvironmentSourceSets() 55 | 56 | mods { 57 | "viavanillaplus" { 58 | sourceSet sourceSets.main 59 | sourceSet sourceSets.client 60 | } 61 | } 62 | 63 | } 64 | 65 | dependencies { 66 | // To change the versions see the gradle.properties file 67 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 68 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 69 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 70 | 71 | modImplementation "maven.modrinth:carpet:${project.carpet_version}" 72 | // implementation "com.viaversion:viaversion:${project.viaversion_version}" 73 | modImplementation "de.florianmichael:viafabricplus:${project.viafabricplus_version}" 74 | 75 | // Fabric API. This is technically optional, but you probably want it anyway. 76 | // modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 77 | 78 | // Uncomment the following line to enable the deprecated Fabric API modules. 79 | // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. 80 | 81 | // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" 82 | 83 | modRuntimeOnly('me.djtheredstoner:DevAuth-fabric:1.1.0') { 84 | transitive = false 85 | } 86 | runtimeOnly 'me.djtheredstoner:DevAuth-common:1.1.0' 87 | } 88 | 89 | processResources { 90 | inputs.property "version", project.version 91 | inputs.property "mcversions", project.fmj_mcversions 92 | 93 | filesMatching("fabric.mod.json") { 94 | expand "version": project.version, "mcversions": project.fmj_mcversions 95 | } 96 | } 97 | 98 | tasks.withType(JavaCompile).configureEach { 99 | it.options.release = 17 100 | } 101 | 102 | java { 103 | // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 104 | // if it is present. 105 | // If you remove this line, sources will not be generated. 106 | withSourcesJar() 107 | 108 | sourceCompatibility = JavaVersion.VERSION_17 109 | targetCompatibility = JavaVersion.VERSION_17 110 | } 111 | 112 | jar { 113 | from("LICENSE") { 114 | rename { "${it}_${project.base.archivesName.get()}"} 115 | } 116 | } 117 | 118 | modrinth { 119 | if (System.getenv('MODRINTH_TOKEN') == null && project.hasProperty('modrinthKey')) { 120 | token = project.modrinthKey 121 | } 122 | projectId = 'viavanillaplus' 123 | uploadFile = remapJar 124 | gameVersions.set(project.modrinth_mcversions.split(',').toList()) 125 | loaders = ['fabric', 'quilt'] 126 | dependencies { 127 | optional.project 'viafabricplus' 128 | optional.project 'viafabric' 129 | optional.project 'carpet' 130 | optional.project 'syncmatica' 131 | } 132 | } 133 | 134 | // configure the maven publication 135 | publishing { 136 | publications { 137 | mavenJava(MavenPublication) { 138 | from components.java 139 | } 140 | } 141 | 142 | // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. 143 | repositories { 144 | // Add repositories to publish to here. 145 | // Notice: This block does NOT have the same function as the block in the top level. 146 | // The repositories here will be used for publishing your artifact, not for 147 | // retrieving dependencies. 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | org.gradle.parallel=true 4 | 5 | # Fabric Properties 6 | # check these on https://fabricmc.net/develop 7 | minecraft_version=1.20.2 8 | yarn_mappings=1.20.2+build.4 9 | loader_version=0.15.2 10 | fmj_mcversions=~1.20.2 11 | modrinth_mcversions=1.20.2 12 | 13 | # Mod Properties 14 | mod_version=1.2.3 15 | maven_group=net.earthcomputer.viavanillaplus 16 | archives_base_name=viavanillaplus 17 | 18 | # Dependencies 19 | carpet_version=1.4.121 20 | fabric_version=0.90.4+1.20.2 21 | viafabricplus_version=2.10.1 22 | viaversion_version=4.9.3-SNAPSHOT 23 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ViaVersionAddons/ViaVanillaPlus/1200f4845267ef9333f64461912b1ec411cacf2e/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-8.3-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original 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 POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command; 206 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 207 | # shell script including quotes and variable substitutions, so put them in 208 | # double quotes to make sure that they get re-expanded; and 209 | # * put everything else in single quotes, so that it's not re-expanded. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /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 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 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 %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 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 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } -------------------------------------------------------------------------------- /src/client/java/net/earthcomputer/viavanillaplus/ViaVanillaPlusClient.java: -------------------------------------------------------------------------------- 1 | package net.earthcomputer.viavanillaplus; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | 5 | public class ViaVanillaPlusClient implements ClientModInitializer { 6 | @Override 7 | public void onInitializeClient() { 8 | } 9 | } -------------------------------------------------------------------------------- /src/client/resources/viavanillaplus.client.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.earthcomputer.viavanillaplus.mixin.client", 4 | "compatibilityLevel": "JAVA_17", 5 | "client": [ 6 | ], 7 | "injectors": { 8 | "defaultRequire": 1 9 | }, 10 | "overwrites": { 11 | "requireAnnotations": true 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/net/earthcomputer/viavanillaplus/ViaVanillaPlus.java: -------------------------------------------------------------------------------- 1 | package net.earthcomputer.viavanillaplus; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class ViaVanillaPlus implements ModInitializer { 9 | 10 | @Override 11 | public void onInitialize() { 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/net/earthcomputer/viavanillaplus/mixin/carpet/Protocol1_20_2To1_20Mixin.java: -------------------------------------------------------------------------------- 1 | package net.earthcomputer.viavanillaplus.mixin.carpet; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.viaversion.viaversion.api.protocol.AbstractProtocol; 5 | import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 6 | import com.viaversion.viaversion.api.type.Type; 7 | import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; 8 | import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; 9 | import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; 10 | import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; 11 | import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4; 12 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20; 13 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; 14 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | @Mixin(value = Protocol1_20_2To1_20.class, remap = false) 21 | public class Protocol1_20_2To1_20Mixin extends AbstractProtocol { 22 | @SuppressWarnings("deprecation") 23 | public Protocol1_20_2To1_20Mixin() { 24 | } 25 | 26 | @Inject(method = "sanitizeCustomPayload", at = @At("RETURN")) 27 | private void onSanitizeCustomPayload(PacketWrapper wrapper, CallbackInfo ci, @Local(name = "channel") String channel) throws Exception { 28 | if (channel.equals("carpet:hello")) { 29 | if (wrapper.getPacketType() == null) { 30 | return; 31 | } 32 | switch (wrapper.getPacketType().direction()) { 33 | case CLIENTBOUND -> { 34 | int command = wrapper.read(Type.VAR_INT); 35 | if (command == 69) { // hi 36 | String version = wrapper.read(Type.STRING); 37 | CompoundTag dataTag = new CompoundTag(); 38 | dataTag.put("69", new StringTag(version)); 39 | wrapper.write(Type.COMPOUND_TAG, dataTag); 40 | } else if (command == 1) { 41 | wrapper.write(Type.COMPOUND_TAG, wrapper.read(Type.NAMED_COMPOUND_TAG)); 42 | } else { 43 | wrapper.cancel(); 44 | } 45 | } 46 | case SERVERBOUND -> { 47 | CompoundTag dataTag = wrapper.read(Type.COMPOUND_TAG); 48 | Tag hello = dataTag.remove("420"); 49 | if (hello instanceof StringTag versionTag) { 50 | PacketWrapper newPacket = PacketWrapper.create(ServerboundPackets1_19_4.PLUGIN_MESSAGE, wrapper.user()); 51 | newPacket.write(Type.STRING, "carpet:hello"); 52 | newPacket.write(Type.VAR_INT, 420); // hello 53 | newPacket.write(Type.STRING, versionTag.getValue()); 54 | newPacket.sendToServer(Protocol1_20_2To1_20.class); 55 | } 56 | if (dataTag.isEmpty()) { 57 | wrapper.cancel(); 58 | } else { 59 | wrapper.write(Type.VAR_INT, 1); // data 60 | wrapper.write(Type.NAMED_COMPOUND_TAG, dataTag); 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/net/earthcomputer/viavanillaplus/mixin/syncmatica/Protocol1_20_2To1_20Mixin.java: -------------------------------------------------------------------------------- 1 | package net.earthcomputer.viavanillaplus.mixin.syncmatica; 2 | 3 | import com.viaversion.viaversion.api.protocol.AbstractProtocol; 4 | import com.viaversion.viaversion.api.protocol.packet.Direction; 5 | import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 6 | import com.viaversion.viaversion.api.protocol.packet.State; 7 | import com.viaversion.viaversion.api.type.Type; 8 | import com.viaversion.viaversion.exception.CancelException; 9 | import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; 10 | import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4; 11 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20; 12 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; 13 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; 14 | import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.ConfigurationState; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | @Mixin(value = Protocol1_20_2To1_20.class, remap = false) 21 | public class Protocol1_20_2To1_20Mixin extends AbstractProtocol { 22 | @SuppressWarnings("deprecation") 23 | public Protocol1_20_2To1_20Mixin() { 24 | } 25 | 26 | @Inject(method = "transform", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundConfigurationPackets1_20_2;CUSTOM_PAYLOAD:Lcom/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundConfigurationPackets1_20_2;")) 27 | private void onClientboundPluginMessage(Direction direction, State state, PacketWrapper wrapper, CallbackInfo ci) throws Exception { 28 | String channel = wrapper.passthrough(Type.STRING); 29 | if (channel.startsWith("syncmatica:")) { 30 | wrapper.user().get(ConfigurationState.class).addPacketToQueue(wrapper, true); 31 | throw CancelException.generate(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/viavanillaplus/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ViaVersionAddons/ViaVanillaPlus/1200f4845267ef9333f64461912b1ec411cacf2e/src/main/resources/assets/viavanillaplus/icon.png -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "viavanillaplus", 4 | "version": "${version}", 5 | "name": "ViaVanillaPlus", 6 | "description": "Handles protocol changes in Vanilla+ mods, intended as an addon to ViaFabricPlus", 7 | "authors": [ 8 | "Earthcomputer" 9 | ], 10 | "contact": { 11 | "homepage": "https://github.com/ViaVersionAddons/ViaVanillaPlus", 12 | "sources": "https://github.com/ViaVersionAddons/ViaVanillaPlus" 13 | }, 14 | "license": "MIT", 15 | "icon": "assets/viavanillaplus/icon.png", 16 | "environment": "*", 17 | "entrypoints": { 18 | "main": [ 19 | "net.earthcomputer.viavanillaplus.ViaVanillaPlus" 20 | ], 21 | "client": [ 22 | "net.earthcomputer.viavanillaplus.ViaVanillaPlusClient" 23 | ] 24 | }, 25 | "mixins": [ 26 | "viavanillaplus.mixins.json", 27 | { 28 | "config": "viavanillaplus.client.mixins.json", 29 | "environment": "client" 30 | } 31 | ], 32 | "depends": { 33 | "fabricloader": ">=0.15.0", 34 | "minecraft": "${mcversions}" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/resources/viavanillaplus.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.earthcomputer.viavanillaplus.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "mixins": [ 6 | "carpet.Protocol1_20_2To1_20Mixin", 7 | "syncmatica.Protocol1_20_2To1_20Mixin" 8 | ], 9 | "injectors": { 10 | "defaultRequire": 1 11 | }, 12 | "overwrites": { 13 | "requireAnnotations": true 14 | } 15 | } --------------------------------------------------------------------------------