From 0e5e960afa984bad9f36548fbb167f3905430630 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Wed, 22 May 2024 21:08:57 +0200 Subject: [PATCH] Updated NetMinecraft API usage --- ...ixinC2SHandshakingClientIntentionPacket.java} | 6 +++--- .../Client2ProxyChannelInitializer.java | 2 +- .../proxy/client2proxy/Client2ProxyHandler.java | 8 ++++---- .../packethandler/CompressionPacketHandler.java | 4 ++-- .../ConfigurationPacketHandler.java | 12 ++++++------ .../proxy/packethandler/LoginPacketHandler.java | 16 ++++++++-------- .../packethandler/OpenAuthModPacketHandler.java | 10 +++++----- .../proxy/packethandler/StatusPacketHandler.java | 4 ++-- .../packethandler/TransferPacketHandler.java | 14 +++++++------- .../Proxy2ServerChannelInitializer.java | 2 +- .../viaproxy/proxy/session/ProxyConnection.java | 4 ++-- 11 files changed, 41 insertions(+), 41 deletions(-) rename src/main/java/net/raphimc/viaproxy/injection/mixins/{MixinC2SHandshakePacket.java => MixinC2SHandshakingClientIntentionPacket.java} (84%) diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakePacket.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakingClientIntentionPacket.java similarity index 84% rename from src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakePacket.java rename to src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakingClientIntentionPacket.java index 2164987..ab2b7b3 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakePacket.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinC2SHandshakingClientIntentionPacket.java @@ -17,13 +17,13 @@ */ package net.raphimc.viaproxy.injection.mixins; -import net.raphimc.netminecraft.packet.impl.handshake.C2SHandshakePacket; +import net.raphimc.netminecraft.packet.impl.handshaking.C2SHandshakingClientIntentionPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(C2SHandshakePacket.class) -public abstract class MixinC2SHandshakePacket { +@Mixin(C2SHandshakingClientIntentionPacket.class) +public abstract class MixinC2SHandshakingClientIntentionPacket { @ModifyConstant(method = "read", constant = @Constant(intValue = 255)) private int allowLargerHostnames(int constant) { diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java index 2c87d04..7af9dc3 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java @@ -56,7 +56,7 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer } super.initChannel(channel); - channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false)); + channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakingRegistry(false)); if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) { channel.close(); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index bebcc5d..0c08384 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -29,7 +29,7 @@ import io.netty.channel.SimpleChannelInboundHandler; import net.raphimc.netminecraft.constants.ConnectionState; import net.raphimc.netminecraft.constants.IntendedState; import net.raphimc.netminecraft.packet.IPacket; -import net.raphimc.netminecraft.packet.impl.handshake.C2SHandshakePacket; +import net.raphimc.netminecraft.packet.impl.handshaking.C2SHandshakingClientIntentionPacket; import net.raphimc.viabedrock.api.BedrockProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.viaproxy.ViaProxy; @@ -91,7 +91,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { if (this.proxyConnection.isClosed()) return; if (this.proxyConnection.getC2pConnectionState() == ConnectionState.HANDSHAKING) { - if (packet instanceof C2SHandshakePacket) this.handleHandshake((C2SHandshakePacket) packet); + if (packet instanceof C2SHandshakingClientIntentionPacket) this.handleHandshake((C2SHandshakingClientIntentionPacket) packet); else throw new IllegalStateException("Unexpected packet in HANDSHAKING state"); return; } @@ -110,7 +110,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { ExceptionUtil.handleNettyException(ctx, cause, this.proxyConnection); } - private void handleHandshake(final C2SHandshakePacket packet) { + private void handleHandshake(final C2SHandshakingClientIntentionPacket packet) { final ProtocolVersion clientVersion = ProtocolVersion.getProtocol(packet.protocolVersion); if (packet.intendedState == null) { @@ -267,7 +267,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { } handshakeParts[0] = address; - final C2SHandshakePacket newHandshakePacket = new C2SHandshakePacket(clientVersion.getOriginalVersion(), String.join("\0", handshakeParts), port, intendedState); + final C2SHandshakingClientIntentionPacket newHandshakePacket = new C2SHandshakingClientIntentionPacket(clientVersion.getOriginalVersion(), String.join("\0", handshakeParts), port, intendedState); this.proxyConnection.getChannel().writeAndFlush(newHandshakePacket).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f2 -> { if (f2.isSuccess()) { diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/CompressionPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/CompressionPacketHandler.java index e551d22..e0f9d57 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/CompressionPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/CompressionPacketHandler.java @@ -28,7 +28,7 @@ import net.raphimc.netminecraft.packet.IPacket; import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.UnknownPacket; import net.raphimc.netminecraft.packet.impl.login.S2CLoginCompressionPacket; -import net.raphimc.netminecraft.packet.impl.login.S2CLoginSuccessPacket1_7; +import net.raphimc.netminecraft.packet.impl.login.S2CLoginGameProfilePacket1_7; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.proxy.session.ProxyConnection; import net.raphimc.viaproxy.proxy.util.ChannelUtil; @@ -56,7 +56,7 @@ public class CompressionPacketHandler extends PacketHandler { return false; } - } else if (packet instanceof S2CLoginSuccessPacket1_7) { + } else if (packet instanceof S2CLoginGameProfilePacket1_7) { if (this.proxyConnection.getClientVersion().newerThanOrEqualTo(ProtocolVersion.v1_8)) { if (ViaProxy.getConfig().getCompressionThreshold() > -1 && this.proxyConnection.getC2P().attr(MCPipeline.COMPRESSION_THRESHOLD_ATTRIBUTE_KEY).get() == -1) { ChannelUtil.disableAutoRead(this.proxyConnection.getChannel()); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/ConfigurationPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/ConfigurationPacketHandler.java index ce7d7a2..6d02ce0 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/ConfigurationPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/ConfigurationPacketHandler.java @@ -22,9 +22,9 @@ import net.raphimc.netminecraft.constants.ConnectionState; import net.raphimc.netminecraft.constants.MCPackets; import net.raphimc.netminecraft.packet.IPacket; import net.raphimc.netminecraft.packet.UnknownPacket; -import net.raphimc.netminecraft.packet.impl.configuration.C2SConfigFinishConfiguration1_20_2; -import net.raphimc.netminecraft.packet.impl.configuration.S2CConfigFinishConfiguration1_20_2; -import net.raphimc.netminecraft.packet.impl.login.C2SLoginStartConfiguration1_20_2; +import net.raphimc.netminecraft.packet.impl.configuration.C2SConfigFinishConfigurationPacket; +import net.raphimc.netminecraft.packet.impl.configuration.S2CConfigFinishConfigurationPacket; +import net.raphimc.netminecraft.packet.impl.login.C2SLoginAcknowledgedPacket; import net.raphimc.viaproxy.proxy.session.ProxyConnection; import net.raphimc.viaproxy.proxy.util.ChannelUtil; import net.raphimc.viaproxy.util.logging.Logger; @@ -56,7 +56,7 @@ public class ConfigurationPacketHandler extends PacketHandler { } }); } - } else if (packet instanceof C2SLoginStartConfiguration1_20_2) { + } else if (packet instanceof C2SLoginAcknowledgedPacket) { this.proxyConnection.setC2pConnectionState(ConnectionState.CONFIGURATION); listeners.add(f -> { if (f.isSuccess()) { @@ -64,7 +64,7 @@ public class ConfigurationPacketHandler extends PacketHandler { ChannelUtil.restoreAutoRead(this.proxyConnection.getChannel()); } }); - } else if (packet instanceof C2SConfigFinishConfiguration1_20_2) { + } else if (packet instanceof C2SConfigFinishConfigurationPacket) { this.proxyConnection.setC2pConnectionState(ConnectionState.PLAY); listeners.add(f -> { if (f.isSuccess()) { @@ -84,7 +84,7 @@ public class ConfigurationPacketHandler extends PacketHandler { if (unknownPacket.packetId == this.startConfigurationId) { ChannelUtil.disableAutoRead(this.proxyConnection.getChannel()); } - } else if (packet instanceof S2CConfigFinishConfiguration1_20_2) { + } else if (packet instanceof S2CConfigFinishConfigurationPacket) { ChannelUtil.disableAutoRead(this.proxyConnection.getChannel()); } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java index c155c7e..27586eb 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java @@ -85,7 +85,7 @@ public class LoginPacketHandler extends PacketHandler { } if (ViaProxy.getConfig().isProxyOnlineMode() && !ViaProxy.EVENT_MANAGER.call(new ShouldVerifyOnlineModeEvent(this.proxyConnection)).isCancelled()) { - this.proxyConnection.getC2P().writeAndFlush(new S2CLoginKeyPacket1_8("", KEY_PAIR.getPublic().getEncoded(), this.verifyToken)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + this.proxyConnection.getC2P().writeAndFlush(new S2CLoginHelloPacket1_20_5("", KEY_PAIR.getPublic().getEncoded(), this.verifyToken, true)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } else { ViaProxy.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection)); ExternalInterface.fillPlayerData(this.proxyConnection); @@ -143,10 +143,10 @@ public class LoginPacketHandler extends PacketHandler { public boolean handleP2S(IPacket packet, List listeners) throws GeneralSecurityException, ExecutionException, InterruptedException { if (packet instanceof S2CLoginDisconnectPacket1_7 loginDisconnectPacket) { Logger.u_info("server kick", this.proxyConnection, ConsoleFormatter.convert(loginDisconnectPacket.reason.asLegacyFormatString())); - } else if (packet instanceof S2CLoginKeyPacket1_7 loginKeyPacket) { - final PublicKey publicKey = CryptUtil.decodeRsaPublicKey(loginKeyPacket.publicKey); + } else if (packet instanceof S2CLoginHelloPacket1_7 loginHelloPacket) { + final PublicKey publicKey = CryptUtil.decodeRsaPublicKey(loginHelloPacket.publicKey); final SecretKey secretKey = CryptUtil.generateSecretKey(); - final String serverHash = new BigInteger(CryptUtil.computeServerIdHash(loginKeyPacket.serverId, publicKey, secretKey)).toString(16); + final String serverHash = new BigInteger(CryptUtil.computeServerIdHash(loginHelloPacket.serverId, publicKey, secretKey)).toString(16); boolean auth = true; if (this.proxyConnection.getServerVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) { @@ -157,11 +157,11 @@ public class LoginPacketHandler extends PacketHandler { } final byte[] encryptedSecretKey = CryptUtil.encryptData(publicKey, secretKey.getEncoded()); - final byte[] encryptedNonce = CryptUtil.encryptData(publicKey, loginKeyPacket.nonce); + final byte[] encryptedNonce = CryptUtil.encryptData(publicKey, loginHelloPacket.nonce); final C2SLoginKeyPacket1_19_3 loginKey = new C2SLoginKeyPacket1_19_3(encryptedSecretKey, encryptedNonce); if (this.proxyConnection.getServerVersion().newerThanOrEqualTo(ProtocolVersion.v1_19) && this.proxyConnection.getLoginHelloPacket() instanceof C2SLoginHelloPacket1_19 && ((C2SLoginHelloPacket1_19) this.proxyConnection.getLoginHelloPacket()).key != null) { - ExternalInterface.signNonce(loginKeyPacket.nonce, loginKey, this.proxyConnection); + ExternalInterface.signNonce(loginHelloPacket.nonce, loginKey, this.proxyConnection); } this.proxyConnection.getChannel().writeAndFlush(loginKey).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); @@ -172,10 +172,10 @@ public class LoginPacketHandler extends PacketHandler { } return false; - } else if (packet instanceof S2CLoginSuccessPacket1_7 loginSuccessPacket) { + } else if (packet instanceof S2CLoginGameProfilePacket1_7 loginGameProfilePacket) { final ConnectionState nextState = this.proxyConnection.getClientVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_2) ? ConnectionState.CONFIGURATION : ConnectionState.PLAY; - this.proxyConnection.setGameProfile(new GameProfile(loginSuccessPacket.uuid, loginSuccessPacket.name)); + this.proxyConnection.setGameProfile(new GameProfile(loginGameProfilePacket.uuid, loginGameProfilePacket.name)); Logger.u_info("session", this.proxyConnection, "Connected successfully! Switching to " + nextState + " state"); ChannelUtil.disableAutoRead(this.proxyConnection.getChannel()); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/OpenAuthModPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/OpenAuthModPacketHandler.java index 067fca5..36c90ea 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/OpenAuthModPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/OpenAuthModPacketHandler.java @@ -28,9 +28,9 @@ import net.raphimc.netminecraft.constants.MCPackets; import net.raphimc.netminecraft.packet.IPacket; import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.UnknownPacket; -import net.raphimc.netminecraft.packet.impl.login.C2SLoginCustomPayloadPacket; +import net.raphimc.netminecraft.packet.impl.login.C2SLoginCustomQueryAnswerPacket; import net.raphimc.netminecraft.packet.impl.login.C2SLoginKeyPacket1_7; -import net.raphimc.netminecraft.packet.impl.login.S2CLoginCustomPayloadPacket; +import net.raphimc.netminecraft.packet.impl.login.S2CLoginCustomQueryPacket; import net.raphimc.netminecraft.packet.impl.login.S2CLoginDisconnectPacket1_20_3; import net.raphimc.viaproxy.proxy.external_interface.OpenAuthModConstants; import net.raphimc.viaproxy.proxy.session.ProxyConnection; @@ -67,8 +67,8 @@ public class OpenAuthModPacketHandler extends PacketHandler { return false; } } - } else if (packet instanceof C2SLoginCustomPayloadPacket loginCustomPayload) { - if (loginCustomPayload.response != null && this.handleCustomPayload(loginCustomPayload.queryId, Unpooled.wrappedBuffer(loginCustomPayload.response))) { + } else if (packet instanceof C2SLoginCustomQueryAnswerPacket loginCustomQueryAnswer) { + if (loginCustomQueryAnswer.response != null && this.handleCustomPayload(loginCustomQueryAnswer.queryId, Unpooled.wrappedBuffer(loginCustomQueryAnswer.response))) { return false; } } else if (packet instanceof C2SLoginKeyPacket1_7 loginKeyPacket) { @@ -90,7 +90,7 @@ public class OpenAuthModPacketHandler extends PacketHandler { switch (this.proxyConnection.getC2pConnectionState()) { case LOGIN: if (this.proxyConnection.getClientVersion().newerThanOrEqualTo(ProtocolVersion.v1_13)) { - this.proxyConnection.getC2P().writeAndFlush(new S2CLoginCustomPayloadPacket(id, channel, PacketTypes.readReadableBytes(data))).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + this.proxyConnection.getC2P().writeAndFlush(new S2CLoginCustomQueryPacket(id, channel, PacketTypes.readReadableBytes(data))).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } else { final ByteBuf disconnectPacketData = Unpooled.buffer(); PacketTypes.writeString(disconnectPacketData, channel); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/StatusPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/StatusPacketHandler.java index a9d86b9..96929c8 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/StatusPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/StatusPacketHandler.java @@ -21,7 +21,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.netty.channel.ChannelFutureListener; import net.raphimc.netminecraft.packet.IPacket; -import net.raphimc.netminecraft.packet.impl.status.S2CStatusPongPacket; +import net.raphimc.netminecraft.packet.impl.status.S2CStatusPongResponsePacket; import net.raphimc.netminecraft.packet.impl.status.S2CStatusResponsePacket; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.proxy.session.ProxyConnection; @@ -36,7 +36,7 @@ public class StatusPacketHandler extends PacketHandler { @Override public boolean handleP2S(IPacket packet, List listeners) { - if (packet instanceof S2CStatusPongPacket) { + if (packet instanceof S2CStatusPongResponsePacket) { listeners.add(ChannelFutureListener.CLOSE); } else if (packet instanceof S2CStatusResponsePacket statusResponsePacket && !ViaProxy.getConfig().getCustomMotd().isBlank()) { try { diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/TransferPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/TransferPacketHandler.java index 1580281..0ff3696 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/TransferPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/TransferPacketHandler.java @@ -25,7 +25,7 @@ import net.raphimc.netminecraft.constants.MCPackets; import net.raphimc.netminecraft.packet.IPacket; import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.UnknownPacket; -import net.raphimc.netminecraft.packet.impl.configuration.S2CConfigTransfer1_20_5; +import net.raphimc.netminecraft.packet.impl.common.S2CTransferPacket; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.proxy.session.ProxyConnection; import net.raphimc.viaproxy.proxy.util.TransferDataHolder; @@ -48,7 +48,7 @@ public class TransferPacketHandler extends PacketHandler { public boolean handleP2S(IPacket packet, List listeners) { if (packet instanceof UnknownPacket unknownPacket && this.proxyConnection.getP2sConnectionState() == ConnectionState.PLAY) { if (unknownPacket.packetId == this.transferId) { - final S2CConfigTransfer1_20_5 transfer = new S2CConfigTransfer1_20_5(); + final S2CTransferPacket transfer = new S2CTransferPacket(); transfer.read(Unpooled.wrappedBuffer(unknownPacket.data)); this.handleTransfer(transfer); @@ -58,7 +58,7 @@ public class TransferPacketHandler extends PacketHandler { this.proxyConnection.getC2P().writeAndFlush(transferToViaProxy).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); return false; } - } else if (packet instanceof S2CConfigTransfer1_20_5 transfer) { + } else if (packet instanceof S2CTransferPacket transfer) { this.handleTransfer(transfer); this.proxyConnection.getC2P().writeAndFlush(this.createTransferPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); return false; @@ -67,14 +67,14 @@ public class TransferPacketHandler extends PacketHandler { return true; } - private void handleTransfer(final S2CConfigTransfer1_20_5 transfer) { + private void handleTransfer(final S2CTransferPacket transfer) { final InetSocketAddress newAddress = new InetSocketAddress(transfer.host, transfer.port); TransferDataHolder.addTempRedirect(this.proxyConnection.getC2P(), newAddress); } - private S2CConfigTransfer1_20_5 createTransferPacket() { + private S2CTransferPacket createTransferPacket() { if (this.proxyConnection.getClientHandshakeAddress() != null) { - return new S2CConfigTransfer1_20_5(this.proxyConnection.getClientHandshakeAddress().getHost(), this.proxyConnection.getClientHandshakeAddress().getPort()); + return new S2CTransferPacket(this.proxyConnection.getClientHandshakeAddress().getHost(), this.proxyConnection.getClientHandshakeAddress().getPort()); } else { Logger.u_warn("transfer", this.proxyConnection, "Client handshake address is invalid, using ViaProxy bind address instead"); if (!(ViaProxy.getCurrentProxyServer().getChannel().localAddress() instanceof InetSocketAddress bindAddress)) { @@ -83,7 +83,7 @@ public class TransferPacketHandler extends PacketHandler { if (!(this.proxyConnection.getC2P().localAddress() instanceof InetSocketAddress clientAddress)) { throw new IllegalArgumentException("Client address must be an InetSocketAddress"); } - return new S2CConfigTransfer1_20_5(clientAddress.getHostString(), bindAddress.getPort()); + return new S2CTransferPacket(clientAddress.getHostString(), bindAddress.getPort()); } } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java index 2eb9ee0..0e140b4 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java @@ -74,7 +74,7 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer } super.initChannel(channel); - channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(true)); + channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakingRegistry(true)); channel.pipeline().addLast(new ViaProxyVLPipeline(user, proxyConnection.getServerVersion())); channel.pipeline().addAfter(VLPipeline.VIA_CODEC_NAME, "via-" + MCPipeline.FLOW_CONTROL_HANDLER_NAME, new NoReadFlowControlHandler()); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java index f012582..2c8f137 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java @@ -204,7 +204,7 @@ public class ProxyConnection extends NetClient { this.c2pConnectionState = connectionState; switch (connectionState) { case HANDSHAKING: - this.c2p.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false)); + this.c2p.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakingRegistry(false)); break; case STATUS: this.c2p.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getStatusRegistry(false)); @@ -226,7 +226,7 @@ public class ProxyConnection extends NetClient { switch (connectionState) { case HANDSHAKING: if (this.getChannel() != null) - this.getChannel().attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(true)); + this.getChannel().attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakingRegistry(true)); break; case STATUS: if (this.getChannel() != null)