Jump to content

(Solved)[1.15.2]Combine TranslationTextComponent?


kyazuki

Recommended Posts

I want to set localized CustomName(e.g. "componentA (componentB)") to chests.

I wrote this:

chestEntity.setCustomName(new TranslationTextComponent("chestname.testmod.testA") + " (" + new TranslationTextComponent("chestname.testmod.testB") + ")");

However, setCustomName method requires TextComponent.

How do I do?

Edited by kyazuki
Link to comment
Share on other sites

ITextComponent provides an appendText(String text) and an appendSibling(ITextComponent component) method.  
You can chain these together to get your desired output. I.e.
 

chestEntity.setCustomName(new TranslationTextComponent("chestname.testmod.testA").appendText(" (").appendSibling(new TranslationTextComponent("chestname.testmod.testB")).appendText")"));

 

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

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.