2323import com .mojang .brigadier .suggestion .SuggestionProvider ;
2424import net .fabricmc .fabric .api .client .command .v2 .ClientCommandManager ;
2525import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
26- import net .minecraft .client .MinecraftClient ;
27- import net .minecraft .client .gui .screen .Screen ;
28- import net .minecraft .text . Text ;
26+ import net .minecraft .client .Minecraft ;
27+ import net .minecraft .client .gui .screens .Screen ;
28+ import net .minecraft .network . chat . Component ;
2929import wtf .cheeze .sbt .utils .text .MessageManager ;
3030import wtf .cheeze .sbt .utils .NumberUtils ;
3131import wtf .cheeze .sbt .utils .text .TextUtils ;
3636import java .util .function .Supplier ;
3737
3838public class CommandUtils {
39-
4039 public static LiteralArgumentBuilder <FabricClientCommandSource > getScreenOpeningCommand (String name , Supplier <Screen > screenFactory ) {
4140 return ClientCommandManager .literal (name ).executes (context -> {
42- MinecraftClient mc = context .getSource ().getClient ();
43- mc .send (() -> mc .setScreen (screenFactory .get ()));
41+ Minecraft mc = context .getSource ().getClient ();
42+ mc .schedule (() -> mc .setScreen (screenFactory .get ()));
4443 return 1 ;
4544 });
4645 }
@@ -54,7 +53,6 @@ public static SuggestionProvider<FabricClientCommandSource> getArrayAsSuggestion
5453 };
5554 }
5655
57-
5856 static int [] getCalcPetTable (Rarity rarity ) {
5957 return switch (rarity ) {
6058 case COMMON -> Constants .pets ().levelsCommon ();
@@ -66,41 +64,46 @@ static int[] getCalcPetTable(Rarity rarity) {
6664 };
6765 }
6866
69-
70- static Text getDebugText (String name , boolean value ) {
67+ static Component getDebugText (String name , boolean value ) {
7168 return getDebugText (name , String .valueOf (value ), value ? Colors .LIME : Colors .RED );
7269 }
73- static Text getDebugText (String name , int value ) {
70+
71+ static Component getDebugText (String name , int value ) {
7472 return getDebugText (name , String .valueOf (value ), Colors .YELLOW );
7573 }
76- static Text getDebugText (String name , float value ) {
74+
75+ static Component getDebugText (String name , float value ) {
7776 return getDebugText (name , String .valueOf (value ), Colors .YELLOW );
7877 }
7978
80- static Text getDebugText (String name , String value , int color ) {
79+ static Component getDebugText (String name , String value , int color ) {
8180 return TextUtils .join (
8281 TextUtils .withColor (name + ": " , Colors .CYAN ),
8382 TextUtils .withColor (value , color )
8483 );
8584 }
86- static Text getDebugText (String name , String value ) {
85+
86+ static Component getDebugText (String name , String value ) {
8787 return TextUtils .join (
8888 TextUtils .withColor (name + ": " , Colors .CYAN ),
8989 TextUtils .withColor (value , Colors .YELLOW )
9090 );
9191 }
9292
93- public static void send (CommandContext <FabricClientCommandSource > context , Text text ) {
93+ public static void send (CommandContext <FabricClientCommandSource > context , Component text ) {
9494 context .getSource ().sendFeedback (TextUtils .join (MessageManager .PREFIX , TextUtils .SPACE , text ));
9595 }
96+
9697 public static void send (CommandContext <FabricClientCommandSource > context , String text ) {
97- context .getSource ().sendFeedback (TextUtils .join (MessageManager .PREFIX , TextUtils .SPACE , Text . of (text )));
98+ context .getSource ().sendFeedback (TextUtils .join (MessageManager .PREFIX , TextUtils .SPACE , Component . nullToEmpty (text )));
9899 }
99- public static void sendRaw (CommandContext <FabricClientCommandSource > context , Text text ) {
100+
101+ public static void sendRaw (CommandContext <FabricClientCommandSource > context , Component text ) {
100102 context .getSource ().sendFeedback (text );
101103 }
104+
102105 public static void sendRaw (CommandContext <FabricClientCommandSource > context , String text ) {
103- context .getSource ().sendFeedback (Text . of (text ));
106+ context .getSource ().sendFeedback (Component . nullToEmpty (text ));
104107 }
105108
106109 public static void calcSend (CommandContext <FabricClientCommandSource > context , String type , int number ) {
0 commit comments