Using Colors
In writing any Minecraft commands that include text which will be shown to the player, you can always use the section symbol §
and a color code to decorate text with colors and formatting.
This formatting is not very informative, but you can use a feature in MCCompiled called definitions
to improve the way colors are laid out in text.
definitions.def
In the MCCompiled installation directory, you can view the file called definitions.def
to view all definitions shipped with the compiler. The file is composed of CATEGORY
s, each with a set of entries where <key> IS <value>
. The entries for the chat colors look like this:
Multiple category names are defined, and most possible variants of color names are covered. To get the entry for black, you could refer to it as color: black
, chatcolor: black
, chat color: black
, etc.
Specifying a Definition
Definitions are evaluated first, before every other process of the compiler. The text contained within a definition is evaluated the same way raw code would be if it were written. Definitions just provide a convenient and verbose way to specify code which has little meaning.
To specify a definition in your code, wrap it in square brackets and provide the category name as well as the entry name.
Example for Chat Coloring
This is an example of using the color
category to style text.
Specifying Multiple Definitions
After specifying a category, you may specify multiple values under that category, separated by commas. The values will be concatenated together, without a space in between them.
Escaping Definitions
If you don't wish for a definition to be parsed, you can precede it with a backslash \\
to cancel the definition on that token. If two backslashes are specified, they'll cancel out, and you will end up with a single backslash before the definition is parsed as usual.
The following table shows the results of different backslash counts to illustrate this idea:
Backslash # | Input | Output |
---|---|---|
0 (even) |
|
|
1 (odd) |
|
|
2 (even) |
|
|
3 (odd) |
|
|
4 (even) |
|
|