Attempt to improve partial read situations during early connections

This commit is contained in:
Shane Freeder
2025-05-22 14:26:48 +01:00
parent 8fea43d6ba
commit 5eb83760cd

View File

@@ -98,7 +98,12 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
state.getProtocolRegistry(direction, ProtocolVersion.MINIMUM_VERSION); state.getProtocolRegistry(direction, ProtocolVersion.MINIMUM_VERSION);
final int index = in.readerIndex(); final int index = in.readerIndex();
final int packetId = ProtocolUtils.readVarInt(in); final int packetId = readRawVarInt21(in);
// Index hasn't changed, we've read nothing
if (index == in.readerIndex()) {
in.resetReaderIndex();
return;
}
final int payloadLength = length - ProtocolUtils.varIntBytes(packetId); final int payloadLength = length - ProtocolUtils.varIntBytes(packetId);
MinecraftPacket packet = registry.createPacket(packetId); MinecraftPacket packet = registry.createPacket(packetId);
@@ -141,6 +146,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
.withThrowable(cause) .withThrowable(cause)
.log("Exception caught while decoding frame for {}", ctx.channel().remoteAddress()); .log("Exception caught while decoding frame for {}", ctx.channel().remoteAddress());
} }
super.exceptionCaught(ctx, cause);
} }
/** /**