From 4c35f7571742405affe94d026da4627c3fe97fa0 Mon Sep 17 00:00:00 2001 From: James58899 Date: Thu, 9 Jun 2022 19:32:21 +0800 Subject: [PATCH] Enable velocity forward protocol 2 --- gradle.properties | 2 +- src/main/java/one/oktw/FabricProxyLite.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index b8dab35..602d4b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.19 yarn_mappings=1.19+build.1 loader_version=0.14.6 # Mod Properties -mod_version=2.0.0 +mod_version=2.1.0 maven_group=one.oktw archives_base_name=FabricProxy-Lite # Dependencies diff --git a/src/main/java/one/oktw/FabricProxyLite.java b/src/main/java/one/oktw/FabricProxyLite.java index c85dde7..bbc6a23 100644 --- a/src/main/java/one/oktw/FabricProxyLite.java +++ b/src/main/java/one/oktw/FabricProxyLite.java @@ -2,11 +2,12 @@ import com.moandjiezana.toml.Toml; import com.moandjiezana.toml.TomlWriter; +import io.netty.buffer.Unpooled; import net.fabricmc.api.DedicatedServerModInitializer; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerLoginConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.network.PacketByteBuf; import org.apache.logging.log4j.LogManager; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; @@ -22,10 +23,11 @@ public class FabricProxyLite implements DedicatedServerModInitializer, IMixinCon @Override public void onInitializeServer() { + PacketByteBuf packet = new PacketByteBuf(Unpooled.wrappedBuffer(new byte[]{(byte) VelocityLib.MODERN_FORWARDING_WITH_KEY}).asReadOnly()); // Packet receiver ServerLoginNetworking.registerGlobalReceiver(VelocityLib.PLAYER_INFO_CHANNEL, new PacketHandler(config)::handleVelocityPacket); if (!config.getHackEarlySend()) { - ServerLoginConnectionEvents.QUERY_START.register((handler, server, sender, synchronizer) -> sender.sendPacket(VelocityLib.PLAYER_INFO_CHANNEL, PacketByteBufs.empty())); + ServerLoginConnectionEvents.QUERY_START.register((handler, server, sender, synchronizer) -> sender.sendPacket(VelocityLib.PLAYER_INFO_CHANNEL, packet)); } }