From bcf2e96a5005451bca780e020441a2d258917203 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 28 May 2023 21:25:58 +0200 Subject: [PATCH] Updated changes from master branch --- build.gradle | 4 +- gradle.properties | 8 ++-- .../de/florianmichael/viaforge/ViaForge.java | 23 ++++++---- ...ine.java => ViaForgeVLLegacyPipeline.java} | 44 ++++++++++++------- .../viaforge/gui/GuiProtocolSelector.java | 12 ++--- .../mixin/impl/MixinNetworkManager.java | 4 +- .../mixin/impl/MixinNetworkManager_5.java | 9 ++-- 7 files changed, 60 insertions(+), 44 deletions(-) rename src/main/java/de/florianmichael/viaforge/{ViaForgeVLBPipeline.java => ViaForgeVLLegacyPipeline.java} (63%) diff --git a/build.gradle b/build.gradle index be200e3..da72d9a 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ repositories { minecraft { version = "1.8.9-11.15.1.2318-1.8.9" runDir = "run" - mappings = "stable_22" + mappings = "stable_20" makeObfSourceJar = false clientJvmArgs += ["-Dfml.coreMods.load=de.florianmichael.viaforge.mixin.MixinLoader"] } @@ -60,7 +60,7 @@ def viaLibs = [ "com.viaversion:viarewind-core:${project.viarewind_version}", "org.yaml:snakeyaml:${project.snake_yml_version}", - "com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}" + "net.raphimc:ViaLoader:${project.vialoader_version}" ] dependencies { diff --git a/gradle.properties b/gradle.properties index dbfafe6..b9249c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,15 +5,15 @@ org.gradle.daemon=false # forge mod_id=viaforge mod_name=ViaForge -mod_version=3.2.1 +mod_version=3.2.2 mod_base_package=de.florianmichael # mixin mixin_version=0.8.3 # via-version -vialoadingbase_version=ff86e681d7 -viaversion_version=4.7.0-23w18a-SNAPSHOT -viabackwards_version=4.7.0-23w18a-SNAPSHOT +vialoader_version=2.2.5-SNAPSHOT +viaversion_version=4.7.0-1.20-pre5-SNAPSHOT +viabackwards_version=4.7.0-1.20-pre5-SNAPSHOT viarewind_version=2.0.4-SNAPSHOT snake_yml_version=2.0 diff --git a/src/main/java/de/florianmichael/viaforge/ViaForge.java b/src/main/java/de/florianmichael/viaforge/ViaForge.java index 7ee83de..af34fde 100644 --- a/src/main/java/de/florianmichael/viaforge/ViaForge.java +++ b/src/main/java/de/florianmichael/viaforge/ViaForge.java @@ -17,18 +17,23 @@ */ package de.florianmichael.viaforge; -import de.florianmichael.vialoadingbase.ViaLoadingBase; -import net.minecraft.client.Minecraft; -import net.minecraft.realms.RealmsSharedConstants; +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; public class ViaForge { + public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_12_2; + + public static VersionEnum targetVersion = VersionEnum.r1_12_2; public static void start() { - ViaLoadingBase.ViaLoadingBaseBuilder. - create(). - runDirectory(Minecraft.getMinecraft().mcDataDir). - nativeVersion(RealmsSharedConstants.NETWORK_PROTOCOL_VERSION). - forceNativeVersionCondition(() -> Minecraft.getMinecraft().isSingleplayer()). - build(); + ViaLoader.init( + null, + null, + null, + null, + ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new + ); } } diff --git a/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java b/src/main/java/de/florianmichael/viaforge/ViaForgeVLLegacyPipeline.java similarity index 63% rename from src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java rename to src/main/java/de/florianmichael/viaforge/ViaForgeVLLegacyPipeline.java index d0bdec2..b1a77f2 100644 --- a/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java +++ b/src/main/java/de/florianmichael/viaforge/ViaForgeVLLegacyPipeline.java @@ -18,30 +18,42 @@ package de.florianmichael.viaforge; import com.viaversion.viaversion.api.connection.UserConnection; -import de.florianmichael.vialoadingbase.netty.VLBPipeline; +import net.raphimc.vialoader.netty.VLLegacyPipeline; +import net.raphimc.vialoader.util.VersionEnum; -public class ViaForgeVLBPipeline extends VLBPipeline { - public ViaForgeVLBPipeline(UserConnection info) { - super(info); +public class ViaForgeVLLegacyPipeline extends VLLegacyPipeline { + + public ViaForgeVLLegacyPipeline(UserConnection user, VersionEnum version) { + super(user, version); } @Override - public String getDecoderHandlerName() { - return "decoder"; - } - - @Override - public String getEncoderHandlerName() { - return "encoder"; - } - - @Override - public String getDecompressionHandlerName() { + protected String decompressName() { return "decompress"; } @Override - public String getCompressionHandlerName() { + 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/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index 3866138..248f775 100644 --- a/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -18,12 +18,12 @@ package de.florianmichael.viaforge.gui; import com.mojang.realmsclient.gui.ChatFormatting; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.vialoadingbase.ViaLoadingBase; +import de.florianmichael.viaforge.ViaForge; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiSlot; +import net.raphimc.vialoader.util.VersionEnum; import org.lwjgl.opengl.GL11; import java.io.IOException; @@ -85,12 +85,12 @@ public class GuiProtocolSelector extends GuiScreen { @Override protected int getSize() { - return ViaLoadingBase.getProtocols().size(); + return VersionEnum.SORTED_VERSIONS.size(); } @Override protected void elementClicked(int i, boolean b, int i1, int i2) { - ViaLoadingBase.getInstance().reload(ViaLoadingBase.getProtocols().get(i)); + ViaForge.targetVersion = VersionEnum.SORTED_VERSIONS.get(i); } @Override @@ -105,9 +105,9 @@ public class GuiProtocolSelector extends GuiScreen { @Override protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5) { - final ProtocolVersion version = ViaLoadingBase.getProtocols().get(i); + final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(i); - drawCenteredString(mc.fontRendererObj, (ViaLoadingBase.getInstance().getTargetVersion().getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1); + drawCenteredString(mc.fontRendererObj, (ViaForge.targetVersion.getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1); } } } diff --git a/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java b/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java index 7b23ae2..125b249 100644 --- a/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java +++ b/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java @@ -17,9 +17,9 @@ */ package de.florianmichael.viaforge.mixin.impl; -import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent; 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; @@ -33,6 +33,6 @@ public class MixinNetworkManager { @Inject(method = "setCompressionTreshold", at = @At("RETURN")) public void reOrderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) { - channel.pipeline().fireUserEventTriggered(new CompressionReorderEvent()); + channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE); } } diff --git a/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java b/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java index 9e27abe..63c484d 100644 --- a/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java +++ b/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java @@ -20,11 +20,10 @@ package de.florianmichael.viaforge.mixin.impl; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; -import de.florianmichael.viaforge.ViaForgeVLBPipeline; -import de.florianmichael.vialoadingbase.ViaLoadingBase; +import de.florianmichael.viaforge.ViaForge; +import de.florianmichael.viaforge.ViaForgeVLLegacyPipeline; import io.netty.channel.Channel; import io.netty.channel.socket.SocketChannel; -import net.minecraft.realms.RealmsSharedConstants; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -35,11 +34,11 @@ public class MixinNetworkManager_5 { @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) private void onInitChannel(Channel channel, CallbackInfo ci) { - if (channel instanceof SocketChannel && ViaLoadingBase.getInstance().getTargetVersion().getVersion() != RealmsSharedConstants.NETWORK_PROTOCOL_VERSION) { + if (channel instanceof SocketChannel && ViaForge.targetVersion != ViaForge.NATIVE_VERSION) { final UserConnection user = new UserConnectionImpl(channel, true); new ProtocolPipelineImpl(user); - channel.pipeline().addLast(new ViaForgeVLBPipeline(user)); + channel.pipeline().addLast(new ViaForgeVLLegacyPipeline(user, ViaForge.targetVersion)); } } }