From 5c76a3745e9958ddaa63e1c449a2ead702fa42dd Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 20 Apr 2023 22:23:55 +0200 Subject: [PATCH] Updated Via* (23w16a) --- gradle.properties | 10 ++-- mc1122/build.gradle | 7 ++- .../de/florianmichael/viaforge/ViaForge.java | 17 +++++++ .../viaforge/ViaForgeVLBPipeline.java | 47 +++++++++++++++++++ .../{ => gui}/GuiProtocolSelector.java | 28 ++++++++--- .../viaforge/mixin/MixinLoader.java | 17 +++++++ .../viaforge/mixin/impl/MixinGuiMainMenu.java | 19 +++++++- .../mixin/impl/MixinGuiMultiplayer.java | 19 +++++++- .../mixin/impl/MixinGuiScreenServerList.java | 19 +++++++- .../mixin/impl/MixinNetworkManager.java | 21 ++++++++- .../mixin/impl/MixinNetworkManagerSub5.java | 30 ++++++++---- 11 files changed, 205 insertions(+), 29 deletions(-) create mode 100644 mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java rename mc1122/src/main/java/de/florianmichael/viaforge/{ => gui}/GuiProtocolSelector.java (68%) diff --git a/gradle.properties b/gradle.properties index 6eaa55c..fbff62a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,16 +5,16 @@ org.gradle.daemon=false # forge mod_id=viaforge mod_name=ViaForge -mod_version=3.1.0 -mod_base_package=de.enzaxd +mod_version=3.1.1 +mod_base_package=de.florianmichael # mixin mixin_version=0.8.3 # via-version -vialoadingbase_version=6dad0a2561 -viaversion_version=4.6.2-SNAPSHOT -viabackwards_version=4.6.2-SNAPSHOT +vialoadingbase_version=ff86e681d7 +viaversion_version=4.7.0-23w16a-SNAPSHOT +viabackwards_version=4.7.0-23w16a-SNAPSHOT viarewind_version=2.0.4-SNAPSHOT snake_yml_version=2.0 diff --git a/mc1122/build.gradle b/mc1122/build.gradle index 501d813..968cf89 100644 --- a/mc1122/build.gradle +++ b/mc1122/build.gradle @@ -6,8 +6,8 @@ buildscript { maven { url = "https://maven.minecraftforge.net/" } maven { url = "https://repo.spongepowered.org/repository/maven-public/" } maven { url = "https://jitpack.io/" } - maven { url 'https://files.minecraftforge.net/maven' } - maven { url 'https://plugins.gradle.org/m2' } + maven { url = "https://files.minecraftforge.net/maven" } + maven { url = "https://plugins.gradle.org/m2" } } dependencies { @@ -65,7 +65,7 @@ minecraft { } sourceSets.main.resources { - srcDir 'src/generated/resources' + srcDir "src/generated/resources" } repositories { @@ -85,7 +85,6 @@ configurations { implementation.extendsFrom(include) } -// ViaProtocolHack READ-ME def viaLibs = [ "com.viaversion:viaversion:${project.viaversion_version}", "com.viaversion:viabackwards:${project.viabackwards_version}", diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java index 1e766cd..041a119 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForge.java @@ -1,3 +1,20 @@ +/* + * 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.vialoadingbase.ViaLoadingBase; diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java new file mode 100644 index 0000000..65cb089 --- /dev/null +++ b/mc1122/src/main/java/de/florianmichael/viaforge/ViaForgeVLBPipeline.java @@ -0,0 +1,47 @@ +/* + * 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 com.viaversion.viaversion.api.connection.UserConnection; +import de.florianmichael.vialoadingbase.netty.VLBPipeline; + +public class ViaForgeVLBPipeline extends VLBPipeline { + public ViaForgeVLBPipeline(UserConnection info) { + super(info); + } + + @Override + public String getDecoderHandlerName() { + return "decoder"; + } + + @Override + public String getEncoderHandlerName() { + return "encoder"; + } + + @Override + public String getDecompressionHandlerName() { + return "decompress"; + } + + @Override + public String getCompressionHandlerName() { + return "compress"; + } +} \ No newline at end of file diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/GuiProtocolSelector.java b/mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java similarity index 68% rename from mc1122/src/main/java/de/florianmichael/viaforge/GuiProtocolSelector.java rename to mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java index d64499b..8c20c9b 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/GuiProtocolSelector.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/gui/GuiProtocolSelector.java @@ -1,9 +1,25 @@ -package de.florianmichael.viaforge; +/* + * 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.protocol.version.ProtocolVersion; import de.florianmichael.vialoadingbase.ViaLoadingBase; -import de.florianmichael.vialoadingbase.platform.InternalProtocolList; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -64,12 +80,12 @@ public class GuiProtocolSelector extends GuiScreen { @Override protected int getSize() { - return InternalProtocolList.getProtocols().size(); + return ViaLoadingBase.getProtocols().size(); } @Override protected void elementClicked(int i, boolean b, int i1, int i2) { - ViaLoadingBase.getClassWrapper().reload(InternalProtocolList.getProtocols().get(i)); + ViaLoadingBase.getInstance().reload(ViaLoadingBase.getProtocols().get(i)); } @Override @@ -84,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 = InternalProtocolList.getProtocols().get(i); + final ProtocolVersion version = ViaLoadingBase.getProtocols().get(i); - drawCenteredString(mc.fontRenderer,(ViaLoadingBase.getClassWrapper().getTargetVersion().getVersion() == version.getVersion() ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, i2, -1); + drawCenteredString(mc.fontRenderer,(ViaLoadingBase.getInstance().getTargetVersion().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/MixinLoader.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/MixinLoader.java index e4b66a7..215a971 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/MixinLoader.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/MixinLoader.java @@ -1,3 +1,20 @@ +/* + * 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 net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMainMenu.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMainMenu.java index d759a72..3f35838 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMainMenu.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMainMenu.java @@ -1,6 +1,23 @@ +/* + * 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.impl; -import de.florianmichael.viaforge.GuiProtocolSelector; +import de.florianmichael.viaforge.gui.GuiProtocolSelector; import net.minecraft.client.gui.*; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMultiplayer.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMultiplayer.java index ddbdc68..3195d6b 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMultiplayer.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiMultiplayer.java @@ -1,6 +1,23 @@ +/* + * 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.impl; -import de.florianmichael.viaforge.GuiProtocolSelector; +import de.florianmichael.viaforge.gui.GuiProtocolSelector; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiScreenServerList.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiScreenServerList.java index e8c4d3c..f03434b 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiScreenServerList.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinGuiScreenServerList.java @@ -1,6 +1,23 @@ +/* + * 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.impl; -import de.florianmichael.viaforge.GuiProtocolSelector; +import de.florianmichael.viaforge.gui.GuiProtocolSelector; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreenServerList; 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 a19d0e4..bf781af 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 @@ -1,6 +1,23 @@ +/* + * 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.impl; -import de.florianmichael.vialoadingbase.event.PipelineReorderEvent; +import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent; import io.netty.channel.Channel; import net.minecraft.network.NetworkManager; import org.spongepowered.asm.mixin.Mixin; @@ -16,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 PipelineReorderEvent()); + channel.pipeline().fireUserEventTriggered(new CompressionReorderEvent()); } } diff --git a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManagerSub5.java b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManagerSub5.java index 86adb9f..59b3c8c 100644 --- a/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManagerSub5.java +++ b/mc1122/src/main/java/de/florianmichael/viaforge/mixin/impl/MixinNetworkManagerSub5.java @@ -1,12 +1,27 @@ +/* + * 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.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.vialoadingbase.netty.NettyConstants; -import de.florianmichael.vialoadingbase.netty.VLBViaDecodeHandler; -import de.florianmichael.vialoadingbase.netty.VLBViaEncodeHandler; import io.netty.channel.Channel; import io.netty.channel.socket.SocketChannel; import net.minecraft.realms.RealmsSharedConstants; @@ -20,14 +35,11 @@ public class MixinNetworkManagerSub5 { @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) private void onInitChannel(Channel channel, CallbackInfo ci) { - if (channel instanceof SocketChannel && ViaLoadingBase.getClassWrapper().getTargetVersion().getVersion() != RealmsSharedConstants.NETWORK_PROTOCOL_VERSION) { - - UserConnection user = new UserConnectionImpl(channel, true); + if (channel instanceof SocketChannel && ViaLoadingBase.getInstance().getTargetVersion().getVersion() != RealmsSharedConstants.NETWORK_PROTOCOL_VERSION) { + final UserConnection user = new UserConnectionImpl(channel, true); new ProtocolPipelineImpl(user); - channel.pipeline() - .addBefore("encoder", NettyConstants.HANDLER_ENCODER_NAME, new VLBViaEncodeHandler(user)) - .addBefore("decoder", NettyConstants.HANDLER_DECODER_NAME, new VLBViaDecodeHandler(user)); + channel.pipeline().addLast(new ViaForgeVLBPipeline(user)); } } }