ProtocolLib

3M Downloads

Get PacketContainer Bytes long "Weight"

LB45440078L opened this issue ยท 1 comments

commented

Using 5.2.0-SNAPSHOT on a Paper 1.20.4 Server.

As a developer developing an hardware and networking tool, I would greatly benefit from this information.

I am looking from a reliable way to easily get the total amount of bytes that a packet container stores.
This will allow me to make an estimate of the RX\TX of the server at runtime.

I have only found the PacketContainer#serializeToBuffer or PacketContainer#handle methods, however those would have me rely on Reflections and\or Mojang's code.

Is there any way to already do this?

commented

Issue solved.

final Object byteBuf = container.serializeToBuffer();
final ByteBuf byteBuf$ = (ByteBuf) byteBuf;
final int bytes = byteBuf$.readableBytes();