19
19
package de .florianmichael .viaforge .mixin ;
20
20
21
21
import de .florianmichael .viaforge .common .gui .ExtendedServerData ;
22
- import net .minecraft .SharedConstants ;
23
22
import net .minecraft .client .multiplayer .ServerData ;
24
23
import net .minecraft .nbt .CompoundTag ;
25
24
import com .viaversion .viaversion .api .protocol .version .ProtocolVersion ;
30
29
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
31
30
import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
32
31
import org .spongepowered .asm .mixin .injection .callback .LocalCapture ;
33
- import java .lang .reflect .Method ;
34
32
35
33
@ Mixin (ServerData .class )
36
34
public class MixinServerData implements ExtendedServerData {
@@ -48,7 +46,7 @@ public void saveVersion(CallbackInfoReturnable<CompoundTag> cir, CompoundTag com
48
46
@ Inject (method = "read" , at = @ At (value = "TAIL" ))
49
47
private static void getVersion (CompoundTag compoundnbt , CallbackInfoReturnable <ServerData > cir ) {
50
48
if (compoundnbt .contains ("viaForge$version" )) {
51
- ((ExtendedServerData ) cir .getReturnValue ()).viaForge$setVersion (ProtocolVersion .getClosest (viaforge$getString ( compoundnbt )));
49
+ ((ExtendedServerData ) cir .getReturnValue ()).viaForge$setVersion (ProtocolVersion .getClosest (compoundnbt . getStringOr ( "viaForge$version" , "" )));
52
50
}
53
51
}
54
52
@@ -69,27 +67,4 @@ public void track(ServerData serverDataIn, CallbackInfo ci) {
69
67
viaForge$version = version ;
70
68
}
71
69
72
- @ Unique
73
- private static Method viaForge$getString ;
74
-
75
- /**
76
- * 1.21.4 Compat
77
- */
78
- @ Unique
79
- private static String viaforge$getString (CompoundTag compoundnbt ) {
80
- if (SharedConstants .getProtocolVersion () >= 770 ) {
81
- return compoundnbt .getStringOr ("viaForge$version" , "" );
82
- } else {
83
- String s = "" ;
84
- try {
85
- if (viaForge$getString == null ) {
86
- viaForge$getString = CompoundTag .class .getDeclaredMethod ("getString" , String .class );
87
- }
88
- s = (String ) viaForge$getString .invoke (compoundnbt , "viaForge$version" );
89
- } catch (Exception e ) {
90
- throw new IllegalArgumentException (e );
91
- }
92
- return s ;
93
- }
94
- }
95
70
}
0 commit comments