From 548e75d279d95c98a6c600a54a3506abaad4455b Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 28 May 2023 20:27:34 +0200 Subject: [PATCH] Migrate to ViaVersion organisation --- README.md | 6 +-- gradle.properties | 8 ++-- mc1122/build.gradle | 5 +- .../de/florianmichael/viaforge/ViaForge.java | 26 ++++++----- ...ine.java => ViaForgeVLLegacyPipeline.java} | 46 ++++++++++++------- .../viaforge/gui/GuiProtocolSelector.java | 12 ++--- .../mixin/impl/MixinNetworkManager.java | 4 +- .../mixin/impl/MixinNetworkManager_5.java | 9 ++-- mc1122/src/main/resources/mcmod.info | 2 +- 9 files changed, 65 insertions(+), 53 deletions(-) rename mc1122/src/main/java/de/florianmichael/viaforge/{ViaForgeVLBPipeline.java => ViaForgeVLLegacyPipeline.java} (63%) diff --git a/README.md b/README.md index d2b16af..e8ce9b8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # ViaForge -Clientside Implementation of ViaVersion for Forge +Client-side Implementation of ViaVersion for Forge ## Contact If you encounter any issues, please report them on the [issue tracker](https://github.com/FlorianMichael/ViaForge/issues). -If you just want to talk or need help with ViaForge feel free to join my -[Discord](https://discord.gg/BwWhCHUKDf). +If you just want to talk or need help with ViaForge feel free to join the ViaVersion +[Discord](https://discord.gg/viaversion). ## For users ### Where can I download the latest version? 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/mc1122/build.gradle b/mc1122/build.gradle index 968cf89..521ff72 100644 --- a/mc1122/build.gradle +++ b/mc1122/build.gradle @@ -75,9 +75,6 @@ repositories { maven { url = "https://repo.viaversion.com" } - maven { - url = "https://jitpack.io" - } } configurations { @@ -91,7 +88,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/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java index 041a119..e319aa7 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java @@ -17,23 +17,27 @@ */ package de.florianmichael.viaforge; -import de.florianmichael.vialoadingbase.ViaLoadingBase; -import io.netty.channel.DefaultEventLoop; -import net.minecraft.client.Minecraft; -import net.minecraft.realms.RealmsSharedConstants; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +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(modid = "viaforge", name = "ViaForge", version = "3.0.0") +@Mod(modid = "viaforge", name = "ViaForge", version = "3.2.2") public class ViaForge { + public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_12_2; + + public static VersionEnum targetVersion = VersionEnum.r1_12_2; @Mod.EventHandler public void init(FMLPreInitializationEvent event) { - ViaLoadingBase.ViaLoadingBaseBuilder. - create(). - runDirectory(Minecraft.getMinecraft().gameDir). - nativeVersion(RealmsSharedConstants.NETWORK_PROTOCOL_VERSION). - forceNativeVersionCondition(() -> Minecraft.getMinecraft().isSingleplayer()). - build(); + ViaLoader.init( + null, + null, + null, + null, + ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new + ); } } diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLLegacyPipeline.java similarity index 63% rename from mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java rename to mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLLegacyPipeline.java index 65cb089..b1a77f2 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java +++ b/mc1122/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"; } -} \ No newline at end of file + + @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/mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java b/mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index 8c20c9b..c9da23d 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java +++ b/mc1122/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; @@ -80,12 +80,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 @@ -100,9 +100,9 @@ public class GuiProtocolSelector extends GuiScreen { @Override protected void drawSlot(int i, int i1, int i2, int i3, int i4, int i5, float v) { - final ProtocolVersion version = ViaLoadingBase.getProtocols().get(i); + final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(i); - drawCenteredString(mc.fontRenderer,(ViaLoadingBase.getInstance().getTargetVersion().getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1); + drawCenteredString(mc.fontRenderer,(ViaForge.targetVersion.getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1); } } } diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java index bf781af..d522255 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager.java +++ b/mc1122/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 = "setCompressionThreshold", 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/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java index 9e27abe..63c484d 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManager_5.java +++ b/mc1122/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)); } } } diff --git a/mc1122/src/main/resources/mcmod.info b/mc1122/src/main/resources/mcmod.info index 401c85d..ab8ca8f 100644 --- a/mc1122/src/main/resources/mcmod.info +++ b/mc1122/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid": "viaforge", "name": "ViaForge", - "description": "Clientside Implementation of ViaVersion for Forge", + "description": "Client-side Implementation of ViaVersion for Forge", "version": "1.0.0", "mcversion": "[1.8,1.12.2]", "url": "https://github.com/FlorianMichael/ViaForge",