Java Code Examples for net.minecraft.util.text.TextComponentString.setStyle()

The following are Jave code examples for showing how to use setStyle() of the net.minecraft.util.text.TextComponentString class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ForgeHax   File: Helper.java   Source Code and License Vote up 6 votes
public static void printMessageNaked(String startWith, String message, Style firstStyle, Style secondStyle) {
    if(getLocalPlayer() != null && !Strings.isNullOrEmpty(message)) {
        if(message.contains("\n")) {
            Scanner scanner = new Scanner(message);
            scanner.useDelimiter("\n");
            Style s1 = firstStyle;
            Style s2 = secondStyle;
            while (scanner.hasNext()) {
                printMessageNaked(startWith, scanner.next(), s1, s2);
                // alternate between colors each newline
                Style cpy = s1;
                s1 = s2;
                s2 = cpy;
            }
        } else {
            TextComponentString string = new TextComponentString(startWith + message.replaceAll("\r", ""));
            string.setStyle(firstStyle);
            getLocalPlayer().sendMessage(string);
        }
    }
}
 
Example 2
Project: UniversalRemote   File: TextFormatter.java   Source Code and License Vote up 5 votes
public static ITextComponent style(TextFormatting color, boolean italic, String unstyledString)
{
	TextComponentString t = new TextComponentString(unstyledString);
	Style s = new Style();
	s.setColor(color);
	s.setItalic(italic);
	t.setStyle(s);
   	
   	return t;
}
 
Example 3
Project: UniversalRemote   File: TextFormatter.java   Source Code and License Vote up 5 votes
public static ITextComponent style(TextFormatting color, String unstyledString, Object... args)
{
	TextComponentString t = new TextComponentString(String.format(unstyledString, args));
	Style s = new Style();
	s.setColor(color);
	t.setStyle(s);
   	
   	return t;
}