55import me .shedaniel .autoconfig .serializer .Toml4jConfigSerializer ;
66import net .fabricmc .api .ClientModInitializer ;
77import net .fabricmc .fabric .api .client .command .v2 .ClientCommandRegistrationCallback ;
8- import net .minecraft .text . HoverEvent ;
9- import net .minecraft .text . MutableText ;
10- import net .minecraft .text . Style ;
11- import net .minecraft .text . Text ;
12- import net .minecraft .util . Formatting ;
8+ import net .minecraft .ChatFormatting ;
9+ import net .minecraft .network . chat . Component ;
10+ import net .minecraft .network . chat . HoverEvent ;
11+ import net .minecraft .network . chat . MutableComponent ;
12+ import net .minecraft .network . chat . Style ;
1313import org .slf4j .Logger ;
1414import org .slf4j .LoggerFactory ;
1515
@@ -65,16 +65,16 @@ public static DisplayMapping getMapping(UUID uuid) {
6565 * @param replaceColour Whether to replace the colour with the colour defined in the mapping
6666 * @return A new MutableText object with the mapping applied (replacements and colour changes)
6767 */
68- static MutableText applyMapping (Text message , DisplayMapping mapping ,
68+ static MutableComponent applyMapping (Component message , DisplayMapping mapping ,
6969 boolean replaceName , boolean replaceColour ) {
7070 if (message == null || message .getString ().isEmpty () || mapping == null ) {
71- return (MutableText ) message ;
71+ return (MutableComponent ) message ;
7272 }
7373
74- MutableText outputMessage = Text .empty ();
74+ MutableComponent outputMessage = Component .empty ();
7575 message .visit ((style , text ) -> {
7676 if (!text .contains (mapping .mc_name ())) {
77- outputMessage .append (Text .literal (text ).setStyle (style ));
77+ outputMessage .append (Component .literal (text ).setStyle (style ));
7878 return Optional .empty (); // Continue visiting
7979 }
8080
@@ -92,10 +92,10 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
9292 }
9393
9494 // Create new MutableText with the display string and style
95- MutableText newText = (MutableText ) Text . of (replacedText );
95+ MutableComponent newText = (MutableComponent ) Component . nullToEmpty (replacedText );
9696 newText .setStyle (replacedStyle );
9797 if (mapping .colours () != null && mapping .colours ().length > 1 && replaceColour ) {
98- newText = (MutableText ) applyGradient (newText , List .of (mapping .colours ()));
98+ newText = (MutableComponent ) applyGradient (newText , List .of (mapping .colours ()));
9999 }
100100 outputMessage .append (newText );
101101
@@ -117,7 +117,7 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
117117 * @param replaceColour Whether to replace the colour with the colour defined in the mapping
118118 * @return A Text object containing the potentially modified name with appropriate styling
119119 */
120- public static Text getStyledName (Text displayName , UUID uuid , boolean replaceName ,
120+ public static Component getStyledName (Component displayName , UUID uuid , boolean replaceName ,
121121 boolean replaceColour ) {
122122 DisplayMapping mapping = getMapping (uuid );
123123 return (mapping != null )
@@ -134,19 +134,19 @@ public static Text getStyledName(Text displayName, UUID uuid, boolean replaceNam
134134 * @param replaceColour Whether to replace the colour with the colour defined in the mapping
135135 * @return A new MutableText object with the mapping applied (replacements and colour changes)
136136 */
137- public static Text getStyledChat (Text message , boolean replaceName , boolean replaceColour ) {
137+ public static Component getStyledChat (Component message , boolean replaceName , boolean replaceColour ) {
138138 if (message == null || message .getString ().isEmpty ()) {
139- return Text .empty ();
139+ return Component .empty ();
140140 }
141141
142- MutableText outputMessage = Text .empty ();
142+ MutableComponent outputMessage = Component .empty ();
143143 message .visit ((style , text ) -> {
144- MutableText newText = Text .literal (text ).setStyle (style );
144+ MutableComponent newText = Component .literal (text ).setStyle (style );
145145
146146 HoverEvent event = style .getHoverEvent ();
147- if (event != null && event .getAction () == HoverEvent .Action .SHOW_ENTITY ) {
148- HoverEvent .EntityContent entity = ((HoverEvent .ShowEntity ) event ).entity ();
149- newText = (MutableText ) getStyledName (newText , entity .uuid ,
147+ if (event != null && event .action () == HoverEvent .Action .SHOW_ENTITY ) {
148+ HoverEvent .EntityTooltipInfo entity = ((HoverEvent .ShowEntity ) event ).entity ();
149+ newText = (MutableComponent ) getStyledName (newText , entity .uuid ,
150150 replaceName , replaceColour );
151151 newText .setStyle (newText .getStyle ().withHoverEvent (event ));
152152 }
@@ -183,19 +183,16 @@ public static int getData(String source) {
183183 *
184184 * @return A Text object containing the status of the mod
185185 */
186- public static Text getStatusString () {
186+ public static Component getStatusString () {
187187 return switch (NameLinkAPI .getStatus ()) {
188- case UNKNOWN -> Text .translatable ("text.scnicknamer.status.unknown" ).formatted (Formatting .GRAY );
189- case SUCCESS ->
190- Text .translatable ("text.scnicknamer.status.success" ).formatted (Formatting .WHITE );
191- case WORKING ->
192- Text .translatable ("text.scnicknamer.status.working" ).formatted (Formatting .YELLOW );
193- case FALLBACK ->
194- Text .translatable ("text.scnicknamer.status.fallback" ).formatted (Formatting .RED );
195- case FAILURE ->
196- Text .translatable ("text.scnicknamer.status.failure" ).formatted (Formatting .RED
197- , Formatting .BOLD );
198- case DISABLED -> Text .translatable ("text.scnicknamer.status.disabled" ).formatted (Formatting .DARK_GRAY );
188+ case UNKNOWN -> Component .translatable ("text.scnicknamer.status.unknown" ).withStyle (ChatFormatting .GRAY );
189+ case SUCCESS -> Component .translatable ("text.scnicknamer.status.success" ).withStyle (ChatFormatting .WHITE );
190+ case WORKING -> Component .translatable ("text.scnicknamer.status.working" ).withStyle (ChatFormatting .YELLOW );
191+ case FALLBACK -> Component .translatable ("text.scnicknamer.status.fallback" ).withStyle (ChatFormatting .RED );
192+ case FAILURE -> Component .translatable ("text.scnicknamer.status.failure" ).withStyle (ChatFormatting .RED
193+ , ChatFormatting .BOLD );
194+ case DISABLED ->
195+ Component .translatable ("text.scnicknamer.status.disabled" ).withStyle (ChatFormatting .DARK_GRAY );
199196 };
200197 }
201198
0 commit comments