Compare commits
58 Commits
c31b19c2ce
...
4d01ae9eee
Author | SHA1 | Date |
---|---|---|
Howard ZHY | 4d01ae9eee | |
EnZaXD | e9e1aa0e4e | |
FlorianMichael | f3da973db7 | |
FlorianMichael | 5e27fb3442 | |
FlorianMichael | ed679a0267 | |
FlorianMichael | d30417a737 | |
FlorianMichael | 9f1a2e2baf | |
FlorianMichael | d325b0691d | |
FlorianMichael | f589b3a28d | |
FlorianMichael | d2d5ed4458 | |
Howard ZHY | 325494824c | |
FlorianMichael | 2548bfa8dd | |
FlorianMichael | 9ba5f28ebd | |
FlorianMichael | d93c875d88 | |
FlorianMichael | 2721955931 | |
FlorianMichael | 08cf5e9929 | |
FlorianMichael | cb49b6d819 | |
FlorianMichael | d19e57a98e | |
FlorianMichael | 1f047f0a84 | |
ccetl | 3a7053fa0c | |
FlorianMichael | 8657507cca | |
FlorianMichael | 53d81b4bdb | |
FlorianMichael | fbe5cf8ded | |
FlorianMichael | 25f3c470e3 | |
FlorianMichael | 10547649ad | |
FlorianMichael | 25af1896f5 | |
EnZaXD | d551e52083 | |
FlorianMichael | 98c299886f | |
FlorianMichael | bd7b535134 | |
FlorianMichael | 9912150b16 | |
FlorianMichael | 060d4b527b | |
FlorianMichael | bc32c47617 | |
EnZaXD | b6057fe811 | |
Howard ZHY | fd77239068 | |
EnZaXD | 45d10be95d | |
EnZaXD | 36d14d5554 | |
EnZaXD | 9d02580e50 | |
FlorianMichael | 17218b808c | |
FlorianMichael | 11e365b36d | |
FlorianMichael | d0d46e9e6d | |
FlorianMichael | cd293c781f | |
FlorianMichael | 4da0b63c19 | |
FlorianMichael | 80594682a8 | |
FlorianMichael | b91a408d36 | |
FlorianMichael | c202c4c3ca | |
FlorianMichael | 758dc93bc7 | |
FlorianMichael | 2bd493a166 | |
FlorianMichael | c9efed6697 | |
FlorianMichael | 76ec05ec35 | |
FlorianMichael | 79631f7caf | |
EnZaXD | a6c9ed237f | |
EnZaXD | ddc93d7a59 | |
EnZaXD | 3a2011caab | |
EnZaXD | 14e555c861 | |
EnZaXD | 3eb7157bf1 | |
EnZaXD | cb0e67591e | |
EnZaXD | fc3b03d8fb | |
EnZaXD | ab9c735eea |
|
@ -0,0 +1,2 @@
|
|||
github: FlorianMichael
|
||||
custom: ["https://florianmichael.de/donate"]
|
|
@ -9,10 +9,10 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 8
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 8
|
||||
java-version: 16
|
||||
distribution: 'temurin'
|
||||
check-latest: true
|
||||
- name: Cache Dependencies
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge Copyright (C) 2021-&#36;today.year FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." />
|
||||
<option name="myName" value="GPL-3.0" />
|
||||
</copyright>
|
||||
</component>
|
|
@ -0,0 +1,8 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="GPL_3_0">
|
||||
<module2copyright>
|
||||
<element module="Project Files" copyright="GPL-3.0" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="__TEMPLATE__" />
|
||||
</settings>
|
||||
</component>
|
|
@ -0,0 +1,4 @@
|
|||
- Updated Via* projects to support 1.20.5
|
||||
- Fixed version in 1.12 mcmod.info file
|
||||
- Fixed connecting issues and other desyncs
|
||||
- Fixed pre netty versions not working on online servers
|
22
README.md
22
README.md
|
@ -20,19 +20,17 @@ GitHub Releases: https://github.com/ViaVersion/ViaForge
|
|||
|
||||
## For developers
|
||||
### Project Structure
|
||||
All ViaForge versions from Minecraft version 1.12 onwards are on the `master` branch. <br>
|
||||
All ViaForge versions from Minecraft version 1.12.2 onwards are on the `master` branch. <br>
|
||||
The names of the submodules indicate the version, they are always given in the format `mc-<version name without .>`. <br>
|
||||
`Minecraft 1.12.2` - `mc112` <br>
|
||||
`Minecraft 1.14.4` - `mc114` <br>
|
||||
`Minecraft 1.15.2` - `mc115` <br>
|
||||
`Minecraft 1.16.4/5` - `mc116` <br>
|
||||
`Minecraft 1.17.1` - `mc117` <br>
|
||||
`Minecraft 1.18.2` - `mc118` <br>
|
||||
`Minecraft 1.19.4` - `mc119` <br>
|
||||
`Minecraft 1.20.2` - `mc120` <br>
|
||||
`Minecraft 1.12.2` - `viaforge-mc1122` <br>
|
||||
`Minecraft 1.16.5` - `viaforge-mc1165` <br>
|
||||
`Minecraft 1.17.1` - `viaforge-mc1171` <br>
|
||||
`Minecraft 1.18.2` - `viaforge-mc1182` <br>
|
||||
`Minecraft 1.19.4` - `viaforge-mc1194` <br>
|
||||
`Minecraft 1.20.4` - `viaforge-mc1204` <br>
|
||||
|
||||
### ViaForge for Minecraft 1.8
|
||||
Since ForgeGradle for Minecraft 1.8 is too old, it has its own branch called `legacy-1.8`
|
||||
Since ForgeGradle for Minecraft 1.8.9 is too old, it has its own branch called `legacy-1.8`
|
||||
|
||||
### I want ViaForge in my own utility mod
|
||||
Just take a look at my other Project called `ViaMCP`: https://github.com/FlorianMichael/ViaMCP
|
||||
|
@ -40,7 +38,7 @@ Just take a look at my other Project called `ViaMCP`: https://github.com/Florian
|
|||
## Other ViaVersion Mods / Platforms
|
||||
- ViaFabric - https://modrinth.com/mod/viafabric
|
||||
- ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus (Includes additional modifications to make the experience better)
|
||||
- ViaProxy (App) - https://github.com/ViaVersion/ViaProxy/
|
||||
- ViaaaS (Proxy) - https://github.com/ViaVersion/ViaaaS
|
||||
- ViaProxy (App) - https://github.com/ViaVersion/ViaProxy
|
||||
- ViaaaS (Proxy) - https://github.com/ViaVersion/ViaaaS
|
||||
|
||||
### If you want to talk with me, feel free to join my [Discord](https://discord.gg/BwWhCHUKDf)
|
||||
|
|
206
build.gradle
206
build.gradle
|
@ -1,8 +1,204 @@
|
|||
plugins {
|
||||
id "java"
|
||||
id "viaforge.base-conventions"
|
||||
buildscript {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
|
||||
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
|
||||
maven { url = "https://jitpack.io/" }
|
||||
maven { url = "https://files.minecraftforge.net/maven" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "com.github.johnrengelman:shadow:7.1.2"
|
||||
classpath "net.minecraftforge.gradle:ForgeGradle:6.+"
|
||||
classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT"
|
||||
classpath "me.modmuss50:mod-publish-plugin:0.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "io.netty:netty-all:4.0.20.Final"
|
||||
allprojects {
|
||||
apply plugin: "java-library"
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
apply plugin: "me.modmuss50.mod-publish-plugin"
|
||||
|
||||
// We define the configuration here so we can use it across all conventions and platforms
|
||||
// To define which projects/source files should be included in the jar
|
||||
configurations {
|
||||
library
|
||||
implementation.extendsFrom(library)
|
||||
}
|
||||
|
||||
// Repositories for the ViaVersion dependencies defined below
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||
}
|
||||
maven {
|
||||
url = "https://repo.viaversion.com"
|
||||
}
|
||||
}
|
||||
|
||||
// Replace the version in the mcmod.info and mods.toml files with the project version
|
||||
// Since this depends on the platform version, we can't define it in the global scope :(
|
||||
tasks {
|
||||
processResources {
|
||||
for (final def file in ["mcmod.info", "META-INF/mods.toml"]) {
|
||||
filesMatching(file) {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Including all required libraries for ViaVersion {for version numbers see gradle.properties}
|
||||
dependencies {
|
||||
compileOnly "io.netty:netty-all:4.0.20.Final"
|
||||
|
||||
library "com.viaversion:viaversion-common:${project.viaversion_version}"
|
||||
library "com.viaversion:viabackwards-common:${project.viabackwards_version}"
|
||||
library "com.viaversion:viarewind-common:${project.viarewind_version}"
|
||||
library ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
}
|
||||
library "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
library ("net.raphimc:ViaLoader:${project.vialoader_version}") {
|
||||
exclude group: "com.google.guava"
|
||||
exclude group: "org.slf4j"
|
||||
}
|
||||
|
||||
library "org.yaml:snakeyaml:${project.snake_yml_version}"
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: "net.minecraftforge.gradle"
|
||||
apply plugin: "org.spongepowered.mixin"
|
||||
|
||||
// Define the jar output attributes for all platforms
|
||||
archivesBaseName = project.maven_name
|
||||
version = maven_version
|
||||
group = maven_group
|
||||
|
||||
// Used to execute code only for specific submodules
|
||||
def versionId = Integer.parseInt(project.mc_version.replace(".", ""))
|
||||
|
||||
compileJava.options.encoding = "UTF-8"
|
||||
|
||||
minecraft {
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file("run")
|
||||
|
||||
property "forge.logging.markers", "REGISTRIES"
|
||||
property "forge.logging.console.level", "debug"
|
||||
|
||||
// mixin
|
||||
property "mixin.debug.export", "true"
|
||||
property "mixin.hotSwap", "true"
|
||||
property "fml.coreMods.load", "de.florianmichael.viaforge.mixin.MixinLoader" // Only required for MC 1.12, but modern Forges skips this anyway
|
||||
args "-mixin.config=" + "mixins." + project.getProperty('maven_name') + ".json"
|
||||
|
||||
// source set
|
||||
mods {
|
||||
"${project.maven_name}" {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources {
|
||||
srcDir "src/generated/resources"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if (versionId >= 1_17_1) {
|
||||
// Minecraft 1.17+ already includes slf4j, so we don't need to include it
|
||||
compileOnly "org.slf4j:slf4j-api:${slf4j_version}"
|
||||
} else {
|
||||
library "org.slf4j:slf4j-api:${slf4j_version}"
|
||||
}
|
||||
|
||||
library "org.spongepowered:mixin:${mixin_version}"
|
||||
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
||||
|
||||
library project(":") // Include the base project, to get Common-ViaForge
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "mixins.${project.maven_name}.refmap.json"
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest.attributes(
|
||||
"Specification-Title": "viaforge",
|
||||
"Specification-Vendor": "viaforge",
|
||||
"Specification-Version": project.version,
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": project.version,
|
||||
"Implementation-Vendor" :"viaforge",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
|
||||
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"TweakOrder": "0",
|
||||
"FMLCorePluginContainsFMLMod": "true", // Only required for MC 1.12, but modern Forges skips this anyway
|
||||
"FMLCorePlugin": "de.florianmichael.viaforge.mixin.MixinLoader", // Counterpart to the above
|
||||
"MixinConfigs": "mixins.${project.maven_name}.json",
|
||||
"ForceLoadAsMod": "true"
|
||||
)
|
||||
enabled = false
|
||||
}
|
||||
|
||||
java {
|
||||
if (versionId >= 1_17_1) {
|
||||
// Minecraft 1.17+ required Java 16/17 to compile
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = jar.archiveFileName
|
||||
configurations = [project.configurations.library] // Include the dependencies from the include configuration
|
||||
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||
|
||||
// Prevent conflicts with Forge's weird service loading
|
||||
exclude("META-INF/maven/**")
|
||||
exclude("META-INF/versions/**")
|
||||
|
||||
if (versionId >= 1_13_2) {
|
||||
// We don't need to package mixins into Forge 1.13+ jars, since Forge already has it
|
||||
exclude("org/spongepowered/**")
|
||||
}
|
||||
if (versionId >= 1_16_5) {
|
||||
// Get rid of the services folder, since Forge 1.16+ would conflict with some of the ForgeDev Environment's services
|
||||
// And since we don't need them for Mixins anyway, we can just exclude them from the shadowJar
|
||||
exclude("META-INF/services/**")
|
||||
}
|
||||
}
|
||||
|
||||
publishMods {
|
||||
file = shadowJar.archiveFile
|
||||
type = STABLE
|
||||
displayName = rootProject.name + ' ' + project.version
|
||||
version = project.version + "+" + project.mc_version
|
||||
modLoaders.add("forge")
|
||||
changelog = file("../CHANGELOG.md").text
|
||||
dryRun = rootProject.maven_version.contains("SNAPSHOT")
|
||||
|
||||
curseforge {
|
||||
accessToken = providers.gradleProperty("curseforge.publishing_token")
|
||||
projectId = "418933"
|
||||
minecraftVersions.addAll(project.mc_version.split(','))
|
||||
}
|
||||
modrinth {
|
||||
accessToken = providers.gradleProperty("modrinth.publishing_token")
|
||||
projectId = "Z6se2s8f"
|
||||
minecraftVersions.addAll(project.mc_version.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
reobf {
|
||||
shadowJar {}
|
||||
}
|
||||
|
||||
jar.dependsOn("shadowJar")
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
plugins {
|
||||
id "groovy-gradle-plugin"
|
||||
}
|
||||
|
||||
// Counterpart of settings.gradle file, sadly conventions can't use those defined repositories for some reason...
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
|
||||
maven { url = "https://repo.spongepowered.org/repository/maven-public/" }
|
||||
maven { url = "https://jitpack.io/" }
|
||||
maven { url = "https://files.minecraftforge.net/maven" }
|
||||
}
|
||||
|
||||
// Counterpart of settings.gradle file, sadly conventions can't use those defined plugins for some reason...
|
||||
dependencies {
|
||||
implementation "com.github.johnrengelman:shadow:7.1.2"
|
||||
implementation "net.minecraftforge.gradle:ForgeGradle:5.+"
|
||||
implementation "org.spongepowered:mixingradle:0.7-SNAPSHOT"
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
plugins {
|
||||
id "java-library"
|
||||
}
|
||||
|
||||
// We define the configuration here so we can use it across all conventions and platforms
|
||||
// To define which projects/source files should be included in the jar
|
||||
configurations {
|
||||
include
|
||||
implementation.extendsFrom(include)
|
||||
}
|
||||
|
||||
// Repositories for the ViaVersion dependencies defined below
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||
}
|
||||
maven {
|
||||
url = "https://repo.viaversion.com"
|
||||
}
|
||||
}
|
||||
|
||||
// Including all required libraries for ViaVersion {for version numbers see gradle.properties}
|
||||
dependencies {
|
||||
include "com.viaversion:viaversion:${project.viaversion_version}"
|
||||
include "com.viaversion:viabackwards:${project.viabackwards_version}"
|
||||
include "com.viaversion:viarewind-universal:${project.viarewind_version}"
|
||||
include ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
}
|
||||
include "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
include "net.raphimc:ViaLoader:${project.vialoader_version}"
|
||||
|
||||
include "org.yaml:snakeyaml:${project.snake_yml_version}"
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
plugins {
|
||||
id "viaforge.shadow-conventions"
|
||||
}
|
||||
|
||||
// Get rid of the services folder, since Forge 1.16+ would conflict with some of the ForgeDev Environment's services
|
||||
// And since we don't need them for Mixins anyway, we can just exclude them from the shadowJar
|
||||
shadowJar {
|
||||
exclude "META-INF/services/**"
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
plugins {
|
||||
id "net.minecraftforge.gradle"
|
||||
id "org.spongepowered.mixin"
|
||||
|
||||
id "viaforge.shadow-conventions"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file("run")
|
||||
|
||||
property "forge.logging.markers", "REGISTRIES"
|
||||
property "forge.logging.console.level", "debug"
|
||||
|
||||
// mixin
|
||||
property "mixin.debug.export", "true"
|
||||
property "mixin.hotSwap", "true"
|
||||
property "fml.coreMods.load", "de.florianmichael.viaforge.mixin.MixinLoader" // Only required for MC 1.12, but modern Forges skips this anyway
|
||||
args "-mixin.config=" + "mixins." + project.getProperty('maven_name') + ".json"
|
||||
|
||||
// source set
|
||||
mods {
|
||||
"${maven_name}" {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources {
|
||||
srcDir "src/generated/resources"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
include "org.spongepowered:mixin:${mixin_version}"
|
||||
include "org.slf4j:slf4j-api:${slf4j_version}"
|
||||
|
||||
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
|
||||
|
||||
include project(":") // Include the base project, to get Common-ViaForge
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "mixins.${maven_name}.refmap.json"
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest.attributes(
|
||||
"Specification-Title": "viaforge",
|
||||
"Specification-Vendor": "viaforge",
|
||||
"Specification-Version": "1",
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${archiveVersion}",
|
||||
"Implementation-Vendor" :"viaforge",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
|
||||
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"TweakOrder": "0",
|
||||
"FMLCorePluginContainsFMLMod": "true", // Only required for MC 1.12, but modern Forges skips this anyway
|
||||
"FMLCorePlugin": "de.florianmichael.viaforge.mixin.MixinLoader", // Counterpart to the above
|
||||
"MixinConfigs": "mixins.${maven_name}.json",
|
||||
"ForceLoadAsMod": "true"
|
||||
)
|
||||
enabled = false
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = jar.archiveFileName
|
||||
configurations = [project.configurations.include] // Include the dependencies from the include configuration
|
||||
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||
|
||||
// Prevent conflicts with Forge's weird service loading
|
||||
exclude("META-INF/maven/**")
|
||||
exclude("META-INF/versions/**")
|
||||
}
|
||||
|
||||
reobf {
|
||||
shadowJar {}
|
||||
}
|
||||
|
||||
jar.dependsOn("shadowJar")
|
|
@ -1,7 +0,0 @@
|
|||
plugins {
|
||||
id "viaforge.forge-conventions"
|
||||
id "viaforge.conflicting-conventions"
|
||||
}
|
||||
|
||||
// Minecraft 1.17+ required Java 16/17 to compile
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
@ -1,25 +0,0 @@
|
|||
plugins {
|
||||
id "viaforge.base-conventions" // Include the base conventions, to get the dependencies
|
||||
|
||||
id "com.github.johnrengelman.shadow"
|
||||
}
|
||||
|
||||
// Define the jar output attributes for all platforms
|
||||
archivesBaseName = project.maven_name
|
||||
version = maven_version + "-" + project.mc_version
|
||||
group = maven_group
|
||||
|
||||
compileJava.options.encoding = "UTF-8"
|
||||
|
||||
// Replace the version in the mcmod.info and mods.toml files with the project version
|
||||
// Since this depends on the platform version, we can't define it in the global scope :(
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
|
||||
for (final def file in ["mcmod.info", "META-INF/mods.toml"]) {
|
||||
filesMatching(file) {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,17 +3,16 @@ org.gradle.jvmargs=-Xmx3G -XX:+UseG1GC
|
|||
org.gradle.daemon=false
|
||||
|
||||
# Project Details
|
||||
maven_name=viaforge
|
||||
maven_version=3.5.0-SNAPSHOT
|
||||
maven_version=3.6.1-SNAPSHOT
|
||||
maven_group=de.florianmichael
|
||||
|
||||
# ViaVersion
|
||||
viaversion_version=4.9.0-23w42a-SNAPSHOT
|
||||
viabackwards_version=4.9.0-23w42a-SNAPSHOT
|
||||
viarewind_version=3.0.3-SNAPSHOT
|
||||
vialegacy_version=2.2.21-SNAPSHOT
|
||||
viaaprilfools_version=2.0.10-SNAPSHOT
|
||||
vialoader_version=2.2.11-SNAPSHOT
|
||||
viaversion_version=4.10.1
|
||||
viabackwards_version=4.10.1
|
||||
viarewind_version=3.1.1
|
||||
vialegacy_version=2.2.23-SNAPSHOT
|
||||
viaaprilfools_version=2.0.13-SNAPSHOT
|
||||
vialoader_version=2.2.14-SNAPSHOT
|
||||
|
||||
snake_yml_version=2.2
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -200,13 +200,13 @@ fi
|
|||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
@ -246,4 +246,4 @@ eval "set -- $(
|
|||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
|
@ -34,7 +34,7 @@ set APP_HOME=%DIRNAME%
|
|||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
@ -89,4 +89,4 @@ exit /b %EXIT_CODE%
|
|||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:omega
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
rootProject.name = "ViaForge"
|
||||
|
||||
include "viaforge-mc112"
|
||||
include "viaforge-mc114"
|
||||
include "viaforge-mc115"
|
||||
include "viaforge-mc116"
|
||||
include "viaforge-mc117"
|
||||
include "viaforge-mc118"
|
||||
include "viaforge-mc119"
|
||||
include "viaforge-mc120"
|
||||
include "viaforge-mc1122"
|
||||
include "viaforge-mc1165"
|
||||
include "viaforge-mc1171"
|
||||
include "viaforge-mc1182"
|
||||
include "viaforge-mc1194"
|
||||
include "viaforge-mc1204"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,24 +15,24 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.common.protocolhack.ViaForgeVLInjector;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.ViaForgeVLLegacyPipeline;
|
||||
import de.florianmichael.viaforge.common.protocolhack.ViaForgeVLLoader;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLInjector;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.ViaForgeVLLoader;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.netty.ViaForgeVLLegacyPipeline;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.raphimc.vialoader.ViaLoader;
|
||||
import net.raphimc.vialoader.impl.platform.*;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -41,13 +41,15 @@ import java.io.File;
|
|||
* It is used to inject the ViaVersion pipeline into the netty pipeline. It also manages the target version.
|
||||
*/
|
||||
public class ViaForgeCommon {
|
||||
public final static AttributeKey<UserConnection> LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user");
|
||||
public final static AttributeKey<VFNetworkManager> VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup");
|
||||
|
||||
public static final AttributeKey<UserConnection> LOCAL_VIA_USER = AttributeKey.valueOf("local_via_user");
|
||||
public static final AttributeKey<VFNetworkManager> VF_NETWORK_MANAGER = AttributeKey.valueOf("encryption_setup");
|
||||
|
||||
private static ViaForgeCommon manager;
|
||||
|
||||
private final VFPlatform platform;
|
||||
private VersionEnum targetVersion;
|
||||
private ProtocolVersion targetVersion;
|
||||
private ProtocolVersion previousVersion;
|
||||
|
||||
private ViaForgeConfig config;
|
||||
|
||||
|
@ -61,11 +63,8 @@ public class ViaForgeCommon {
|
|||
* @param platform the platform fields
|
||||
*/
|
||||
public static void init(final VFPlatform platform) {
|
||||
if (manager != null) {
|
||||
return; // Already initialized, ignore it then :tm:
|
||||
}
|
||||
final VersionEnum version = VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||
if (version == VersionEnum.UNKNOWN) {
|
||||
final ProtocolVersion version = ProtocolVersion.getProtocol(platform.getGameVersion()); // ViaForge will only load on post-netty versions
|
||||
if (version == ProtocolVersion.unknown) {
|
||||
throw new IllegalArgumentException("Unknown version " + platform.getGameVersion());
|
||||
}
|
||||
|
||||
|
@ -76,8 +75,8 @@ public class ViaForgeCommon {
|
|||
ViaLoader.init(new ViaVersionPlatformImpl(mainFolder), new ViaForgeVLLoader(platform), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new);
|
||||
manager.config = new ViaForgeConfig(new File(mainFolder, "viaforge.yml"));
|
||||
|
||||
final VersionEnum configVersion = VersionEnum.fromProtocolId(manager.config.getClientSideVersion());
|
||||
if (configVersion != VersionEnum.UNKNOWN) {
|
||||
final ProtocolVersion configVersion = ProtocolVersion.getClosest(manager.config.getClientSideVersion());
|
||||
if (configVersion != null) {
|
||||
manager.setTargetVersion(configVersion);
|
||||
} else {
|
||||
manager.setTargetVersion(version);
|
||||
|
@ -90,15 +89,22 @@ public class ViaForgeCommon {
|
|||
* @param channel the channel to inject the pipeline into
|
||||
*/
|
||||
public void inject(final Channel channel, final VFNetworkManager networkManager) {
|
||||
if (channel instanceof SocketChannel) {
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
|
||||
channel.attr(LOCAL_VIA_USER).set(user);
|
||||
channel.attr(VF_NETWORK_MANAGER).set(networkManager);
|
||||
|
||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, targetVersion));
|
||||
if (networkManager.viaForge$getTrackedVersion().equals(getNativeVersion())) {
|
||||
return; // Don't inject ViaVersion into pipeline if there is nothing to translate anyway
|
||||
}
|
||||
channel.attr(VF_NETWORK_MANAGER).set(networkManager);
|
||||
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
|
||||
channel.attr(LOCAL_VIA_USER).set(user);
|
||||
|
||||
channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, targetVersion));
|
||||
channel.closeFuture().addListener(future -> {
|
||||
if (previousVersion != null) {
|
||||
restoreVersion();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,25 +118,29 @@ public class ViaForgeCommon {
|
|||
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
|
||||
}
|
||||
|
||||
public VersionEnum getNativeVersion() {
|
||||
return VersionEnum.fromProtocolId(platform.getGameVersion());
|
||||
public ProtocolVersion getNativeVersion() {
|
||||
return ProtocolVersion.getProtocol(platform.getGameVersion());
|
||||
}
|
||||
|
||||
public VersionEnum getTargetVersion() {
|
||||
public ProtocolVersion getTargetVersion() {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
public void restoreVersion() {
|
||||
this.targetVersion = VersionEnum.fromProtocolId(config.getClientSideVersion());
|
||||
this.targetVersion = ProtocolVersion.getClosest(config.getClientSideVersion());
|
||||
}
|
||||
|
||||
public void setTargetVersionSilent(final VersionEnum targetVersion) {
|
||||
public void setTargetVersionSilent(final ProtocolVersion targetVersion) {
|
||||
final ProtocolVersion oldVersion = this.targetVersion;
|
||||
this.targetVersion = targetVersion;
|
||||
if (oldVersion != targetVersion) {
|
||||
previousVersion = oldVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTargetVersion(final VersionEnum targetVersion) {
|
||||
public void setTargetVersion(final ProtocolVersion targetVersion) {
|
||||
this.targetVersion = targetVersion;
|
||||
config.setClientSideVersion(targetVersion.getVersion());
|
||||
config.setClientSideVersion(targetVersion.getName());
|
||||
}
|
||||
|
||||
public VFPlatform getPlatform() {
|
||||
|
@ -144,4 +154,5 @@ public class ViaForgeCommon {
|
|||
public static ViaForgeCommon getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,16 +15,18 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.gui;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
/**
|
||||
* This interface is used to store the target version for a specific server in the server list.
|
||||
*/
|
||||
public interface ExtendedServerData {
|
||||
|
||||
VersionEnum viaforge_getVersion();
|
||||
ProtocolVersion viaForge$getVersion();
|
||||
|
||||
void viaForge$setVersion(final ProtocolVersion version);
|
||||
|
||||
void viaforge_setVersion(final VersionEnum version);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,10 +15,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.platform;
|
||||
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -54,4 +54,5 @@ public interface VFPlatform {
|
|||
* @return the game profile fetcher of the platform for ViaLegacy
|
||||
*/
|
||||
GameProfileFetcher getGameProfileFetcher();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Dirty, but needed to store the server specific version until building the netty pipeline.
|
||||
*/
|
||||
public class VersionTracker {
|
||||
|
||||
public static final Map<InetAddress, ProtocolVersion> SERVER_PROTOCOL_VERSIONS = new HashMap<>();
|
||||
|
||||
public static void storeServerProtocolVersion(InetAddress address, ProtocolVersion version) {
|
||||
SERVER_PROTOCOL_VERSIONS.put(address, version);
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
}
|
||||
|
||||
public static ProtocolVersion getServerProtocolVersion(InetAddress address) {
|
||||
return SERVER_PROTOCOL_VERSIONS.remove(address);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,24 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
|
@ -10,18 +29,19 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class ViaForgeConfig extends Config {
|
||||
public final static String CLIENT_SIDE_VERSION = "client-side-version";
|
||||
public final static String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions";
|
||||
public final static String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication";
|
||||
public final static String SHOW_PROTOCOL_VERSION_IN_F3 = "show-protocol-version-in-f3";
|
||||
|
||||
public static final String CLIENT_SIDE_VERSION = "client-side-version";
|
||||
public static final String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions";
|
||||
public static final String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication";
|
||||
public static final String SHOW_PROTOCOL_VERSION_IN_F3 = "show-protocol-version-in-f3";
|
||||
|
||||
public final static String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button";
|
||||
public final static String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button";
|
||||
public final static String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button";
|
||||
public final static String SHOW_ADD_SERVER_BUTTON = "show-add-server-button";
|
||||
public static final String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button";
|
||||
public static final String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button";
|
||||
public static final String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button";
|
||||
public static final String SHOW_ADD_SERVER_BUTTON = "show-add-server-button";
|
||||
|
||||
public final static String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position";
|
||||
public final static String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position";
|
||||
public static final String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position";
|
||||
public static final String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position";
|
||||
|
||||
/**
|
||||
* @param configFile The location of where the config is loaded/saved.
|
||||
|
@ -51,11 +71,14 @@ public class ViaForgeConfig extends Config {
|
|||
save(); // Automatically save the config when something changes
|
||||
}
|
||||
|
||||
public int getClientSideVersion() {
|
||||
return getInt(CLIENT_SIDE_VERSION, 0);
|
||||
public String getClientSideVersion() {
|
||||
if (getInt(CLIENT_SIDE_VERSION, -1) != -1) { // Temporary fix for old configs
|
||||
return ProtocolVersion.getProtocol(getInt(CLIENT_SIDE_VERSION, -1)).getName();
|
||||
}
|
||||
return getString(CLIENT_SIDE_VERSION, "");
|
||||
}
|
||||
|
||||
public void setClientSideVersion(final int version) {
|
||||
public void setClientSideVersion(final String version) {
|
||||
set(CLIENT_SIDE_VERSION, version);
|
||||
}
|
||||
|
||||
|
@ -117,6 +140,8 @@ public class ViaForgeConfig extends Config {
|
|||
public interface PositionInvoker {
|
||||
|
||||
Pair<Integer, Integer> invoke(int width, int height);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package de.florianmichael.viaforge.common.protocolhack.netty;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public interface VFNetworkManager {
|
||||
|
||||
/**
|
||||
* API method to setup the decryption side of the pipeline.
|
||||
* This method is called by the {@link de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeEncryptionProvider} class.
|
||||
*/
|
||||
void viaforge_setupPreNettyDecryption();
|
||||
|
||||
/**
|
||||
* @return the target version of the connection
|
||||
*/
|
||||
VersionEnum viaforge_getTrackedVersion();
|
||||
|
||||
/**
|
||||
* Sets the target version of the connection.
|
||||
*
|
||||
* @param version the target version
|
||||
*/
|
||||
void viaforge_setTrackedVersion(final VersionEnum version);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
|
||||
public class DummyMovementTransmitter extends MovementTransmitterProvider {
|
||||
|
||||
@Override
|
||||
public void sendPlayer(UserConnection userConnection) {
|
||||
// We are on the client side, so we can handle the idle packet properly
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
||||
|
||||
public class ViaForgeEncryptionProvider extends EncryptionProvider {
|
||||
|
||||
@Override
|
||||
public void enableDecryption(UserConnection user) {
|
||||
user.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).getAndRemove().viaforge_setupPreNettyDecryption();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
|
||||
|
||||
public class ViaForgeOldAuthProvider extends OldAuthProvider {
|
||||
|
||||
@Override
|
||||
public void sendAuthRequest(UserConnection user, String serverId) throws Throwable {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
if (!common.getConfig().isVerifySessionInOldVersions()) {
|
||||
return;
|
||||
}
|
||||
|
||||
common.getPlatform().joinServer(serverId);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,7 +15,8 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.common.protocolhack;
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator;
|
||||
|
||||
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
|
@ -31,4 +32,5 @@ public class ViaForgeVLInjector extends VLInjector {
|
|||
public String getEncoderName() {
|
||||
return VLLegacyPipeline.VIA_ENCODER_NAME;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,14 +15,15 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.common.protocolhack;
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
import de.florianmichael.viaforge.common.protocolhack.provider.*;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.provider.*;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
||||
|
@ -44,10 +45,11 @@ public class ViaForgeVLLoader extends VLLoader {
|
|||
final ViaProviders providers = Via.getManager().getProviders();
|
||||
|
||||
providers.use(VersionProvider.class, new ViaForgeVersionProvider());
|
||||
providers.use(MovementTransmitterProvider.class, new DummyMovementTransmitter());
|
||||
providers.use(MovementTransmitterProvider.class, new ViaForgeMovementTransmitterProvider());
|
||||
providers.use(OldAuthProvider.class, new ViaForgeOldAuthProvider());
|
||||
providers.use(GameProfileFetcher.class, platform.getGameProfileFetcher());
|
||||
providers.use(EncryptionProvider.class, new ViaForgeEncryptionProvider());
|
||||
providers.use(ClassicMPPassProvider.class, new ViaForgeClassicMPPassProvider());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
public interface VFNetworkManager {
|
||||
|
||||
/**
|
||||
* API method to setup the decryption side of the pipeline.
|
||||
* This method is called by the {@link de.florianmichael.viaforge.common.protocoltranslator.provider.ViaForgeEncryptionProvider} class.
|
||||
*/
|
||||
void viaForge$setupPreNettyDecryption();
|
||||
|
||||
/**
|
||||
* @return the target version of the connection
|
||||
*/
|
||||
ProtocolVersion viaForge$getTrackedVersion();
|
||||
|
||||
/**
|
||||
* Sets the target version of the connection.
|
||||
*
|
||||
* @param version the target version
|
||||
*/
|
||||
void viaForge$setTrackedVersion(final ProtocolVersion version);
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,15 +15,16 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.common.protocolhack.netty;
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
||||
|
||||
public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
||||
public ViaForgeVLLegacyPipeline(UserConnection user, ProtocolVersion version) {
|
||||
super(user, version);
|
||||
}
|
||||
|
||||
|
@ -56,4 +57,5 @@ public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
|
|||
protected String lengthPrependerName() {
|
||||
return "prepender";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,22 @@
|
|||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
@ -66,4 +84,5 @@ public class ViaForgeClassicMPPassProvider extends ClassicMPPassProvider {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
||||
|
||||
public class ViaForgeEncryptionProvider extends EncryptionProvider {
|
||||
|
||||
@Override
|
||||
public void enableDecryption(UserConnection user) {
|
||||
user.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).getAndRemove().viaForge$setupPreNettyDecryption();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
|
||||
public class ViaForgeMovementTransmitterProvider extends MovementTransmitterProvider {
|
||||
|
||||
@Override
|
||||
public void sendPlayer(UserConnection userConnection) {
|
||||
// We are on the client side, so we can handle the idle packet properly
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
|
||||
|
||||
public class ViaForgeOldAuthProvider extends OldAuthProvider {
|
||||
|
||||
@Override
|
||||
public void sendAuthRequest(UserConnection user, String serverId) throws Throwable {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
if (!common.getConfig().isVerifySessionInOldVersions()) {
|
||||
return;
|
||||
}
|
||||
common.getPlatform().joinServer(serverId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,26 +15,22 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.common.protocolhack.provider;
|
||||
|
||||
package de.florianmichael.viaforge.common.protocoltranslator.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ViaForgeVersionProvider extends BaseVersionProvider {
|
||||
|
||||
@Override
|
||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
if (connection.isClientSide() && !ViaForgeCommon.getManager().getPlatform().isSingleplayer().get()) {
|
||||
try {
|
||||
System.out.println(connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaforge_getTrackedVersion().getVersion();
|
||||
return connection.getChannel().attr(ViaForgeCommon.VF_NETWORK_MANAGER).get().viaForge$getTrackedVersion();
|
||||
}
|
||||
|
||||
return super.getClosestServerProtocol(connection);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
|
@ -1,2 +0,0 @@
|
|||
maven_name=viaforge-mc112
|
||||
mc_version=1.12.2
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.multiplayer.GuiConnecting$1")
|
||||
public class MixinGuiConnecting_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;createNetworkManagerAndConnect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getMinecraft().getCurrentServerData() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
}
|
||||
|
||||
return NetworkManager.createNetworkManagerAndConnect(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.GuiOverlayDebug;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GuiOverlayDebug.class)
|
||||
public class MixinGuiOverlayDebug {
|
||||
|
||||
@Inject(method = "getDebugInfoRight", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
}
|
||||
|
||||
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerData.class)
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_version;
|
||||
|
||||
@Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<NBTTagCompound> cir, NBTTagCompound nbttagcompound) {
|
||||
if (viaforge_version != null) {
|
||||
nbttagcompound.setInteger("viaforge_version", viaforge_version.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL"))
|
||||
private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (nbtCompound.hasKey("viaforge_version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(nbtCompound.getInteger("viaforge_version")));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("HEAD"))
|
||||
public void track(ServerData serverDataIn, CallbackInfo ci) {
|
||||
if (serverDataIn instanceof ExtendedServerData) {
|
||||
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getVersion() {
|
||||
return viaforge_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setVersion(VersionEnum version) {
|
||||
viaforge_version = version;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(ServerPinger.class)
|
||||
public class MixinServerPinger {
|
||||
|
||||
@Unique
|
||||
private ServerData viaforge_serverData;
|
||||
|
||||
@Inject(method = "ping", at = @At("HEAD"))
|
||||
public void trackServerData(ServerData server, CallbackInfo ci) {
|
||||
viaforge_serverData = server;
|
||||
}
|
||||
|
||||
@Redirect(method = "ping", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;createNetworkManagerAndConnect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaforge_serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
viaforge_serverData = null;
|
||||
}
|
||||
|
||||
return NetworkManager.createNetworkManagerAndConnect(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
plugins {
|
||||
id "viaforge.forge-conventions"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: "stable", version: "39-1.12"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
maven_name=viaforge-mc1122
|
||||
mc_version=1.12.2
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,22 +15,29 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.realms.RealmsSharedConstants;
|
||||
import net.minecraft.util.Session;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod(modid = "viaforge")
|
||||
public class ViaForge112 implements VFPlatform {
|
||||
public final static ViaForge112 PLATFORM = new ViaForge112();
|
||||
@Mod(modid = "viaforge", name = "ViaForge", acceptableRemoteVersions = "*", clientSideOnly=true, useMetadata=true)
|
||||
public class ViaForge1122 implements VFPlatform {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onInit(FMLInitializationEvent event) {
|
||||
ViaForgeCommon.init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGameVersion() {
|
||||
|
@ -58,4 +65,5 @@ public class ViaForge112 implements VFPlatform {
|
|||
public GameProfileFetcher getGameProfileFetcher() {
|
||||
return new ViaForgeGameProfileFetcher();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,17 +15,19 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.gui;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.DumpUtil;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSlot;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.ProtocolVersionList;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -132,12 +134,12 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return VersionEnum.SORTED_VERSIONS.size();
|
||||
return ProtocolVersionList.getProtocolsNewToOld().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int index, boolean b, int i1, int i2) {
|
||||
finishedCallback.finished(VersionEnum.SORTED_VERSIONS.get(index), parent);
|
||||
finishedCallback.finished(ProtocolVersionList.getProtocolsNewToOld().get(index), parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,8 +154,8 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||
|
||||
@Override
|
||||
protected void drawSlot(int index, int x, int y, int slotHeight, int mouseX, int mouseY, float partialTicks) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(index);
|
||||
final ProtocolVersion targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
final ProtocolVersion version = ProtocolVersionList.getProtocolsNewToOld().get(index);
|
||||
|
||||
String color;
|
||||
if (targetVersion == version) {
|
||||
|
@ -168,6 +170,7 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final GuiScreen parent);
|
||||
void finished(final ProtocolVersion version, final GuiScreen parent);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,6 +15,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
@ -28,7 +29,7 @@ public class MixinLoader implements IFMLLoadingPlugin {
|
|||
|
||||
public MixinLoader() {
|
||||
MixinBootstrap.init();
|
||||
Mixins.addConfiguration("mixins.viaforge-mc112.json");
|
||||
Mixins.addConfiguration("mixins.viaforge-mc1122.json");
|
||||
MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
|
||||
}
|
||||
|
||||
|
@ -55,4 +56,5 @@ public class MixinLoader implements IFMLLoadingPlugin {
|
|||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,14 +15,16 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.ViaForge112;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -33,8 +35,6 @@ public class MixinGuiMainMenu extends GuiScreen {
|
|||
|
||||
@Inject(method = "initGui", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
ViaForgeCommon.init(ViaForge112.PLATFORM);
|
||||
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowMainMenuButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
@ -51,4 +51,5 @@ public class MixinGuiMainMenu extends GuiScreen {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,6 +15,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
@ -50,4 +51,5 @@ public class MixinGuiMultiplayer extends GuiScreen {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.GuiOverlayDebug;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GuiOverlayDebug.class)
|
||||
public class MixinGuiOverlayDebug {
|
||||
|
||||
@Inject(method = "getDebugInfoRight", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final ProtocolVersion version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
cir.getReturnValue().add("ViaForge: " + version.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,8 +15,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
|
@ -26,7 +28,6 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenAddServer;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -46,7 +47,7 @@ public class MixinGuiScreenAddServer extends GuiScreen {
|
|||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion();
|
||||
final ProtocolVersion target = ((ExtendedServerData) serverData).viaForge$getVersion();
|
||||
buttonList.add(new GuiButton(1_000_000_000, pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version"));
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +58,11 @@ public class MixinGuiScreenAddServer extends GuiScreen {
|
|||
if (button.id == 1_000_000_000) {
|
||||
mc.displayGuiScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
((ExtendedServerData) serverData).viaforge_setVersion(version);
|
||||
((ExtendedServerData) serverData).viaForge$setVersion(version);
|
||||
mc.displayGuiScreen(parent);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,6 +15,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
@ -50,4 +51,5 @@ public class MixinGuiScreenServerList extends GuiScreen {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerData.class)
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private ProtocolVersion viaForge$version;
|
||||
|
||||
@Inject(method = "getNBTCompound", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<NBTTagCompound> cir, NBTTagCompound nbttagcompound) {
|
||||
if (viaForge$version != null) {
|
||||
nbttagcompound.setString("viaForge$version", viaForge$version.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getServerDataFromNBTCompound", at = @At(value = "TAIL"))
|
||||
private static void getVersion(NBTTagCompound nbtCompound, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (nbtCompound.hasKey("viaForge$version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaForge$setVersion(ProtocolVersion.getClosest(nbtCompound.getString("viaForge$version")));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("HEAD"))
|
||||
public void track(ServerData serverDataIn, CallbackInfo ci) {
|
||||
if (serverDataIn instanceof ExtendedServerData) {
|
||||
viaForge$version = ((ExtendedServerData) serverDataIn).viaForge$getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolVersion viaForge$getVersion() {
|
||||
return viaForge$version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaForge$setVersion(ProtocolVersion version) {
|
||||
viaForge$version = version;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.connect;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import de.florianmichael.viaforge.common.platform.VersionTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.multiplayer.GuiConnecting$1")
|
||||
public class MixinGuiConnecting_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
|
||||
public InetAddress trackServerVersion(String s) throws UnknownHostException {
|
||||
final InetAddress address = InetAddress.getByName(s);
|
||||
ProtocolVersion version = ((ExtendedServerData) Minecraft.getMinecraft().getCurrentServerData()).viaForge$getVersion();
|
||||
if (version == null) {
|
||||
version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
}
|
||||
VersionTracker.storeServerProtocolVersion(address, version);
|
||||
return address;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,33 @@
|
|||
package de.florianmichael.viaforge.mixin.impl;
|
||||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.connect;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
|
||||
import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -23,7 +42,8 @@ public class MixinNetHandlerLoginClient {
|
|||
|
||||
@Redirect(method = "handleEncryptionRequest", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
final VFNetworkManager mixinNetworkManager = (VFNetworkManager) networkManager;
|
||||
if (mixinNetworkManager.viaForge$getTrackedVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
final UserConnection user = networkManager.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
|
@ -34,4 +54,5 @@ public class MixinNetHandlerLoginClient {
|
|||
}
|
||||
instance.joinServer(profile, authenticationToken, serverId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,19 +15,21 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.connect;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||
import de.florianmichael.viaforge.common.platform.VersionTracker;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.NettyEncryptingDecoder;
|
||||
import net.minecraft.network.NettyEncryptingEncoder;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.LazyLoadBase;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
@ -46,61 +48,55 @@ public class MixinNetworkManager implements VFNetworkManager {
|
|||
|
||||
@Shadow private Channel channel;
|
||||
|
||||
@Shadow private boolean isEncrypted;
|
||||
@Unique
|
||||
private Cipher viaforge_decryptionCipher;
|
||||
private Cipher viaForge$decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_targetVersion;
|
||||
|
||||
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
||||
// The connecting screen and server pinger are setting the main target version when a specific version for a server is set,
|
||||
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
|
||||
// but for the server pinger we need to store the target version and force the pinging to use the target version.
|
||||
// Due to the fact that the server pinger is being called multiple times.
|
||||
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
|
||||
}
|
||||
|
||||
@Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
|
||||
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
|
||||
// tells us to do, therefore we need to store the cipher instance.
|
||||
this.viaforge_decryptionCipher = CryptManager.createNetCipherInstance(2, key);
|
||||
|
||||
// Enabling the encryption side
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key)));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "closeChannel", at = @At("HEAD"))
|
||||
public void restoreTargetVersion(ITextComponent message, CallbackInfo ci) {
|
||||
// If the previous server forced a version, we need to restore the version to the default one.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
private ProtocolVersion viaForge$targetVersion;
|
||||
|
||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||
}
|
||||
|
||||
@Inject(method = "enableEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) {
|
||||
if (viaForge$targetVersion != null && viaForge$targetVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
// Minecraft 1.6.4 supports tile encryption which means the server can only enable one side of the encryption
|
||||
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
|
||||
// tells us to do, therefore we need to store the cipher instance.
|
||||
this.viaForge$decryptionCipher = CryptManager.createNetCipherInstance(2, key);
|
||||
|
||||
// Enabling the encryption side
|
||||
this.isEncrypted = true;
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key)));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void setTargetVersion(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
||||
final VFNetworkManager mixinNetworkManager = (VFNetworkManager) networkmanager;
|
||||
mixinNetworkManager.viaForge$setTrackedVersion(VersionTracker.getServerProtocolVersion(address));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setupPreNettyDecryption() {
|
||||
public void viaForge$setupPreNettyDecryption() {
|
||||
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher));
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaForge$decryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getTrackedVersion() {
|
||||
return viaforge_targetVersion;
|
||||
public ProtocolVersion viaForge$getTrackedVersion() {
|
||||
return viaForge$targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setTrackedVersion(VersionEnum version) {
|
||||
viaforge_targetVersion = version;
|
||||
public void viaForge$setTrackedVersion(ProtocolVersion version) {
|
||||
viaForge$targetVersion = version;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -15,10 +15,11 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin.impl;
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.connect;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||
import de.florianmichael.viaforge.common.protocoltranslator.netty.VFNetworkManager;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
|
@ -34,7 +35,8 @@ public class MixinNetworkManager_5 {
|
|||
NetworkManager val$networkmanager;
|
||||
|
||||
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
|
||||
private void onInitChannel(Channel channel, CallbackInfo ci) {
|
||||
private void hookViaPipeline(Channel channel, CallbackInfo ci) {
|
||||
ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.connect;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import de.florianmichael.viaforge.common.platform.VersionTracker;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(ServerPinger.class)
|
||||
public class MixinServerPinger {
|
||||
|
||||
@Unique
|
||||
private ServerData viaForge$serverData;
|
||||
|
||||
@Inject(method = "ping", at = @At("HEAD"))
|
||||
public void trackServerData(ServerData server, CallbackInfo ci) {
|
||||
viaForge$serverData = server;
|
||||
}
|
||||
|
||||
@Redirect(method = "ping", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;createNetworkManagerAndConnect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
ProtocolVersion version = ((ExtendedServerData) viaForge$serverData).viaForge$getVersion();
|
||||
if (version == null) {
|
||||
version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
}
|
||||
VersionTracker.storeServerProtocolVersion(address, version);
|
||||
viaForge$serverData = null;
|
||||
|
||||
return NetworkManager.createNetworkManagerAndConnect(address, i, b);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,29 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.mixin.impl.fixes;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -22,7 +40,7 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
|||
|
||||
@Redirect(method = "onUpdateWalkingPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/EntityPlayerSP;prevOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(EntityPlayerSP instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
|
@ -34,4 +52,5 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
|||
}
|
||||
return prevOnGround;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viaforge.provider;
|
||||
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.HttpAuthenticationService;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.ProfileNotFoundException;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ViaForgeGameProfileFetcher extends GameProfileFetcher {
|
||||
|
||||
public static final HttpAuthenticationService AUTHENTICATION_SERVICE = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
|
||||
public static final MinecraftSessionService SESSION_SERVICE = AUTHENTICATION_SERVICE.createMinecraftSessionService();
|
||||
public static final GameProfileRepository GAME_PROFILE_REPOSITORY = AUTHENTICATION_SERVICE.createProfileRepository();
|
||||
|
||||
@Override
|
||||
public UUID loadMojangUUID(String playerName) throws Exception {
|
||||
final CompletableFuture<com.mojang.authlib.GameProfile> future = new CompletableFuture<>();
|
||||
GAME_PROFILE_REPOSITORY.findProfilesByNames(new String[]{playerName}, Agent.MINECRAFT, new ProfileLookupCallback() {
|
||||
@Override
|
||||
public void onProfileLookupSucceeded(com.mojang.authlib.GameProfile profile) {
|
||||
future.complete(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileLookupFailed(com.mojang.authlib.GameProfile profile, Exception exception) {
|
||||
future.completeExceptionally(exception);
|
||||
}
|
||||
});
|
||||
if (!future.isDone()) {
|
||||
future.completeExceptionally(new ProfileNotFoundException());
|
||||
}
|
||||
return future.get().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile loadGameProfile(UUID uuid) {
|
||||
final com.mojang.authlib.GameProfile inProfile = new com.mojang.authlib.GameProfile(uuid, null);
|
||||
final com.mojang.authlib.GameProfile mojangProfile = SESSION_SERVICE.fillProfileProperties(inProfile, true);
|
||||
if (mojangProfile.equals(inProfile)) throw new ProfileNotFoundException();
|
||||
|
||||
final GameProfile gameProfile = new GameProfile(mojangProfile.getName(), mojangProfile.getId());
|
||||
for (final java.util.Map.Entry<String, Property> entry : mojangProfile.getProperties().entries()) {
|
||||
final Property prop = entry.getValue();
|
||||
gameProfile.addProperty(new GameProfile.Property(prop.getName(), prop.getValue(), prop.getSignature()));
|
||||
}
|
||||
|
||||
return gameProfile;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,15 +4,12 @@
|
|||
"name": "ViaForge",
|
||||
"description": "Client-side Implementation of the Via* projects for Minecraft Forge",
|
||||
"version": "${version}",
|
||||
"mcversion": "[1.12.2]",
|
||||
"mcversion": "[1.12,)",
|
||||
"url": "https://github.com/ViaVersion/ViaForge",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"FlorianMichael/EnZaXD"
|
||||
],
|
||||
"credits": "https://github.com/FlorianMichael/",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
"logoFile": "icon.png"
|
||||
}
|
||||
]
|
|
@ -3,19 +3,19 @@
|
|||
"minVersion": "0.7.5",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"package": "de.florianmichael.viaforge.mixin.impl",
|
||||
"refmap": "mixins.viaforge-mc112.refmap.json",
|
||||
"refmap": "mixins.viaforge-mc1122.refmap.json",
|
||||
"client": [
|
||||
"MixinGuiConnecting_1",
|
||||
"connect.MixinGuiConnecting_1",
|
||||
"MixinGuiMainMenu",
|
||||
"MixinGuiMultiplayer",
|
||||
"MixinGuiOverlayDebug",
|
||||
"MixinGuiScreenAddServer",
|
||||
"MixinGuiScreenServerList",
|
||||
"MixinNetHandlerLoginClient",
|
||||
"MixinNetworkManager",
|
||||
"MixinNetworkManager_5",
|
||||
"connect.MixinNetHandlerLoginClient",
|
||||
"connect.MixinNetworkManager",
|
||||
"connect.MixinNetworkManager_5",
|
||||
"MixinServerData",
|
||||
"MixinServerPinger",
|
||||
"connect.MixinServerPinger",
|
||||
"fixes.MixinEntityPlayerSP"
|
||||
],
|
||||
"verbose": true
|
|
@ -1,11 +0,0 @@
|
|||
plugins {
|
||||
id "viaforge.forge-conventions"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: "official", version: "1.14.4"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:1.14.4-28.2.26"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
maven_name=viaforge-mc114
|
||||
mc_version=1.14.4
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge;
|
||||
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Session;
|
||||
import net.minecraft.util.SharedConstants;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod("viaforge")
|
||||
public class ViaForge114 implements VFPlatform {
|
||||
public final static ViaForge114 PLATFORM = new ViaForge114();
|
||||
|
||||
@Override
|
||||
public int getGameVersion() {
|
||||
return SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Boolean> isSingleplayer() {
|
||||
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLeadingDirectory() {
|
||||
return Minecraft.getInstance().gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinServer(String serverId) throws Throwable {
|
||||
final Session session = Minecraft.getInstance().getUser();
|
||||
|
||||
Minecraft.getInstance().getMinecraftSessionService().joinServer(session.getGameProfile(), session.getAccessToken(), serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileFetcher getGameProfileFetcher() {
|
||||
return new ViaForgeGameProfileFetcher();
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.gui;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.util.DumpUtil;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.widget.list.AbstractList;
|
||||
import net.minecraft.client.gui.widget.list.ExtendedList;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class GuiProtocolSelector extends Screen {
|
||||
|
||||
public final Screen parent;
|
||||
public final boolean simple;
|
||||
public final FinishedCallback finishedCallback;
|
||||
|
||||
private SlotList list;
|
||||
|
||||
private String status;
|
||||
private long time;
|
||||
|
||||
public static void open(final Minecraft minecraft) { // Bypass for some weird bytecode instructions errors in Forge
|
||||
minecraft.setScreen(new GuiProtocolSelector(minecraft.screen));
|
||||
}
|
||||
|
||||
public GuiProtocolSelector(final Screen parent) {
|
||||
this(parent, false, (version, unused) -> {
|
||||
// Default action is to set the target version and go back to the parent screen.
|
||||
ViaForgeCommon.getManager().setTargetVersion(version);
|
||||
});
|
||||
}
|
||||
|
||||
public GuiProtocolSelector(final Screen parent, final boolean simple, final FinishedCallback finishedCallback) {
|
||||
super(new StringTextComponent("ViaForge Protocol Selector"));
|
||||
this.parent = parent;
|
||||
this.simple = simple;
|
||||
this.finishedCallback = finishedCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
addButton(new Button(5, height - 25, 20, 20, "<-", b -> minecraft.setScreen(parent)));
|
||||
if (!this.simple) {
|
||||
addButton(new Button(width - 105, 5, 100, 20, "Create dump", b -> {
|
||||
try {
|
||||
minecraft.keyboardHandler.setClipboard(DumpUtil.postDump(UUID.randomUUID()).get());
|
||||
setStatus(ChatFormatting.GREEN + "Dump created and copied to clipboard");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
setStatus(ChatFormatting.RED + "Failed to create dump: " + e.getMessage());
|
||||
}
|
||||
}));
|
||||
addButton(new Button(width - 105, height - 25, 100, 20, "Reload configs", b -> Via.getManager().getConfigurationProvider().reloadConfigs()));
|
||||
}
|
||||
|
||||
list = new SlotList(minecraft, width, height, 3 + 3 /* start offset */ + (font.lineHeight + 2) * 3 /* title is 2 */, height - 30, font.lineHeight + 2);
|
||||
}
|
||||
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int actions) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ESCAPE) {
|
||||
minecraft.setScreen(parent);
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) {
|
||||
if (System.currentTimeMillis() - this.time >= 10_000) {
|
||||
this.status = null;
|
||||
}
|
||||
|
||||
renderBackground();
|
||||
this.list.render(p_230430_2_, p_230430_3_, p_230430_4_);
|
||||
|
||||
super.render(p_230430_2_, p_230430_3_, p_230430_4_);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2.0F, 2.0F, 2.0F);
|
||||
drawCenteredString(font, ChatFormatting.GOLD + "ViaForge", width / 4, 3, 16777215);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
drawCenteredString(font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1);
|
||||
drawString(font, status != null ? status : "Discord: florianmichael", 3, 3, -1);
|
||||
}
|
||||
|
||||
class SlotList extends ExtendedList<SlotList.SlotEntry> {
|
||||
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends AbstractList.AbstractListEntry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int p_230432_2_, int y, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.AddServerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(AddServerScreen.class)
|
||||
public class MixinAddServerScreen extends Screen {
|
||||
|
||||
@Shadow @Final private ServerData serverData;
|
||||
|
||||
public MixinAddServerScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void initGui(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion();
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
((ExtendedServerData) serverData).viaforge_setVersion(version);
|
||||
minecraft.setScreen(parent);
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.network.login.ClientLoginNetHandler;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(ClientLoginNetHandler.class)
|
||||
public class MixinClientLoginNetHandler {
|
||||
|
||||
@Shadow @Final private NetworkManager connection;
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
// if the server is in offline mode, due the packet changes <-> networking changes
|
||||
// Minecraft's networking code is bad for us.
|
||||
return;
|
||||
}
|
||||
}
|
||||
instance.joinServer(profile, authenticationToken, serverId);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectingScreen$1")
|
||||
public class MixinConnectingScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.overlay.DebugOverlayGui;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugOverlayGui.class)
|
||||
public class MixinDebugOverlayGui {
|
||||
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
}
|
||||
|
||||
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.ViaForge114;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MainMenuScreen.class)
|
||||
public class MixinMainMenuScreen extends Screen {
|
||||
|
||||
public MixinMainMenuScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
ViaForgeCommon.init(ViaForge114.PLATFORM);
|
||||
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowMainMenuButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public class MixinMultiplayerScreen extends Screen {
|
||||
|
||||
public MixinMultiplayerScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowMainMenuButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.NettyEncryptingDecoder;
|
||||
import net.minecraft.network.NettyEncryptingEncoder;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.LazyLoadBase;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(NetworkManager.class)
|
||||
public class MixinNetworkManager implements VFNetworkManager {
|
||||
|
||||
@Shadow private Channel channel;
|
||||
|
||||
@Unique
|
||||
private Cipher viaforge_decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
||||
// The connecting screen and server pinger are setting the main target version when a specific version for a server is set,
|
||||
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
|
||||
// but for the server pinger we need to store the target version and force the pinging to use the target version.
|
||||
// Due to the fact that the server pinger is being called multiple times.
|
||||
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
|
||||
}
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
|
||||
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
|
||||
// tells us to do, therefore we need to store the cipher instance.
|
||||
this.viaforge_decryptionCipher = CryptManager.getCipher(2, key);
|
||||
|
||||
// Enabling the encryption side
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key)));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "disconnect", at = @At("HEAD"))
|
||||
public void restoreTargetVersion(ITextComponent p_150718_1_, CallbackInfo ci) {
|
||||
// If the previous server forced a version, we need to restore the version to the default one.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setupPreNettyDecryption() {
|
||||
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getTrackedVersion() {
|
||||
return viaforge_targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setTrackedVersion(VersionEnum version) {
|
||||
viaforge_targetVersion = version;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerData.class)
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
|
||||
if (viaforge_version != null) {
|
||||
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaforge_version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version")));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("HEAD"))
|
||||
public void track(ServerData serverDataIn, CallbackInfo ci) {
|
||||
if (serverDataIn instanceof ExtendedServerData) {
|
||||
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getVersion() {
|
||||
return viaforge_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setVersion(VersionEnum version) {
|
||||
viaforge_version = version;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ServerListScreen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerListScreen.class)
|
||||
public class MixinServerListScreen extends Screen {
|
||||
|
||||
public MixinServerListScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowDirectConnectButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(ServerPinger.class)
|
||||
public class MixinServerPinger {
|
||||
|
||||
@Unique
|
||||
private ServerData viaforge_serverData;
|
||||
|
||||
@Inject(method = "pingServer", at = @At("HEAD"))
|
||||
public void trackServerData(ServerData server, CallbackInfo ci) {
|
||||
viaforge_serverData = server;
|
||||
}
|
||||
|
||||
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaforge_serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
viaforge_serverData = null;
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.7.5",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"package": "de.florianmichael.viaforge.mixin",
|
||||
"client": [
|
||||
"MixinAddServerScreen",
|
||||
"MixinClientLoginNetHandler",
|
||||
"MixinConnectingScreen_1",
|
||||
"MixinDebugOverlayGui",
|
||||
"MixinMainMenuScreen",
|
||||
"MixinMultiplayerScreen",
|
||||
"MixinNetworkManager",
|
||||
"MixinNetworkManager_1",
|
||||
"MixinServerData",
|
||||
"MixinServerListScreen",
|
||||
"MixinServerPinger",
|
||||
"fixes.MixinClientPlayerEntity"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "mixins.viaforge-mc114.refmap.json",
|
||||
"mixins": [
|
||||
"MixinNetworkManager_1"
|
||||
]
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
plugins {
|
||||
id "viaforge.forge-conventions"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: "official", version: "1.15.2"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:1.15.2-31.2.57"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
maven_name=viaforge-mc115
|
||||
mc_version=1.15.2
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge;
|
||||
|
||||
import de.florianmichael.viaforge.common.platform.VFPlatform;
|
||||
import de.florianmichael.viaforge.provider.ViaForgeGameProfileFetcher;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Session;
|
||||
import net.minecraft.util.SharedConstants;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod("viaforge")
|
||||
public class ViaForge115 implements VFPlatform {
|
||||
|
||||
public final static ViaForge115 PLATFORM = new ViaForge115();
|
||||
|
||||
@Override
|
||||
public int getGameVersion() {
|
||||
return SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Boolean> isSingleplayer() {
|
||||
return () -> Minecraft.getInstance().hasSingleplayerServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLeadingDirectory() {
|
||||
return Minecraft.getInstance().gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinServer(String serverId) throws Throwable {
|
||||
final Session session = Minecraft.getInstance().getUser();
|
||||
|
||||
Minecraft.getInstance().getMinecraftSessionService().joinServer(session.getGameProfile(), session.getAccessToken(), serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileFetcher getGameProfileFetcher() {
|
||||
return new ViaForgeGameProfileFetcher();
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.gui;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.util.DumpUtil;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.widget.list.AbstractList;
|
||||
import net.minecraft.client.gui.widget.list.ExtendedList;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class GuiProtocolSelector extends Screen {
|
||||
|
||||
public final Screen parent;
|
||||
public final boolean simple;
|
||||
public final FinishedCallback finishedCallback;
|
||||
|
||||
private SlotList list;
|
||||
|
||||
private String status;
|
||||
private long time;
|
||||
|
||||
public static void open(final Minecraft minecraft) { // Bypass for some weird bytecode instructions errors in Forge
|
||||
minecraft.setScreen(new GuiProtocolSelector(minecraft.screen));
|
||||
}
|
||||
|
||||
public GuiProtocolSelector(final Screen parent) {
|
||||
this(parent, false, (version, unused) -> {
|
||||
// Default action is to set the target version and go back to the parent screen.
|
||||
ViaForgeCommon.getManager().setTargetVersion(version);
|
||||
});
|
||||
}
|
||||
|
||||
public GuiProtocolSelector(final Screen parent, final boolean simple, final FinishedCallback finishedCallback) {
|
||||
super(new StringTextComponent("ViaForge Protocol Selector"));
|
||||
this.parent = parent;
|
||||
this.simple = simple;
|
||||
this.finishedCallback = finishedCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
addButton(new Button(5, height - 25, 20, 20, "<-", b -> minecraft.setScreen(parent)));
|
||||
if (!this.simple) {
|
||||
addButton(new Button(width - 105, 5, 100, 20, "Create dump", b -> {
|
||||
try {
|
||||
minecraft.keyboardHandler.setClipboard(DumpUtil.postDump(UUID.randomUUID()).get());
|
||||
setStatus(ChatFormatting.GREEN + "Dump created and copied to clipboard");
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
setStatus(ChatFormatting.RED + "Failed to create dump: " + e.getMessage());
|
||||
}
|
||||
}));
|
||||
addButton(new Button(width - 105, height - 25, 100, 20, "Reload configs", b -> Via.getManager().getConfigurationProvider().reloadConfigs()));
|
||||
}
|
||||
|
||||
list = new SlotList(minecraft, width, height, 3 + 3 /* start offset */ + (font.lineHeight + 2) * 3 /* title is 2 */, height - 30, font.lineHeight + 2);
|
||||
}
|
||||
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int actions) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ESCAPE) {
|
||||
minecraft.setScreen(parent);
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) {
|
||||
if (System.currentTimeMillis() - this.time >= 10_000) {
|
||||
this.status = null;
|
||||
}
|
||||
|
||||
renderBackground();
|
||||
this.list.render(p_230430_2_, p_230430_3_, p_230430_4_);
|
||||
|
||||
super.render(p_230430_2_, p_230430_3_, p_230430_4_);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2.0F, 2.0F, 2.0F);
|
||||
drawCenteredString(font, ChatFormatting.GOLD + "ViaForge", width / 4, 3, 16777215);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
drawCenteredString(font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1);
|
||||
drawString(font, status != null ? status : "Discord: florianmichael", 3, 3, -1);
|
||||
}
|
||||
|
||||
class SlotList extends ExtendedList<SlotList.SlotEntry> {
|
||||
|
||||
public SlotList(Minecraft client, int width, int height, int top, int bottom, int slotHeight) {
|
||||
super(client, width, height, top, bottom, slotHeight);
|
||||
|
||||
for (VersionEnum version : VersionEnum.SORTED_VERSIONS) {
|
||||
addEntry(new SlotEntry(version));
|
||||
}
|
||||
}
|
||||
|
||||
public class SlotEntry extends AbstractList.AbstractListEntry<SlotEntry> {
|
||||
|
||||
private final VersionEnum versionEnum;
|
||||
|
||||
public SlotEntry(VersionEnum versionEnum) {
|
||||
this.versionEnum = versionEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
GuiProtocolSelector.this.finishedCallback.finished(versionEnum, GuiProtocolSelector.this.parent);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int p_230432_2_, int y, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
|
||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
String color;
|
||||
if (targetVersion == versionEnum) {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||
} else {
|
||||
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||
}
|
||||
|
||||
drawCenteredString(Minecraft.getInstance().font, color + versionEnum.getName(), width / 2, y, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface FinishedCallback {
|
||||
|
||||
void finished(final VersionEnum version, final Screen parent);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.AddServerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(AddServerScreen.class)
|
||||
public class MixinAddServerScreen extends Screen {
|
||||
|
||||
@Shadow @Final private ServerData serverData;
|
||||
|
||||
public MixinAddServerScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void initGui(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
|
||||
if (config.isShowAddServerButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getAddServerScreenButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
final VersionEnum target = ((ExtendedServerData) serverData).viaforge_getVersion();
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, target != null ? target.getName() : "Set Version", b -> {
|
||||
minecraft.setScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||
// Set version and go back to the parent screen.
|
||||
((ExtendedServerData) serverData).viaforge_setVersion(version);
|
||||
minecraft.setScreen(parent);
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectingScreen$1")
|
||||
public class MixinConnectingScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.overlay.DebugOverlayGui;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugOverlayGui.class)
|
||||
public class MixinDebugOverlayGui {
|
||||
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
}
|
||||
|
||||
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.ViaForge115;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MainMenuScreen.class)
|
||||
public class MixinMainMenuScreen extends Screen {
|
||||
|
||||
public MixinMainMenuScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
ViaForgeCommon.init(ViaForge115.PLATFORM);
|
||||
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowMainMenuButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public class MixinMultiplayerScreen extends Screen {
|
||||
|
||||
public MixinMultiplayerScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowMainMenuButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||
import io.netty.channel.Channel;
|
||||
import net.minecraft.network.NettyEncryptingDecoder;
|
||||
import net.minecraft.network.NettyEncryptingEncoder;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.util.CryptManager;
|
||||
import net.minecraft.util.LazyValue;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(NetworkManager.class)
|
||||
public class MixinNetworkManager implements VFNetworkManager {
|
||||
|
||||
@Shadow private Channel channel;
|
||||
|
||||
@Unique
|
||||
private Cipher viaforge_decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_targetVersion;
|
||||
|
||||
@Inject(method = "connectToServer", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void trackSelfTarget(InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyValue lazyvalue) {
|
||||
// The connecting screen and server pinger are setting the main target version when a specific version for a server is set,
|
||||
// This works for joining perfect since we can simply restore the version when the server doesn't have a specific one set,
|
||||
// but for the server pinger we need to store the target version and force the pinging to use the target version.
|
||||
// Due to the fact that the server pinger is being called multiple times.
|
||||
((VFNetworkManager) networkmanager).viaforge_setTrackedVersion(ViaForgeCommon.getManager().getTargetVersion());
|
||||
}
|
||||
|
||||
@Inject(method = "setEncryptionKey", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(SecretKey key, CallbackInfo ci) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
|
||||
ci.cancel();
|
||||
|
||||
// Minecraft 1.6.4 supports tile encryption which means the server can only disable one side of the encryption
|
||||
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
|
||||
// tells us to do, therefore we need to store the cipher instance.
|
||||
this.viaforge_decryptionCipher = CryptManager.getCipher(2, key);
|
||||
|
||||
// Enabling the encryption side
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new NettyEncryptingEncoder(CryptManager.getCipher(1, key)));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "disconnect", at = @At("HEAD"))
|
||||
public void restoreTargetVersion(ITextComponent p_150718_1_, CallbackInfo ci) {
|
||||
// If the previous server forced a version, we need to restore the version to the default one.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
@Inject(method = "setupCompression", at = @At("RETURN"))
|
||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setupPreNettyDecryption() {
|
||||
// Enabling the decryption side for 1.6.4 if the 1.7 -> 1.6 protocol tells us to do
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getTrackedVersion() {
|
||||
return viaforge_targetVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setTrackedVersion(VersionEnum version) {
|
||||
viaforge_targetVersion = version;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerData.class)
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
|
||||
if (viaforge_version != null) {
|
||||
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaforge_version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version")));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("HEAD"))
|
||||
public void track(ServerData serverDataIn, CallbackInfo ci) {
|
||||
if (serverDataIn instanceof ExtendedServerData) {
|
||||
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getVersion() {
|
||||
return viaforge_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setVersion(VersionEnum version) {
|
||||
viaforge_version = version;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of ViaForge - https://github.com/FlorianMichael/ViaForge
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.platform.ViaForgeConfig;
|
||||
import de.florianmichael.viaforge.gui.GuiProtocolSelector;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ServerListScreen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerListScreen.class)
|
||||
public class MixinServerListScreen extends Screen {
|
||||
|
||||
public MixinServerListScreen(ITextComponent title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void hookViaForgeButton(CallbackInfo ci) {
|
||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||
if (config.isShowDirectConnectButton()) {
|
||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||
|
||||
addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(ServerPinger.class)
|
||||
public class MixinServerPinger {
|
||||
|
||||
@Unique
|
||||
private ServerData viaforge_serverData;
|
||||
|
||||
@Inject(method = "pingServer", at = @At("HEAD"))
|
||||
public void trackServerData(ServerData server, CallbackInfo ci) {
|
||||
viaforge_serverData = server;
|
||||
}
|
||||
|
||||
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaforge_serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
viaforge_serverData = null;
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.fixes;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||
|
||||
@Shadow private boolean lastOnGround;
|
||||
|
||||
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||
super(world, profile);
|
||||
}
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
// To be like:
|
||||
// if (!onGround != onGround) sendPacket
|
||||
// Which is the same as:
|
||||
// if (true) sendPacket
|
||||
return !onGround;
|
||||
}
|
||||
return lastOnGround;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
maven_name=viaforge-mc116
|
||||
mc_version=1.16.5
|
|
@ -1,37 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.network.login.ClientLoginNetHandler;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(ClientLoginNetHandler.class)
|
||||
public class MixinClientLoginNetHandler {
|
||||
|
||||
@Shadow @Final private NetworkManager connection;
|
||||
|
||||
@Redirect(method = "authenticateServer", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;joinServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/lang/String;)V"))
|
||||
public void onlyJoinServerIfPremium(MinecraftSessionService instance, GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
final UserConnection user = connection.channel().attr(ViaForgeCommon.LOCAL_VIA_USER).get();
|
||||
if (user != null && user.has(ProtocolMetadataStorage.class) && !user.get(ProtocolMetadataStorage.class).authenticate) {
|
||||
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
|
||||
// if the server is in offline mode, due the packet changes <-> networking changes
|
||||
// Minecraft's networking code is bad for us.
|
||||
return;
|
||||
}
|
||||
}
|
||||
instance.joinServer(profile, authenticationToken, serverId);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectingScreen$1")
|
||||
public class MixinConnectingScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
if (Minecraft.getInstance().getCurrentServer() instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) Minecraft.getInstance().getCurrentServer()).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.gui.overlay.DebugOverlayGui;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugOverlayGui.class)
|
||||
public class MixinDebugOverlayGui {
|
||||
|
||||
@Inject(method = "getSystemInformation", at = @At(value = "TAIL"))
|
||||
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||
|
||||
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||
cir.getReturnValue().add("");
|
||||
|
||||
int protocolVersion = version.getVersion();
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||
// So we need to unmap the version to get the real protocol version id
|
||||
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||
}
|
||||
|
||||
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerData.class)
|
||||
public class MixinServerData implements ExtendedServerData {
|
||||
|
||||
@Unique
|
||||
private VersionEnum viaforge_version;
|
||||
|
||||
@Inject(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundNBT;putString(Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveVersion(CallbackInfoReturnable<CompoundNBT> cir, CompoundNBT compoundnbt) {
|
||||
if (viaforge_version != null) {
|
||||
compoundnbt.putInt("viaforge_version", viaforge_version.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At(value = "TAIL"))
|
||||
private static void getVersion(CompoundNBT compoundnbt, CallbackInfoReturnable<ServerData> cir) {
|
||||
if (compoundnbt.contains("viaforge_version")) {
|
||||
((ExtendedServerData) cir.getReturnValue()).viaforge_setVersion(VersionEnum.fromProtocolId(compoundnbt.getInt("viaforge_version")));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("HEAD"))
|
||||
public void track(ServerData serverDataIn, CallbackInfo ci) {
|
||||
if (serverDataIn instanceof ExtendedServerData) {
|
||||
viaforge_version = ((ExtendedServerData) serverDataIn).viaforge_getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaforge_getVersion() {
|
||||
return viaforge_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaforge_setVersion(VersionEnum version) {
|
||||
viaforge_version = version;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin;
|
||||
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import de.florianmichael.viaforge.common.gui.ExtendedServerData;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.network.ServerPinger;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Mixin(ServerPinger.class)
|
||||
public class MixinServerPinger {
|
||||
|
||||
@Unique
|
||||
private ServerData viaforge_serverData;
|
||||
|
||||
@Inject(method = "pingServer", at = @At("HEAD"))
|
||||
public void trackServerData(ServerData server, Runnable p_147224_2_, CallbackInfo ci) {
|
||||
viaforge_serverData = server;
|
||||
}
|
||||
|
||||
@Redirect(method = "pingServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkManager;connectToServer(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/NetworkManager;"))
|
||||
public NetworkManager trackVersion(InetAddress address, int i, boolean b) {
|
||||
// We need to track the version of the server we are connecting to, so we can later
|
||||
// use it to determine the protocol version to use.
|
||||
// We hope that the current server data is not null
|
||||
|
||||
if (viaforge_serverData instanceof ExtendedServerData) {
|
||||
final VersionEnum version = ((ExtendedServerData) viaforge_serverData).viaforge_getVersion();
|
||||
if (version != null) {
|
||||
ViaForgeCommon.getManager().setTargetVersionSilent(version);
|
||||
} else {
|
||||
// If the server data does not contain a version, we need to restore the version
|
||||
// we had before, so we don't use the wrong version.
|
||||
ViaForgeCommon.getManager().restoreVersion();
|
||||
}
|
||||
|
||||
viaforge_serverData = null;
|
||||
}
|
||||
|
||||
return NetworkManager.connectToServer(address, i, b);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package de.florianmichael.viaforge.mixin.fixes;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||
|
||||
@Shadow private boolean lastOnGround;
|
||||
|
||||
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||
super(world, profile);
|
||||
}
|
||||
|
||||
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||
// So we invert the original logic:
|
||||
// if (prevOnGround != onGround) sendPacket
|
||||
// To be like:
|
||||
// if (!onGround != onGround) sendPacket
|
||||
// Which is the same as:
|
||||
// if (true) sendPacket
|
||||
return !onGround;
|
||||
}
|
||||
return lastOnGround;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.7.5",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"package": "de.florianmichael.viaforge.mixin",
|
||||
"client": [
|
||||
"MixinAddServerScreen",
|
||||
"MixinClientLoginNetHandler",
|
||||
"MixinConnectingScreen_1",
|
||||
"MixinDebugOverlayGui",
|
||||
"MixinMainMenuScreen",
|
||||
"MixinMultiplayerScreen",
|
||||
"MixinNetworkManager",
|
||||
"MixinNetworkManager_1",
|
||||
"MixinServerData",
|
||||
"MixinServerListScreen",
|
||||
"MixinServerPinger",
|
||||
"fixes.MixinClientPlayerEntity"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "mixins.viaforge-mc116.refmap.json"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue