From d015b8807eb2852414e45cef344e5201e9f6610d Mon Sep 17 00:00:00 2001
From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com>
Date: Sat, 21 Oct 2023 02:40:45 +0200
Subject: [PATCH] Added Support for Minecraft 1.14 and 1.15
---
README.md | 5 +-
settings.gradle | 2 +
viaforge-mc114/build.gradle | 12 +++
viaforge-mc114/gradle.properties | 2 +
.../de/florianmichael/viaforge/ViaForge.java | 42 ++++++++
.../viaforge/gui/GuiProtocolSelector.java | 101 ++++++++++++++++++
.../viaforge/mixin/MixinMainMenuScreen.java | 45 ++++++++
.../mixin/MixinMultiplayerScreen.java | 44 ++++++++
.../viaforge/mixin/MixinNetworkManager.java | 38 +++++++
.../viaforge/mixin/MixinNetworkManager_5.java | 4 +-
.../viaforge/mixin/MixinServerListScreen.java | 44 ++++++++
.../protocolhack/ViaForgeVLInjector.java | 34 ++++++
.../ViaForgeVLLegacyPipeline.java | 59 ++++++++++
.../protocolhack/ViaForgeVLLoader.java | 45 ++++++++
.../src/main/resources/META-INF/mods.toml | 17 +++
.../main/resources/mixins.viaforge-mc114.json | 17 +++
viaforge-mc114/src/main/resources/pack.mcmeta | 6 ++
viaforge-mc115/build.gradle | 12 +++
viaforge-mc115/gradle.properties | 2 +
.../de/florianmichael/viaforge/ViaForge.java | 42 ++++++++
.../viaforge/gui/GuiProtocolSelector.java | 101 ++++++++++++++++++
.../viaforge/mixin/MixinMainMenuScreen.java | 45 ++++++++
.../mixin/MixinMultiplayerScreen.java | 44 ++++++++
.../viaforge/mixin/MixinNetworkManager.java | 38 +++++++
.../viaforge/mixin/MixinNetworkManager_5.java | 44 ++++++++
.../viaforge/mixin/MixinServerListScreen.java | 44 ++++++++
.../protocolhack/ViaForgeVLInjector.java | 34 ++++++
.../ViaForgeVLLegacyPipeline.java | 59 ++++++++++
.../protocolhack/ViaForgeVLLoader.java | 45 ++++++++
.../src/main/resources/META-INF/mods.toml | 17 +++
.../main/resources/mixins.viaforge-mc115.json | 17 +++
viaforge-mc115/src/main/resources/pack.mcmeta | 6 ++
.../viaforge/mixin/MixinNetworkManager_5.java | 44 ++++++++
.../main/resources/mixins.viaforge-mc116.json | 2 +-
34 files changed, 1109 insertions(+), 4 deletions(-)
create mode 100644 viaforge-mc114/build.gradle
create mode 100644 viaforge-mc114/gradle.properties
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java
rename viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java => viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java (95%)
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
create mode 100644 viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
create mode 100644 viaforge-mc114/src/main/resources/META-INF/mods.toml
create mode 100644 viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json
create mode 100644 viaforge-mc114/src/main/resources/pack.mcmeta
create mode 100644 viaforge-mc115/build.gradle
create mode 100644 viaforge-mc115/gradle.properties
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
create mode 100644 viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
create mode 100644 viaforge-mc115/src/main/resources/META-INF/mods.toml
create mode 100644 viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json
create mode 100644 viaforge-mc115/src/main/resources/pack.mcmeta
create mode 100644 viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
diff --git a/README.md b/README.md
index 5376fab..f678ddb 100644
--- a/README.md
+++ b/README.md
@@ -23,10 +23,13 @@ GitHub Releases: https://github.com/ViaVersion/ViaForge
All ViaForge versions from Minecraft version 1.12 onwards are on the `master` branch.
The names of the submodules indicate the version, they are always given in the format `mc-`.
`Minecraft 1.12.2` - `mc112`
+`Minecraft 1.14.4` - `mc114`
+`Minecraft 1.15.2` - `mc115`
`Minecraft 1.16.4/5` - `mc116`
-`Minecraft 1.17.2` - `mc117`
+`Minecraft 1.17.1` - `mc117`
`Minecraft 1.18.2` - `mc118`
`Minecraft 1.19.4` - `mc119`
+`Minecraft 1.20.2` - `mc120`
### ViaForge for Minecraft 1.8
Since ForgeGradle for Minecraft 1.8 is too old, it has its own branch called `legacy-1.8`
diff --git a/settings.gradle b/settings.gradle
index d42ce04..ea090b1 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -23,4 +23,6 @@ include "viaforge-mc117"
include "viaforge-mc118"
include "viaforge-mc119"
include "viaforge-mc120"
+include 'viaforge-mc115'
+include 'viaforge-mc114'
diff --git a/viaforge-mc114/build.gradle b/viaforge-mc114/build.gradle
new file mode 100644
index 0000000..8c9808a
--- /dev/null
+++ b/viaforge-mc114/build.gradle
@@ -0,0 +1,12 @@
+plugins {
+ id "florianmichael.viaforge.base-conventions"
+ id "florianmichael.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
new file mode 100644
index 0000000..fa2c7a4
--- /dev/null
+++ b/viaforge-mc114/gradle.properties
@@ -0,0 +1,2 @@
+maven_name=viaforge-mc114
+mc_version=1.14.4
diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge.java
new file mode 100644
index 0000000..d3ba472
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/ViaForge.java
@@ -0,0 +1,42 @@
+/*
+ * 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.protocolhack.ViaForgeVLInjector;
+import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
+import net.minecraftforge.fml.common.Mod;
+import net.raphimc.vialoader.ViaLoader;
+import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
+import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
+import net.raphimc.vialoader.util.VersionEnum;
+
+@Mod("viaforge")
+public class ViaForge {
+ public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_14_4;
+
+ public static VersionEnum targetVersion = VersionEnum.r1_14_4;
+
+ private static boolean loaded;
+
+ public static void initViaVersion() {
+ if (loaded) return;
+
+ ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
+ loaded = true;
+ }
+}
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
new file mode 100644
index 0000000..4b6611b
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java
@@ -0,0 +1,101 @@
+/*
+ * 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 de.florianmichael.viaforge.ViaForge;
+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.minecraft.util.text.TextFormatting;
+import net.raphimc.vialoader.util.VersionEnum;
+import org.lwjgl.opengl.GL11;
+
+public class GuiProtocolSelector extends Screen {
+
+ private final Screen parent;
+
+ public static void open(final Minecraft minecraft) { // Bypass for some weird bytecode instructions errors in Forge
+ minecraft.setScreen(new GuiProtocolSelector(minecraft.screen));
+ }
+
+ private SlotList slotList;
+
+ public GuiProtocolSelector(Screen parent) {
+ super(new StringTextComponent("ViaForge Protocol Selector"));
+ this.parent = parent;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+
+ slotList = new SlotList(minecraft, width, height, 32, height - 32, 10);
+ addButton(new Button(width / 2 - 100, height - 27, 200, 20, "Back", b -> minecraft.setScreen(parent)));
+ }
+
+ @Override
+ public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) {
+ renderBackground();
+ this.slotList.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(this.font, TextFormatting.GOLD + "ViaForge", this.width / 4, 6, 16777215);
+ GL11.glPopMatrix();
+
+ drawString(this.font, "by https://github.com/ViaVersion/ViaForge", 1, 1, -1);
+ drawString(this.font, "Discord: florianmichael", 1, 11, -1);
+ }
+
+ static class SlotList extends ExtendedList {
+
+ public SlotList(Minecraft p_i51146_1_, int p_i51146_2_, int p_i51146_3_, int p_i51146_4_, int p_i51146_5_, int p_i51146_6_) {
+ super(p_i51146_1_, p_i51146_2_, p_i51146_3_, p_i51146_4_, p_i51146_5_, p_i51146_6_);
+
+ 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 p_231044_1_, double p_231044_3_, int p_231044_5_) {
+ ViaForge.targetVersion = versionEnum;
+ return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
+ }
+
+ @Override
+ public void render(int p_230432_2_, int p_230432_3_, 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_) {
+ drawCenteredString(Minecraft.getInstance().font,
+ (ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
+ }
+ }
+ }
+}
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
new file mode 100644
index 0000000..ece29e6
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ViaForge;
+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 net.minecraft.util.text.StringTextComponent;
+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 p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("HEAD"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
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
new file mode 100644
index 0000000..b059506
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java
@@ -0,0 +1,44 @@
+/*
+ * 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.ViaForge;
+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 {
+
+ protected MixinMultiplayerScreen(ITextComponent p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("RETURN"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
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
new file mode 100644
index 0000000..ca36f19
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java
@@ -0,0 +1,38 @@
+/*
+ * 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 io.netty.channel.Channel;
+import net.minecraft.network.NetworkManager;
+import net.raphimc.vialoader.netty.CompressionReorderEvent;
+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(NetworkManager.class)
+public class MixinNetworkManager {
+
+ @Shadow private Channel channel;
+
+ @Inject(method = "setupCompression", at = @At("RETURN"))
+ public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
+ channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
+ }
+}
diff --git a/viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
similarity index 95%
rename from viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java
rename to viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
index 424fe67..7dde3b2 100644
--- a/viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_1.java
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
@@ -29,8 +29,8 @@ 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", remap = false)
-public class MixinNetworkManager_1 {
+@Mixin(targets = "net.minecraft.network.NetworkManager$5", remap = false)
+public class MixinNetworkManager_5 {
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
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
new file mode 100644
index 0000000..2609743
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java
@@ -0,0 +1,44 @@
+/*
+ * 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.ViaForge;
+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 {
+
+ protected MixinServerListScreen(ITextComponent p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("RETURN"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
new file mode 100644
index 0000000..5a30719
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
@@ -0,0 +1,34 @@
+/*
+ * 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.protocolhack;
+
+import net.raphimc.vialoader.impl.viaversion.VLInjector;
+import net.raphimc.vialoader.netty.VLLegacyPipeline;
+
+public class ViaForgeVLInjector extends VLInjector {
+
+ @Override
+ public String getDecoderName() {
+ return VLLegacyPipeline.VIA_DECODER_NAME;
+ }
+
+ @Override
+ public String getEncoderName() {
+ return VLLegacyPipeline.VIA_ENCODER_NAME;
+ }
+}
diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
new file mode 100644
index 0000000..37da249
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
@@ -0,0 +1,59 @@
+/*
+ * 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.protocolhack;
+
+import com.viaversion.viaversion.api.connection.UserConnection;
+import net.raphimc.vialoader.netty.VLLegacyPipeline;
+import net.raphimc.vialoader.util.VersionEnum;
+
+public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
+
+ public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
+ super(user, version);
+ }
+
+ @Override
+ protected String decompressName() {
+ return "decompress";
+ }
+
+ @Override
+ protected String compressName() {
+ return "compress";
+ }
+
+ @Override
+ protected String packetDecoderName() {
+ return "decoder";
+ }
+
+ @Override
+ protected String packetEncoderName() {
+ return "encoder";
+ }
+
+ @Override
+ protected String lengthSplitterName() {
+ return "splitter";
+ }
+
+ @Override
+ protected String lengthPrependerName() {
+ return "prepender";
+ }
+}
diff --git a/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
new file mode 100644
index 0000000..2158ad3
--- /dev/null
+++ b/viaforge-mc114/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
@@ -0,0 +1,45 @@
+/*
+ * 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.protocolhack;
+
+import com.viaversion.viaversion.api.Via;
+import com.viaversion.viaversion.api.connection.UserConnection;
+import com.viaversion.viaversion.api.protocol.version.VersionProvider;
+import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
+import de.florianmichael.viaforge.ViaForge;
+import net.minecraft.client.Minecraft;
+import net.raphimc.vialoader.impl.viaversion.VLLoader;
+
+public class ViaForgeVLLoader extends VLLoader {
+
+ @Override
+ public void load() {
+ super.load();
+
+ Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
+ @Override
+ public int getClosestServerProtocol(UserConnection connection) throws Exception {
+ if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
+ return ViaForge.targetVersion.getVersion();
+ }
+
+ return super.getClosestServerProtocol(connection);
+ }
+ });
+ }
+}
diff --git a/viaforge-mc114/src/main/resources/META-INF/mods.toml b/viaforge-mc114/src/main/resources/META-INF/mods.toml
new file mode 100644
index 0000000..b5beba3
--- /dev/null
+++ b/viaforge-mc114/src/main/resources/META-INF/mods.toml
@@ -0,0 +1,17 @@
+modLoader="javafml"
+loaderVersion="[1,)"
+
+license="GPL-3.0 license"
+issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
+showAsResourcePack=false
+
+[[mods]]
+modId="viaforge"
+version="${version}"
+displayName="ViaForge"
+displayURL="https://github.com/FlorianMichael"
+credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
+authors="FlorianMichael/EnZaXD"
+description='''
+ Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
+ '''
\ No newline at end of file
diff --git a/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json b/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json
new file mode 100644
index 0000000..e160baf
--- /dev/null
+++ b/viaforge-mc114/src/main/resources/mixins.viaforge-mc114.json
@@ -0,0 +1,17 @@
+{
+ "required": true,
+ "minVersion": "0.7.5",
+ "compatibilityLevel": "JAVA_8",
+ "package": "de.florianmichael.viaforge.mixin",
+ "mixins": [
+ "MixinNetworkManager",
+ "MixinNetworkManager_5",
+ "MixinMainMenuScreen",
+ "MixinMultiplayerScreen",
+ "MixinServerListScreen"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ },
+ "refmap": "mixins.viaforge-mc114.refmap.json"
+}
diff --git a/viaforge-mc114/src/main/resources/pack.mcmeta b/viaforge-mc114/src/main/resources/pack.mcmeta
new file mode 100644
index 0000000..646ce57
--- /dev/null
+++ b/viaforge-mc114/src/main/resources/pack.mcmeta
@@ -0,0 +1,6 @@
+{
+ "pack": {
+ "description": "ViaForge",
+ "pack_format": 6
+ }
+}
diff --git a/viaforge-mc115/build.gradle b/viaforge-mc115/build.gradle
new file mode 100644
index 0000000..8fef129
--- /dev/null
+++ b/viaforge-mc115/build.gradle
@@ -0,0 +1,12 @@
+plugins {
+ id "florianmichael.viaforge.base-conventions"
+ id "florianmichael.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
new file mode 100644
index 0000000..5682b59
--- /dev/null
+++ b/viaforge-mc115/gradle.properties
@@ -0,0 +1,2 @@
+maven_name=viaforge-mc115
+mc_version=1.15.2
diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge.java
new file mode 100644
index 0000000..c8b3107
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/ViaForge.java
@@ -0,0 +1,42 @@
+/*
+ * 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.protocolhack.ViaForgeVLInjector;
+import de.florianmichael.viaforge.protocolhack.ViaForgeVLLoader;
+import net.minecraftforge.fml.common.Mod;
+import net.raphimc.vialoader.ViaLoader;
+import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
+import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
+import net.raphimc.vialoader.util.VersionEnum;
+
+@Mod("viaforge")
+public class ViaForge {
+ public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_15_2;
+
+ public static VersionEnum targetVersion = VersionEnum.r1_15_2;
+
+ private static boolean loaded;
+
+ public static void initViaVersion() {
+ if (loaded) return;
+
+ ViaLoader.init(null, new ViaForgeVLLoader(), new ViaForgeVLInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new);
+ loaded = true;
+ }
+}
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
new file mode 100644
index 0000000..4b6611b
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java
@@ -0,0 +1,101 @@
+/*
+ * 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 de.florianmichael.viaforge.ViaForge;
+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.minecraft.util.text.TextFormatting;
+import net.raphimc.vialoader.util.VersionEnum;
+import org.lwjgl.opengl.GL11;
+
+public class GuiProtocolSelector extends Screen {
+
+ private final Screen parent;
+
+ public static void open(final Minecraft minecraft) { // Bypass for some weird bytecode instructions errors in Forge
+ minecraft.setScreen(new GuiProtocolSelector(minecraft.screen));
+ }
+
+ private SlotList slotList;
+
+ public GuiProtocolSelector(Screen parent) {
+ super(new StringTextComponent("ViaForge Protocol Selector"));
+ this.parent = parent;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+
+ slotList = new SlotList(minecraft, width, height, 32, height - 32, 10);
+ addButton(new Button(width / 2 - 100, height - 27, 200, 20, "Back", b -> minecraft.setScreen(parent)));
+ }
+
+ @Override
+ public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) {
+ renderBackground();
+ this.slotList.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(this.font, TextFormatting.GOLD + "ViaForge", this.width / 4, 6, 16777215);
+ GL11.glPopMatrix();
+
+ drawString(this.font, "by https://github.com/ViaVersion/ViaForge", 1, 1, -1);
+ drawString(this.font, "Discord: florianmichael", 1, 11, -1);
+ }
+
+ static class SlotList extends ExtendedList {
+
+ public SlotList(Minecraft p_i51146_1_, int p_i51146_2_, int p_i51146_3_, int p_i51146_4_, int p_i51146_5_, int p_i51146_6_) {
+ super(p_i51146_1_, p_i51146_2_, p_i51146_3_, p_i51146_4_, p_i51146_5_, p_i51146_6_);
+
+ 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 p_231044_1_, double p_231044_3_, int p_231044_5_) {
+ ViaForge.targetVersion = versionEnum;
+ return super.mouseClicked(p_231044_1_, p_231044_3_, p_231044_5_);
+ }
+
+ @Override
+ public void render(int p_230432_2_, int p_230432_3_, 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_) {
+ drawCenteredString(Minecraft.getInstance().font,
+ (ViaForge.targetVersion.getVersion() == versionEnum.getVersion() ? TextFormatting.GREEN.toString() : TextFormatting.DARK_RED.toString()) + versionEnum.getName(), width / 2, p_230432_3_, -1);
+ }
+ }
+ }
+}
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
new file mode 100644
index 0000000..ece29e6
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMainMenuScreen.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ViaForge;
+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 net.minecraft.util.text.StringTextComponent;
+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 p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("HEAD"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
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
new file mode 100644
index 0000000..b059506
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinMultiplayerScreen.java
@@ -0,0 +1,44 @@
+/*
+ * 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.ViaForge;
+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 {
+
+ protected MixinMultiplayerScreen(ITextComponent p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("RETURN"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
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
new file mode 100644
index 0000000..ca36f19
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager.java
@@ -0,0 +1,38 @@
+/*
+ * 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 io.netty.channel.Channel;
+import net.minecraft.network.NetworkManager;
+import net.raphimc.vialoader.netty.CompressionReorderEvent;
+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(NetworkManager.class)
+public class MixinNetworkManager {
+
+ @Shadow private Channel channel;
+
+ @Inject(method = "setupCompression", at = @At("RETURN"))
+ public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
+ channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
+ }
+}
diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
new file mode 100644
index 0000000..7dde3b2
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
@@ -0,0 +1,44 @@
+/*
+ * 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.api.connection.UserConnection;
+import com.viaversion.viaversion.connection.UserConnectionImpl;
+import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
+import de.florianmichael.viaforge.ViaForge;
+import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
+import io.netty.channel.Channel;
+import io.netty.channel.socket.SocketChannel;
+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(targets = "net.minecraft.network.NetworkManager$5", remap = false)
+public class MixinNetworkManager_5 {
+
+ @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
+ private void onInitChannel(Channel channel, CallbackInfo ci) {
+ if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
+ final UserConnection user = new UserConnectionImpl(channel, true);
+ new ProtocolPipelineImpl(user);
+
+ channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
+ }
+ }
+}
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
new file mode 100644
index 0000000..2609743
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/mixin/MixinServerListScreen.java
@@ -0,0 +1,44 @@
+/*
+ * 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.ViaForge;
+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 {
+
+ protected MixinServerListScreen(ITextComponent p_i51108_1_) {
+ super(p_i51108_1_);
+ }
+
+ @Inject(method = "init", at = @At("RETURN"))
+ public void hookViaForgeButton(CallbackInfo ci) {
+ addButton(new Button(5, 6, 98, 20,"ViaForge", b -> GuiProtocolSelector.open(minecraft)));
+
+ ViaForge.initViaVersion();
+ }
+}
diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
new file mode 100644
index 0000000..5a30719
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLInjector.java
@@ -0,0 +1,34 @@
+/*
+ * 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.protocolhack;
+
+import net.raphimc.vialoader.impl.viaversion.VLInjector;
+import net.raphimc.vialoader.netty.VLLegacyPipeline;
+
+public class ViaForgeVLInjector extends VLInjector {
+
+ @Override
+ public String getDecoderName() {
+ return VLLegacyPipeline.VIA_DECODER_NAME;
+ }
+
+ @Override
+ public String getEncoderName() {
+ return VLLegacyPipeline.VIA_ENCODER_NAME;
+ }
+}
diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
new file mode 100644
index 0000000..37da249
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLegacyPipeline.java
@@ -0,0 +1,59 @@
+/*
+ * 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.protocolhack;
+
+import com.viaversion.viaversion.api.connection.UserConnection;
+import net.raphimc.vialoader.netty.VLLegacyPipeline;
+import net.raphimc.vialoader.util.VersionEnum;
+
+public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline {
+
+ public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) {
+ super(user, version);
+ }
+
+ @Override
+ protected String decompressName() {
+ return "decompress";
+ }
+
+ @Override
+ protected String compressName() {
+ return "compress";
+ }
+
+ @Override
+ protected String packetDecoderName() {
+ return "decoder";
+ }
+
+ @Override
+ protected String packetEncoderName() {
+ return "encoder";
+ }
+
+ @Override
+ protected String lengthSplitterName() {
+ return "splitter";
+ }
+
+ @Override
+ protected String lengthPrependerName() {
+ return "prepender";
+ }
+}
diff --git a/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
new file mode 100644
index 0000000..2158ad3
--- /dev/null
+++ b/viaforge-mc115/src/main/java/de/florianmichael/viaforge/protocolhack/ViaForgeVLLoader.java
@@ -0,0 +1,45 @@
+/*
+ * 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.protocolhack;
+
+import com.viaversion.viaversion.api.Via;
+import com.viaversion.viaversion.api.connection.UserConnection;
+import com.viaversion.viaversion.api.protocol.version.VersionProvider;
+import com.viaversion.viaversion.protocols.base.BaseVersionProvider;
+import de.florianmichael.viaforge.ViaForge;
+import net.minecraft.client.Minecraft;
+import net.raphimc.vialoader.impl.viaversion.VLLoader;
+
+public class ViaForgeVLLoader extends VLLoader {
+
+ @Override
+ public void load() {
+ super.load();
+
+ Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {
+ @Override
+ public int getClosestServerProtocol(UserConnection connection) throws Exception {
+ if (connection.isClientSide() && !Minecraft.getInstance().hasSingleplayerServer()) {
+ return ViaForge.targetVersion.getVersion();
+ }
+
+ return super.getClosestServerProtocol(connection);
+ }
+ });
+ }
+}
diff --git a/viaforge-mc115/src/main/resources/META-INF/mods.toml b/viaforge-mc115/src/main/resources/META-INF/mods.toml
new file mode 100644
index 0000000..b5beba3
--- /dev/null
+++ b/viaforge-mc115/src/main/resources/META-INF/mods.toml
@@ -0,0 +1,17 @@
+modLoader="javafml"
+loaderVersion="[1,)"
+
+license="GPL-3.0 license"
+issueTrackerURL="https://github.com/ViaVersion/ViaForge/issues"
+showAsResourcePack=false
+
+[[mods]]
+modId="viaforge"
+version="${version}"
+displayName="ViaForge"
+displayURL="https://github.com/FlorianMichael"
+credits="FlorianMichael/EnZaXD and all ViaVersion/ViaForge contributors"
+authors="FlorianMichael/EnZaXD"
+description='''
+ Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge
+ '''
\ No newline at end of file
diff --git a/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json b/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json
new file mode 100644
index 0000000..9a47e38
--- /dev/null
+++ b/viaforge-mc115/src/main/resources/mixins.viaforge-mc115.json
@@ -0,0 +1,17 @@
+{
+ "required": true,
+ "minVersion": "0.7.5",
+ "compatibilityLevel": "JAVA_8",
+ "package": "de.florianmichael.viaforge.mixin",
+ "mixins": [
+ "MixinNetworkManager",
+ "MixinNetworkManager_5",
+ "MixinMainMenuScreen",
+ "MixinMultiplayerScreen",
+ "MixinServerListScreen"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ },
+ "refmap": "mixins.viaforge-mc115.refmap.json"
+}
diff --git a/viaforge-mc115/src/main/resources/pack.mcmeta b/viaforge-mc115/src/main/resources/pack.mcmeta
new file mode 100644
index 0000000..646ce57
--- /dev/null
+++ b/viaforge-mc115/src/main/resources/pack.mcmeta
@@ -0,0 +1,6 @@
+{
+ "pack": {
+ "description": "ViaForge",
+ "pack_format": 6
+ }
+}
diff --git a/viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java b/viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
new file mode 100644
index 0000000..7dde3b2
--- /dev/null
+++ b/viaforge-mc116/src/main/java/de/florianmichael/viaforge/mixin/MixinNetworkManager_5.java
@@ -0,0 +1,44 @@
+/*
+ * 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.api.connection.UserConnection;
+import com.viaversion.viaversion.connection.UserConnectionImpl;
+import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
+import de.florianmichael.viaforge.ViaForge;
+import de.florianmichael.viaforge.protocolhack.ViaForgeVLLegacyPipeline;
+import io.netty.channel.Channel;
+import io.netty.channel.socket.SocketChannel;
+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(targets = "net.minecraft.network.NetworkManager$5", remap = false)
+public class MixinNetworkManager_5 {
+
+ @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
+ private void onInitChannel(Channel channel, CallbackInfo ci) {
+ if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) {
+ final UserConnection user = new UserConnectionImpl(channel, true);
+ new ProtocolPipelineImpl(user);
+
+ channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion));
+ }
+ }
+}
diff --git a/viaforge-mc116/src/main/resources/mixins.viaforge-mc116.json b/viaforge-mc116/src/main/resources/mixins.viaforge-mc116.json
index ebd2aa4..5c58f31 100644
--- a/viaforge-mc116/src/main/resources/mixins.viaforge-mc116.json
+++ b/viaforge-mc116/src/main/resources/mixins.viaforge-mc116.json
@@ -5,7 +5,7 @@
"package": "de.florianmichael.viaforge.mixin",
"mixins": [
"MixinNetworkManager",
- "MixinNetworkManager_1",
+ "MixinNetworkManager_5",
"MixinMainMenuScreen",
"MixinMultiplayerScreen",
"MixinServerListScreen"