Difference between revisions of "Chat"

From wiki.vg
Jump to navigation Jump to search
(Document a couple of chat-related files, clean up a bit)
Line 1: Line 1:
Chat strings are subject to myriad limitations imposed by defects in the Notchian server and client, and also have special meanings for certain characters.
+
Minecraft supports two-way chat communication via the [[Protocol#Chat_Message_.280x03.29|0x03 chat message]] packet.
  
 
== Character Set ==
 
== Character Set ==
  
The following list of characters are known to be supported by the Notchian server:
+
Minecraft loads its internal 8-bit character set from <code>fonts.txt</code> in <code>minecraft.jar</code>. Ignoring the first line then stripping spaces, the file lists characters 32-255 in order. It follows ASCII for values under 0x80.
 +
 
 +
The character set is as follows:
 
<blockquote>
 
<blockquote>
 
<code>
 
<code>
Line 12: Line 14:
 
Characters not in this list will cause Notchian servers to kick clients, and Notchian clients to choke and die horribly.
 
Characters not in this list will cause Notchian servers to kick clients, and Notchian clients to choke and die horribly.
  
== Colors ==
+
== Font ==
 +
 
 +
Minecraft loads its font from <code>font/default.png</code> in <code>minecraft.jar</code>. Glyphs 0-255 are given, each in an 8x8 area.
 +
 
 +
Minecraft also provides other font pages, as <code>font/glyph_XX.png</code>, where XX is the hex representation of the first byte of the UTF-16 character. The archive also provides <code>font/glyph_sizes.bin</code>. Glyphs are in-order, a byte a piece. The glyph's width can be ascertained from the expression <code>(byte & 0x0F - byte >> 4)</code>. However, the sizes for the first 256 glyphs are *not* correct and the minecraft client generates them on startup.
 +
 
 +
== Control Sequences ==
 +
 
 +
The client treats certain two-character sequences specially. The first character must be:
 +
 
 +
*§ (U+00A7) for minecraft
 +
*& for minecraft classic
 +
 
 +
The following character indicates a certain colour or formatting to apply to the proceeding text.
 +
 
 +
The Notchian client expects that an escape code in a chat message will be followed by at least one character, and will otherwise crash with a StringIndexOutOfBoundsException. The workaround for servers is to never end a message with a color control character.
 +
 
 +
=== Colors ===
 +
 
 +
These correspond very roughly to the colors available in ANSI terminals.
  
The Notchian client has support for colorized text. To select a color, a color escape code, similar to an ANSI color escape code, is inserted to change the color of the following characters.
+
e.g.: <code>This is white, but §4this is dark red</code>
  
 
[[File:Colors.png|thumb|Hex digit to color mapping]]
 
[[File:Colors.png|thumb|Hex digit to color mapping]]
Line 85: Line 106:
 
|}
 
|}
  
These correspond very roughly to the colors available in ANSI terminals.
+
=== Styles ===
 
 
A color escape code is created by combining the control character § (U+00A7) for Minecraft, or & for Minecraft Classic, with the character specifying the color; thus, "§4" in Minecraft selects dark red as the color for the following text, and "&4" does the same for classic.
 
 
 
== Styles==
 
  
Minecraft 1.2.4 added several new font style escape codes. Like the color codes above, style escape codes are created by combining § (U+00A7) with one of the following characters. Style codes can be combined (except for "r") to enable multiple effects at once. Using any color codes will reset the current style back to plain (unknown if this is a bug or intended behavior). The "r" plain style code will also reset the current chat color back to white (may also be a bug). The "k" random style code already existed before 1.2.4, and it is used for the "§kFUNKY LOL" message in /title/splashes.txt inside minecraft.jar.
+
Like the color codes above, style escape codes are created by combining § (U+00A7) with one of the following characters. Style codes can be combined (except for "r") to enable multiple effects at once. Using any color codes will reset the current style back to plain (unknown if this is a bug or intended behavior). The "r" plain style code will also reset the current chat color back to white (may also be a bug). The "k" random style code is used for the "§kFUNKY LOL" message in /title/splashes.txt inside minecraft.jar.
  
 
{| class="wikitable" style="text-align:center;" border="1" cellpadding="5"
 
{| class="wikitable" style="text-align:center;" border="1" cellpadding="5"
Line 111: Line 128:
 
| [[File:plain_chat.png]] || r || Plain White
 
| [[File:plain_chat.png]] || r || Plain White
 
|}
 
|}
 
