Jump to content

Recommended Posts

Posted (edited)

For example, I have a TextComponentString like this:

 

new TextComponentString("Hi, there!")

 

I want the 'Hi' to be blue and 'there' to be green. Also, how do we make parts of the text clickable? Like, if the player clicks 'hi' it will execute code

Edited by Alsan Ali
Forgot to mention some things
Posted (edited)
  On 3/3/2018 at 7:51 AM, Alsan Ali said:

For example, I have a TextComponentString like this:

 

new TextComponentString("Hi, there!")

 

I want the 'Hi' to be blue and 'there' to be green. Also, how do we make parts of the text clickable? Like, if the player clicks 'hi' it will execute code

Expand  

 

use Color Codes.

http://minecraft.tools/en/color-code.php (use the MOTD one)

 

Example of something I use in my mod (the first line is in orange/gold + Italics. the next line is normal white)

  Reveal hidden contents

 

For the commands, look at how vanilla does it in the books. you wouldn't be limited by vanilla commands though, you could directly call your own java code

Edited by Cadiboo

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 3/3/2018 at 10:06 AM, diesieben07 said:

No.

 

Create a "base" TextComponentString with an empty string in it. Then you can use ITextComponent::appendSibling on it with differently formatted components to form one big component.

Expand  

Thanks, I thought about doing this, just didn't know how to nest TextComponentStrings together. And can you tell me the reason why color codes can't be used? I just want to know

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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