TintedForge
ColorCodes
ColorCodes allow you to make text in the game a specific color. The most common use case is when displaying a message to the player, and you want to display it in a different color. Let's see an example:
player.displayClientMessage(Component.literal("Welcome to the mod!"), true);
This will show Welcome to the mod!
to the player in the standard, white text.
To make it colored, you can now use one of the colors code listed in the mod description by calling the color code with its displayColor
like this:
player.displayClientMessage(Component.literal(ColorCode.RED.getDisplayColor() + "Welcome to the mod!"), true);
This will make the text red.
Formatting Codes
Formatting codes act exactly the same as color codes, but instead of making the text a particular color, they change the text format by calling their displayCode
.
For example, to make text bold,
player.displayClientMessage(Component.literal(FormattingCode.BOLD.getDisplayCode() + "Welcome to the mod!"), true);
This will make the text bold.