Serialized ClientboundPlayerInfoUpdatePacket cannot be deserialized well.
cxzlw opened this issue · 3 comments
cxzlw commented
Using com.github.steveice10:mcprotocollib:1.20-1-SNAPSHOT
from https://repo.opencollab.dev/maven-snapshots
if (packet is ClientboundPlayerInfoUpdatePacket){
val testBuf = PooledByteBufAllocator.DEFAULT.buffer()
packet.serialize(testBuf, helper)
val test = ClientboundPlayerInfoUpdatePacket(testBuf, helper)
println(test)
}
packet
here is from the code below,
client.addListener(object : SessionAdapter() {
override fun packetReceived(session: Session, packet: Packet) {
}
})
This code doesn't work and throws an Exception below,
java.lang.IndexOutOfBoundsException: readerIndex(35) + length(1) exceeds writerIndex(35): PooledUnsafeDirectByteBuf(ridx: 35, widx: 35, cap: 256)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:730)
at io.netty.buffer.AbstractByteBuf.readBoolean(AbstractByteBuf.java:739)
at com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper.readNullable(MinecraftCodecHelper.java:100)
at com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket.<init>(ClientboundPlayerInfoUpdatePacket.java:89)
at Replay.add(Replay.kt:76)
at App$run$1.packetReceived(Main.kt:98)
at com.github.steveice10.packetlib.tcp.TcpSession.callPacketReceived(TcpSession.java:157)
at com.github.steveice10.packetlib.tcp.TcpSession.lambda$channelRead0$2(TcpSession.java:386)
at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
cxzlw commented
I met the issue when I was trying to make a simple standalone replay recording client (like PCRC, also SARC).
Everything worked well except the ClientboundPlayerInfoUpdatePacket
(which made the result no player), Minecraft also throws the Exception and finally I tried the code above and the same Exception was throwed.
Which means the problem is caused by the .serialize()
, because not only MCProtocolLib but also Minecraft cannot deserialize it well.