=== Bugs ===
 
 
The Notchian client expects that a color escape code in a chat message will be followed by at least one character, and will otherwise crash with a StringIndexOutOfBoundsException. The workaround for servers is to never end a message with a color control character.
 
  
 
[[Category:Protocol Details]]
 
[[Category:Protocol Details]]
 
[[Category:Minecraft Modern]]
 
[[Category:Minecraft Modern]]

Revision as of 12:46, 29 March 2012

Minecraft supports two-way chat communication via the 0x03 chat message packet.

Character Set

Minecraft loads its internal 8-bit character set from fonts.txt in minecraft.jar. Ignoring the first line then stripping spaces, the file lists characters 32-255 in order. It follows ASCII for values under 0x80.

The character set is as follows:

" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»"

Characters not in this list will cause Notchian servers to kick clients, and Notchian clients to choke and die horribly.

Font

Minecraft loads its font from font/default.png in minecraft.jar. Glyphs 0-255 are given, each in an 8x8 area.

Minecraft also provides other font pages, as font/glyph_XX.png, where XX is the hex representation of the first byte of the UTF-16 character. The archive also provides font/glyph_sizes.bin. Glyphs are in-order, a byte a piece. The glyph's width can be ascertained from the expression (byte & 0x0F - byte >> 4). However, the sizes for the first 256 glyphs are *not* correct and the minecraft client generates them on startup.

Control Sequences

The client treats certain two-character sequences specially. The first character must be:

  • § (U+00A7) for minecraft
  • & for minecraft classic

The following character indicates a certain colour or formatting to apply to the proceeding text.

The Notchian client expects that an escape code in a chat message will be followed by at least one character, and will otherwise crash with a StringIndexOutOfBoundsException. The workaround for servers is to never end a message with a color control character.

Colors

These correspond very roughly to the colors available in ANSI terminals.

e.g.: This is white, but §4this is dark red

Hex digit to color mapping
Sample Code Common Name Foreground Color Background Color Hexadecimal
R G B R G B
0 Black 0 0 0 0 0 0 #000000
1 Dark blue 0 0 170 0 0 42 #0000aa
2 Dark green 0 170 0 0 42 0 #00aa00
3 Dark cyan 0 170 170 0 42 42 #00aaaa
4 Dark red 170 0 0 42 0 0 #aa0000
5 Purple 170 0 170 42 0 42 #aa00aa
6 Gold 255 170 0 42 42 0 #ffaa00
7 Gray 170 170 170 42 42 42 #aaaaaa
8 Dark gray 85 85 85 21 21 21 #555555
9 Blue 85 85 255 21 21 63 #5555ff
a Bright green 85 255 85 21 63 21 #55ff55
b Cyan 85 255 255 21 63 63 #55ffff
c Red 255 85 85 63 21 21 #ff5555
d Pink 255 85 255 63 21 63 #ff55ff
e Yellow 255 255 85 63 63 21 #ffff55
f White 255 255 255 63 63 63 #ffffff

Styles

Like the color codes above, style escape codes are created by combining § (U+00A7) with one of the following characters. Style codes can be combined (except for "r") to enable multiple effects at once. Using any color codes will reset the current style back to plain (unknown if this is a bug or intended behavior). The "r" plain style code will also reset the current chat color back to white (may also be a bug). The "k" random style code is used for the "§kFUNKY LOL" message in /title/splashes.txt inside minecraft.jar.

Sample Code Style
Random chat.gif k Random
Bold chat.png l Bold
Strikethrough chat.png m Strikethrough
Underlined chat.png n Underlined
Italic chat.png o Italic
Plain chat.png r Plain White