From 2bd493a1665b8e78baaf6c628cc6314b47989f85 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 6 Dec 2023 22:05:18 +0100 Subject: [PATCH] Rework build structure to prevent gradle plugins Drop 1.14/1.15 as Forge doesn't seem to like Mixins on those versions Fixed 1.17+ GUI rendering crashing for OpenGL exceptions --- build.gradle | 180 +++++++++++++++++- buildSrc/build.gradle | 19 -- .../groovy/viaforge.base-conventions.gradle | 34 ---- .../viaforge.conflicting-conventions.gradle | 9 - .../groovy/viaforge.forge-conventions.gradle | 82 -------- .../groovy/viaforge.modern-conventions.gradle | 7 - .../groovy/viaforge.shadow-conventions.gradle | 25 --- settings.gradle | 2 - viaforge-mc112/build.gradle | 4 - viaforge-mc112/gradle.properties | 1 + .../florianmichael/viaforge/ViaForge112.java | 2 +- viaforge-mc114/build.gradle | 11 -- viaforge-mc114/gradle.properties | 2 - .../florianmichael/viaforge/ViaForge114.java | 64 ------- .../viaforge/gui/GuiProtocolSelector.java | 165 ---------------- .../viaforge/mixin/MixinAddServerScreen.java | 66 ------- .../mixin/MixinClientLoginNetHandler.java | 56 ------ .../mixin/MixinConnectingScreen_1.java | 54 ------ .../viaforge/mixin/MixinDebugOverlayGui.java | 54 ------ .../viaforge/mixin/MixinMainMenuScreen.java | 54 ------ .../mixin/MixinMultiplayerScreen.java | 51 ----- .../viaforge/mixin/MixinNetworkManager.java | 108 ----------- .../viaforge/mixin/MixinNetworkManager_1.java | 44 ----- .../viaforge/mixin/MixinServerData.java | 70 ------- .../viaforge/mixin/MixinServerListScreen.java | 51 ----- .../viaforge/mixin/MixinServerPinger.java | 69 ------- .../mixin/fixes/MixinClientPlayerEntity.java | 56 ------ .../provider/ViaForgeGameProfileFetcher.java | 77 -------- .../main/resources/mixins.viaforge-mc114.json | 27 --- viaforge-mc115/build.gradle | 11 -- viaforge-mc115/gradle.properties | 2 - .../florianmichael/viaforge/ViaForge115.java | 64 ------- .../viaforge/gui/GuiProtocolSelector.java | 165 ---------------- .../viaforge/mixin/MixinAddServerScreen.java | 66 ------- .../mixin/MixinClientLoginNetHandler.java | 56 ------ .../mixin/MixinConnectingScreen_1.java | 54 ------ .../viaforge/mixin/MixinDebugOverlayGui.java | 54 ------ .../viaforge/mixin/MixinMainMenuScreen.java | 54 ------ .../mixin/MixinMultiplayerScreen.java | 51 ----- .../viaforge/mixin/MixinNetworkManager.java | 108 ----------- .../viaforge/mixin/MixinNetworkManager_1.java | 44 ----- .../viaforge/mixin/MixinServerData.java | 70 ------- .../viaforge/mixin/MixinServerListScreen.java | 51 ----- .../viaforge/mixin/MixinServerPinger.java | 69 ------- .../mixin/fixes/MixinClientPlayerEntity.java | 56 ------ .../provider/ViaForgeGameProfileFetcher.java | 77 -------- .../main/resources/mixins.viaforge-mc115.json | 24 --- viaforge-mc116/build.gradle | 5 - viaforge-mc116/gradle.properties | 1 + .../src}/main/resources/META-INF/mods.toml | 4 +- viaforge-mc117/build.gradle | 4 - viaforge-mc117/gradle.properties | 1 + .../viaforge/gui/GuiProtocolSelector.java | 6 +- .../src/main/resources/META-INF/mods.toml | 17 ++ viaforge-mc118/build.gradle | 4 - viaforge-mc118/gradle.properties | 1 + .../viaforge/gui/GuiProtocolSelector.java | 6 +- .../src/main/resources/META-INF/mods.toml | 17 ++ viaforge-mc119/build.gradle | 4 - viaforge-mc119/gradle.properties | 1 + .../viaforge/gui/GuiProtocolSelector.java | 6 +- .../src/main/resources/META-INF/mods.toml | 17 ++ viaforge-mc120/build.gradle | 4 - viaforge-mc120/gradle.properties | 1 + .../viaforge/gui/GuiProtocolSelector.java | 8 +- .../src/main/resources/META-INF/mods.toml | 17 ++ 66 files changed, 266 insertions(+), 2378 deletions(-) delete mode 100644 buildSrc/build.gradle delete mode 100644 buildSrc/src/main/groovy/viaforge.base-conventions.gradle delete mode 100644 buildSrc/src/main/groovy/viaforge.conflicting-conventions.gradle delete mode 100644 buildSrc/src/main/groovy/viaforge.forge-conventions.gradle delete mode 100644 buildSrc/src/main/groovy/viaforge.modern-conventions.gradle delete mode 100644 buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle delete mode 100644 viaforge-mc114/build.gradle delete mode 100644 viaforge-mc114/gradle.properties delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge114.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java delete mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java delete mode 100644 viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json delete mode 100644 viaforge-mc115/build.gradle delete mode 100644 viaforge-mc115/gradle.properties delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge115.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java delete mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java delete mode 100644 viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json rename {src => viaforge-mc116/src}/main/resources/META-INF/mods.toml (91%) create mode 100644 viaforge-mc117/src/main/resources/META-INF/mods.toml create mode 100644 viaforge-mc118/src/main/resources/META-INF/mods.toml create mode 100644 viaforge-mc119/src/main/resources/META-INF/mods.toml create mode 100644 viaforge-mc120/src/main/resources/META-INF/mods.toml diff --git a/build.gradle b/build.gradle index 39bf09b..1e192b0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,178 @@ -plugins { - id "java" - id "viaforge.base-conventions" +buildscript { + // 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 { + classpath "com.github.johnrengelman:shadow:7.1.2" + classpath "net.minecraftforge.gradle:ForgeGradle:5.+" + classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT" + } } -dependencies { - compileOnly "io.netty:netty-all:4.0.20.Final" +allprojects { + apply plugin: "java-library" + apply plugin: "com.github.johnrengelman.shadow" + + // 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 :( + processResources { + inputs.property "version", project.version + + + 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:${project.viaversion_version}" + library "com.viaversion:viabackwards:${project.viabackwards_version}" + library "com.viaversion:viarewind-universal:${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 + "-" + project.mc_version + group = maven_group + + 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 ((project.property("sub_module_increment") as Integer) >= 2) { + 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": "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.${project.maven_name}.json", + "ForceLoadAsMod": "true" + ) + enabled = false + } + + java { + if ((project.property("sub_module_increment") as Integer) >= 2) { + // 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 ((project.property("sub_module_increment") as Integer) >= 1) { + // 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/**") + // We don't need to package mixins into Forge 1.13+ jars, since Forge already has it + exclude("org/spongepowered/**") + } + } + + reobf { + shadowJar {} + } + + jar.dependsOn("shadowJar") } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index 7c5aeee..0000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -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" -} diff --git a/buildSrc/src/main/groovy/viaforge.base-conventions.gradle b/buildSrc/src/main/groovy/viaforge.base-conventions.gradle deleted file mode 100644 index 742bb14..0000000 --- a/buildSrc/src/main/groovy/viaforge.base-conventions.gradle +++ /dev/null @@ -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}" -} diff --git a/buildSrc/src/main/groovy/viaforge.conflicting-conventions.gradle b/buildSrc/src/main/groovy/viaforge.conflicting-conventions.gradle deleted file mode 100644 index 6b4023f..0000000 --- a/buildSrc/src/main/groovy/viaforge.conflicting-conventions.gradle +++ /dev/null @@ -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/**" -} diff --git a/buildSrc/src/main/groovy/viaforge.forge-conventions.gradle b/buildSrc/src/main/groovy/viaforge.forge-conventions.gradle deleted file mode 100644 index 2f75187..0000000 --- a/buildSrc/src/main/groovy/viaforge.forge-conventions.gradle +++ /dev/null @@ -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") diff --git a/buildSrc/src/main/groovy/viaforge.modern-conventions.gradle b/buildSrc/src/main/groovy/viaforge.modern-conventions.gradle deleted file mode 100644 index c489d1e..0000000 --- a/buildSrc/src/main/groovy/viaforge.modern-conventions.gradle +++ /dev/null @@ -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) diff --git a/buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle b/buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle deleted file mode 100644 index 588b3cf..0000000 --- a/buildSrc/src/main/groovy/viaforge.shadow-conventions.gradle +++ /dev/null @@ -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 - } - } -} diff --git a/settings.gradle b/settings.gradle index 9be3b1b..e8e01f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,6 @@ rootProject.name = "ViaForge" include "viaforge-mc112" -include "viaforge-mc114" -include "viaforge-mc115" include "viaforge-mc116" include "viaforge-mc117" include "viaforge-mc118" diff --git a/viaforge-mc112/build.gradle b/viaforge-mc112/build.gradle index 7f84c48..8d86795 100644 --- a/viaforge-mc112/build.gradle +++ b/viaforge-mc112/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "viaforge.forge-conventions" -} - minecraft { mappings channel: "stable", version: "39-1.12" } diff --git a/viaforge-mc112/gradle.properties b/viaforge-mc112/gradle.properties index 1f4b32b..88abde9 100644 --- a/viaforge-mc112/gradle.properties +++ b/viaforge-mc112/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc112 mc_version=1.12.2 +sub_module_increment=0 diff --git a/viaforge-mc112/src/main/java/de/florianmichael/viaforge/ViaForge112.java b/viaforge-mc112/src/main/java/de/florianmichael/viaforge/ViaForge112.java index 2d61d74..bb89d61 100644 --- a/viaforge-mc112/src/main/java/de/florianmichael/viaforge/ViaForge112.java +++ b/viaforge-mc112/src/main/java/de/florianmichael/viaforge/ViaForge112.java @@ -29,7 +29,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.G import java.io.File; import java.util.function.Supplier; -@Mod(modid = "viaforge") +@Mod(modid = "viaforge", version = "3.5.0") public class ViaForge112 implements VFPlatform { public static final ViaForge112 PLATFORM = new ViaForge112(); diff --git a/viaforge-mc114/build.gradle b/viaforge-mc114/build.gradle deleted file mode 100644 index be06926..0000000 --- a/viaforge-mc114/build.gradle +++ /dev/null @@ -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" -} diff --git a/viaforge-mc114/gradle.properties b/viaforge-mc114/gradle.properties deleted file mode 100644 index fa2c7a4..0000000 --- a/viaforge-mc114/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -maven_name=viaforge-mc114 -mc_version=1.14.4 diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge114.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge114.java deleted file mode 100644 index 2edfadf..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge114.java +++ /dev/null @@ -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 . - */ - -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 static final ViaForge114 PLATFORM = new ViaForge114(); - - @Override - public int getGameVersion() { - return SharedConstants.getCurrentVersion().getProtocolVersion(); - } - - @Override - public Supplier 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(); - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java deleted file mode 100644 index 1930e5e..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ /dev/null @@ -1,165 +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 . - */ - -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 { - - 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 { - - 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); - - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java deleted file mode 100644 index 9d3077e..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java +++ /dev/null @@ -1,66 +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 . - */ - -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 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); - })); - })); - } - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java deleted file mode 100644 index 3a76b6d..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java +++ /dev/null @@ -1,56 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java deleted file mode 100644 index 82f0c93..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java +++ /dev/null @@ -1,54 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java deleted file mode 100644 index 5aa9c58..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java +++ /dev/null @@ -1,54 +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 . - */ - -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> 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 + ")"); - } - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java deleted file mode 100644 index f81314d..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java +++ /dev/null @@ -1,54 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java deleted file mode 100644 index 5ca8095..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java +++ /dev/null @@ -1,51 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java deleted file mode 100644 index 9068539..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java +++ /dev/null @@ -1,108 +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 . - */ - -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 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; - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java deleted file mode 100644 index 512a5e3..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java +++ /dev/null @@ -1,44 +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 . - */ - -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.NetworkManager; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(targets = "net.minecraft.network.NetworkManager$1") -public class MixinNetworkManager_1 { - - @Final - @Mutable - NetworkManager val$networkmanager; - - @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) - private void onInitChannel(Channel channel, CallbackInfo ci) { - ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java deleted file mode 100644 index c06e1c8..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java +++ /dev/null @@ -1,70 +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 . - */ - -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 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 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; - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java deleted file mode 100644 index be6ad44..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java +++ /dev/null @@ -1,51 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java deleted file mode 100644 index 6800a02..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java +++ /dev/null @@ -1,69 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java deleted file mode 100644 index c6f6b8e..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java +++ /dev/null @@ -1,56 +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 . - */ - -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; - } - -} diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java deleted file mode 100644 index 3adcfa4..0000000 --- a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java +++ /dev/null @@ -1,77 +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 . - */ - -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 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) throws Exception { - 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 entry : mojangProfile.getProperties().entries()) { - final Property prop = entry.getValue(); - gameProfile.addProperty(new GameProfile.Property(prop.getName(), prop.getValue(), prop.getSignature())); - } - - return gameProfile; - } - -} diff --git a/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json b/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json deleted file mode 100644 index 064a646..0000000 --- a/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json +++ /dev/null @@ -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" - ] -} diff --git a/viaforge-mc115/build.gradle b/viaforge-mc115/build.gradle deleted file mode 100644 index e8a9dd3..0000000 --- a/viaforge-mc115/build.gradle +++ /dev/null @@ -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" -} diff --git a/viaforge-mc115/gradle.properties b/viaforge-mc115/gradle.properties deleted file mode 100644 index 5682b59..0000000 --- a/viaforge-mc115/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -maven_name=viaforge-mc115 -mc_version=1.15.2 diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge115.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge115.java deleted file mode 100644 index 54fc3a0..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge115.java +++ /dev/null @@ -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 . - */ - -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 static final ViaForge115 PLATFORM = new ViaForge115(); - - @Override - public int getGameVersion() { - return SharedConstants.getCurrentVersion().getProtocolVersion(); - } - - @Override - public Supplier 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(); - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java deleted file mode 100644 index 1930e5e..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ /dev/null @@ -1,165 +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 . - */ - -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 { - - 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 { - - 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); - - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java deleted file mode 100644 index 9d3077e..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinAddServerScreen.java +++ /dev/null @@ -1,66 +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 . - */ - -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 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); - })); - })); - } - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java deleted file mode 100644 index 3a76b6d..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinClientLoginNetHandler.java +++ /dev/null @@ -1,56 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java deleted file mode 100644 index 82f0c93..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinConnectingScreen_1.java +++ /dev/null @@ -1,54 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java deleted file mode 100644 index 5aa9c58..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinDebugOverlayGui.java +++ /dev/null @@ -1,54 +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 . - */ - -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> 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 + ")"); - } - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java deleted file mode 100644 index c158987..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java +++ /dev/null @@ -1,54 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java deleted file mode 100644 index 5ca8095..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java +++ /dev/null @@ -1,51 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", buttons -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java deleted file mode 100644 index 3da5f27..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java +++ /dev/null @@ -1,108 +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 . - */ - -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 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; - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java deleted file mode 100644 index 512a5e3..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java +++ /dev/null @@ -1,44 +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 . - */ - -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.NetworkManager; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(targets = "net.minecraft.network.NetworkManager$1") -public class MixinNetworkManager_1 { - - @Final - @Mutable - NetworkManager val$networkmanager; - - @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) - private void onInitChannel(Channel channel, CallbackInfo ci) { - ViaForgeCommon.getManager().inject(channel, (VFNetworkManager) val$networkmanager); - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java deleted file mode 100644 index c06e1c8..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerData.java +++ /dev/null @@ -1,70 +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 . - */ - -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 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 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; - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java deleted file mode 100644 index be6ad44..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java +++ /dev/null @@ -1,51 +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 . - */ - -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 pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height); - - addButton(new Button(pos.key(), pos.value(), 100, 20, "ViaForge", b -> GuiProtocolSelector.open(minecraft))); - } - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java deleted file mode 100644 index 6800a02..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerPinger.java +++ /dev/null @@ -1,69 +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 . - */ - -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); - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java deleted file mode 100644 index c6f6b8e..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/fixes/MixinClientPlayerEntity.java +++ /dev/null @@ -1,56 +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 . - */ - -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; - } - -} diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java deleted file mode 100644 index 3adcfa4..0000000 --- a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/provider/ViaForgeGameProfileFetcher.java +++ /dev/null @@ -1,77 +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 . - */ - -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 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) throws Exception { - 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 entry : mojangProfile.getProperties().entries()) { - final Property prop = entry.getValue(); - gameProfile.addProperty(new GameProfile.Property(prop.getName(), prop.getValue(), prop.getSignature())); - } - - return gameProfile; - } - -} diff --git a/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json b/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json deleted file mode 100644 index ada0467..0000000 --- a/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json +++ /dev/null @@ -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-mc115.refmap.json" -} diff --git a/viaforge-mc116/build.gradle b/viaforge-mc116/build.gradle index 454feb3..bbba224 100644 --- a/viaforge-mc116/build.gradle +++ b/viaforge-mc116/build.gradle @@ -1,8 +1,3 @@ -plugins { - id "viaforge.forge-conventions" - id "viaforge.conflicting-conventions" -} - minecraft { mappings channel: "official", version: "1.16.5" } diff --git a/viaforge-mc116/gradle.properties b/viaforge-mc116/gradle.properties index 229f7cb..089d8b7 100644 --- a/viaforge-mc116/gradle.properties +++ b/viaforge-mc116/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc116 mc_version=1.16.5 +sub_module_increment=1 diff --git a/src/main/resources/META-INF/mods.toml b/viaforge-mc116/src/main/resources/META-INF/mods.toml similarity index 91% rename from src/main/resources/META-INF/mods.toml rename to viaforge-mc116/src/main/resources/META-INF/mods.toml index 620259d..8590195 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/viaforge-mc116/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[1,)" +loaderVersion="[36,)" license="GPL-3.0 license" issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues" @@ -7,7 +7,7 @@ showAsResourcePack=false [[mods]] modId="viaforge" -version="${version}" +version="3.5.0" displayName="ViaForge" displayURL="https://github.com/FlorianMichael" credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors" diff --git a/viaforge-mc117/build.gradle b/viaforge-mc117/build.gradle index c829268..2ed7ce9 100644 --- a/viaforge-mc117/build.gradle +++ b/viaforge-mc117/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "viaforge.modern-conventions" -} - minecraft { mappings channel: "official", version: "1.17.1" } diff --git a/viaforge-mc117/gradle.properties b/viaforge-mc117/gradle.properties index 9ca4f68..ea1a7f9 100644 --- a/viaforge-mc117/gradle.properties +++ b/viaforge-mc117/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc117 mc_version=1.17.1 +sub_module_increment=2 diff --git a/viaforge-mc117/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc117/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index 057acc5..9f7fb5d 100644 --- a/viaforge-mc117/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/viaforge-mc117/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -108,10 +108,10 @@ public class GuiProtocolSelector extends Screen { super.render(matrices, p_230430_2_, p_230430_3_, p_230430_4_); - GL11.glPushMatrix(); - GL11.glScalef(2.0F, 2.0F, 2.0F); + matrices.pushPose(); + matrices.scale(2.0F, 2.0F, 2.0F); drawCenteredString(matrices, font, TextFormatting.GOLD + "ViaForge", width / 4, 3, 16777215); - GL11.glPopMatrix(); + matrices.popPose(); drawCenteredString(matrices, font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1); drawString(matrices, font, status != null ? status : "Discord: florianmichael", 3, 3, -1); diff --git a/viaforge-mc117/src/main/resources/META-INF/mods.toml b/viaforge-mc117/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..d0f84c2 --- /dev/null +++ b/viaforge-mc117/src/main/resources/META-INF/mods.toml @@ -0,0 +1,17 @@ +modLoader="javafml" +loaderVersion="[37,)" + +license="GPL-3.0 license" +issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues" +showAsResourcePack=false + +[[mods]] +modId="viaforge" +version="3.5.0" +displayName="ViaForge" +displayURL="https://github.com/FlorianMichael" +credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors" +authors="FlorianMichael/EnZaXD" +description=''' + Client-side Implementation of the Via* projects for Minecraft Forge + ''' \ No newline at end of file diff --git a/viaforge-mc118/build.gradle b/viaforge-mc118/build.gradle index b4265cf..7ac4a6b 100644 --- a/viaforge-mc118/build.gradle +++ b/viaforge-mc118/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "viaforge.modern-conventions" -} - minecraft { mappings channel: "official", version: "1.18.2" } diff --git a/viaforge-mc118/gradle.properties b/viaforge-mc118/gradle.properties index 6b1d82e..fe9f656 100644 --- a/viaforge-mc118/gradle.properties +++ b/viaforge-mc118/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc118 mc_version=1.18.2 +sub_module_increment=3 diff --git a/viaforge-mc118/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc118/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index 095a2dc..6e28248 100644 --- a/viaforge-mc118/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/viaforge-mc118/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -108,10 +108,10 @@ public class GuiProtocolSelector extends Screen { super.render(matrices, p_230430_2_, p_230430_3_, p_230430_4_); - GL11.glPushMatrix(); - GL11.glScalef(2.0F, 2.0F, 2.0F); + matrices.pushPose(); + matrices.scale(2.0F, 2.0F, 2.0F); drawCenteredString(matrices, font, TextFormatting.GOLD + "ViaForge", width / 4, 3, 16777215); - GL11.glPopMatrix(); + matrices.popPose(); drawCenteredString(matrices, font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1); drawString(matrices, font, status != null ? status : "Discord: florianmichael", 3, 3, -1); diff --git a/viaforge-mc118/src/main/resources/META-INF/mods.toml b/viaforge-mc118/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..8906bee --- /dev/null +++ b/viaforge-mc118/src/main/resources/META-INF/mods.toml @@ -0,0 +1,17 @@ +modLoader="javafml" +loaderVersion="[40,)" + +license="GPL-3.0 license" +issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues" +showAsResourcePack=false + +[[mods]] +modId="viaforge" +version="3.5.0" +displayName="ViaForge" +displayURL="https://github.com/FlorianMichael" +credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors" +authors="FlorianMichael/EnZaXD" +description=''' + Client-side Implementation of the Via* projects for Minecraft Forge + ''' \ No newline at end of file diff --git a/viaforge-mc119/build.gradle b/viaforge-mc119/build.gradle index 8728924..c33c922 100644 --- a/viaforge-mc119/build.gradle +++ b/viaforge-mc119/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "viaforge.modern-conventions" -} - minecraft { mappings channel: "official", version: "1.19.4" } diff --git a/viaforge-mc119/gradle.properties b/viaforge-mc119/gradle.properties index 78b5a45..b10ca2f 100644 --- a/viaforge-mc119/gradle.properties +++ b/viaforge-mc119/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc119 mc_version=1.19.4 +sub_module_increment=4 diff --git a/viaforge-mc119/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc119/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index f19380d..e276011 100644 --- a/viaforge-mc119/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/viaforge-mc119/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -107,10 +107,10 @@ public class GuiProtocolSelector extends Screen { super.render(matrices, p_230430_2_, p_230430_3_, p_230430_4_); - GL11.glPushMatrix(); - GL11.glScalef(2.0F, 2.0F, 2.0F); + matrices.pushPose(); + matrices.scale(2.0F, 2.0F, 2.0F); drawCenteredString(matrices, font, TextFormatting.GOLD + "ViaForge", width / 4, 3, 16777215); - GL11.glPopMatrix(); + matrices.popPose(); drawCenteredString(matrices, font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1); drawString(matrices, font, status != null ? status : "Discord: florianmichael", 3, 3, -1); diff --git a/viaforge-mc119/src/main/resources/META-INF/mods.toml b/viaforge-mc119/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..d608ca5 --- /dev/null +++ b/viaforge-mc119/src/main/resources/META-INF/mods.toml @@ -0,0 +1,17 @@ +modLoader="javafml" +loaderVersion="[45,)" + +license="GPL-3.0 license" +issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues" +showAsResourcePack=false + +[[mods]] +modId="viaforge" +version="3.5.0" +displayName="ViaForge" +displayURL="https://github.com/FlorianMichael" +credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors" +authors="FlorianMichael/EnZaXD" +description=''' + Client-side Implementation of the Via* projects for Minecraft Forge + ''' \ No newline at end of file diff --git a/viaforge-mc120/build.gradle b/viaforge-mc120/build.gradle index aee776b..0afed94 100644 --- a/viaforge-mc120/build.gradle +++ b/viaforge-mc120/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "viaforge.modern-conventions" -} - minecraft { mappings channel: "official", version: "1.20.2" } diff --git a/viaforge-mc120/gradle.properties b/viaforge-mc120/gradle.properties index 2099f7e..65522d7 100644 --- a/viaforge-mc120/gradle.properties +++ b/viaforge-mc120/gradle.properties @@ -1,2 +1,3 @@ maven_name=viaforge-mc120 mc_version=1.20.2 +sub_module_increment=5 diff --git a/viaforge-mc120/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/viaforge-mc120/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index 71cad43..4ba2764 100644 --- a/viaforge-mc120/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/viaforge-mc120/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -106,10 +106,12 @@ public class GuiProtocolSelector extends Screen { this.list.render(graphics, p_230430_2_, p_230430_3_, p_230430_4_); super.render(graphics, p_230430_2_, p_230430_3_, p_230430_4_); - GL11.glPushMatrix(); - GL11.glScalef(2.0F, 2.0F, 2.0F); + final var pose = graphics.pose(); + + pose.pushPose(); + pose.scale(2.0F, 2.0F, 2.0F); graphics.drawCenteredString(font, TextFormatting.GOLD + "ViaForge", width / 4, 3, 16777215); - GL11.glPopMatrix(); + pose.popPose(); graphics.drawCenteredString(font, "https://github.com/ViaVersion/ViaForge", width / 2, (font.lineHeight + 2) * 2 + 3, -1); graphics.drawString(font, status != null ? status : "Discord: florianmichael", 3, 3, -1); diff --git a/viaforge-mc120/src/main/resources/META-INF/mods.toml b/viaforge-mc120/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..61f69c1 --- /dev/null +++ b/viaforge-mc120/src/main/resources/META-INF/mods.toml @@ -0,0 +1,17 @@ +modLoader="javafml" +loaderVersion="[48,)" + +license="GPL-3.0 license" +issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues" +showAsResourcePack=false + +[[mods]] +modId="viaforge" +version="3.5.0" +displayName="ViaForge" +displayURL="https://github.com/FlorianMichael" +credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors" +authors="FlorianMichael/EnZaXD" +description=''' + Client-side Implementation of the Via* projects for Minecraft Forge + ''' \ No newline at end of file