Jump to content

Recommended Posts

Posted (edited)

Hello, guys!

I want feedback to be colored, for example, Repaired Stick for Player001

I'm doing it right now:

source.sendFeedback(new TranslationTextComponent("commands.times.night", source.getDisplayName()).func_240701_a_(TextFormatting.BLUE), true);

I need Stick and Player001 to be the same color, and the rest of the message is different.

Edited by ChA0S_f4me
Mark
Posted
1 hour ago, diesieben07 said:

First of all, your translation keys should be prefixed with your Mod ID to avoid collisions.

Then, you can use multiple place holders in the message and apply different styles to the ITextComponents you pass in as parameters to TranslationTextComponent. Then only those placeholders will be colored.

You can also use IFormattableTextComponent#append to append differently styled components together.

Can you set an example?

Posted
12 minutes ago, diesieben07 said:

new TranslationTextComponent("yourmod.foo.bar", <first component here>, <second component here>).

 

Then have two placeholders in the translation.

Thx, I'll try this

Posted
8 hours ago, diesieben07 said:

new TranslationTextComponent("yourmod.foo.bar", <first component here>, <second component here>).

 

Then have two placeholders in the translation.

Hmm... This is don't work

source.sendFeedback(new TranslationTextComponent("commands.times.set",  new TranslationTextComponent("commands.times.night", source.getDisplayName()).func_240701_a_(TextFormatting.BLUE)), true);

1079064631_.png.9c4027ee8d77e758c2f892d2f3e46b29.png

 

Posted

I found the answer!

source.sendFeedback(new TranslationTextComponent("commands.times.set").mergeStyle(TextFormatting.BLUE).append(new TranslationTextComponent("commands.times.night").mergeStyle(TextFormatting.LIGHT_PURPLE)), true);

1644692042_-.png.ca8df13a106dd7a47fe82dfacdd54b29.png

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.