11package io .github ._4drian3d .signedvelocity .fabric .model ;
22
3+ import com .google .common .io .ByteArrayDataInput ;
4+ import com .google .common .io .ByteStreams ;
35import io .github ._4drian3d .signedvelocity .fabric .SignedVelocity ;
46import io .netty .buffer .ByteBuf ;
57import net .minecraft .network .FriendlyByteBuf ;
@@ -20,12 +22,12 @@ public record QueuedDataPacket(
2022 public static final StreamCodec <ByteBuf , QueuedDataPacket > PACKET_CODEC = CustomPacketPayload .codec (QueuedDataPacket ::write , QueuedDataPacket ::generate );
2123
2224 public static QueuedDataPacket generate (final ByteBuf buf ) {
23- final FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf ( buf );
24- final UUID playerId = friendlyByteBuf . readUUID ( );
25- final String source = friendlyByteBuf . readUtf ();
26- final String result = friendlyByteBuf . readUtf ();
25+ final ByteArrayDataInput input = ByteStreams . newDataInput ( convertFromBuf ( buf ) );
26+ final UUID playerId = UUID . fromString ( input . readUTF () );
27+ final String source = input . readUTF ();
28+ final String result = input . readUTF ();
2729 final String modifiedMessage = result .equals ("MODIFY" )
28- ? friendlyByteBuf . readUtf ()
30+ ? input . readUTF ()
2931 : null ;
3032 return new QueuedDataPacket (playerId , source , result , modifiedMessage );
3133 }
@@ -43,4 +45,10 @@ public static void write(final QueuedDataPacket packet, final ByteBuf buf) {
4345 public @ NotNull Type <? extends CustomPacketPayload > type () {
4446 return PACKET_ID ;
4547 }
48+
49+ private static byte [] convertFromBuf (final ByteBuf buf ) {
50+ final byte [] bytes = new byte [buf .readableBytes ()];
51+ buf .readBytes (bytes );
52+ return bytes ;
53+ }
4654}
0 commit comments