1
1
package dev .tonimatas .packetfixer .mixins ;
2
2
3
- import dev .tonimatas .packetfixer .util .Config ;
3
+ import io .netty .buffer .ByteBuf ;
4
+ import io .netty .channel .ChannelHandlerContext ;
4
5
import net .minecraft .network .NettyVarint21FrameDecoder ;
6
+ import net .minecraft .network .PacketBuffer ;
5
7
import org .spongepowered .asm .mixin .Mixin ;
8
+ import org .spongepowered .asm .mixin .Unique ;
9
+ import org .spongepowered .asm .mixin .injection .At ;
6
10
import org .spongepowered .asm .mixin .injection .Constant ;
11
+ import org .spongepowered .asm .mixin .injection .Inject ;
7
12
import org .spongepowered .asm .mixin .injection .ModifyConstant ;
13
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
8
14
9
- @ Mixin (NettyVarint21FrameDecoder .class )
15
+ import java .util .List ;
16
+
17
+ @ Mixin (value = NettyVarint21FrameDecoder .class , priority = 1001 )
10
18
public abstract class Varint21FrameDecoderMixin {
19
+ @ Unique
20
+ private int packetFixer$varInt21Size = 10 ;
21
+
22
+ @ Inject (method = "decode" , at = @ At ("HEAD" ))
23
+ private void decode (ChannelHandlerContext channelHandlerContext , ByteBuf byteBuf , List <Object > list , CallbackInfo ci ) {
24
+ packetFixer$varInt21Size = PacketBuffer .getVarIntSize (byteBuf .readableBytes ()) + 2 ;
25
+ }
26
+
11
27
@ ModifyConstant (method = "decode" , constant = @ Constant (intValue = 3 ))
12
- private int newSize (int value ) {
13
- return Config . getVarInt21Size () ;
28
+ private int newSize (int constant ) {
29
+ return packetFixer$varInt21Size ;
14
30
}
15
- }
31
+ }
0 commit comments