BIOMIMESIS

IMITATION IS THE SINCEREST FORM OF FLATTERY

Minecraft has a unique format code called 'Obfuscated' text. Here's what it looks like:

Herobrine is real 2401

And here's a snippet to use it on your own website:

HTML:

JS:

CSS:

Always disable this effect if the prefers-reduced-motion browser setting is enabled. Obfuscated text will trigger reactions in photosensitive individuals.

More On Obfuscated Text:

Obfuscation is a format code that cycles the characters of the string it is applied to rapidly and randomly. The characters it cycles through are drawn from a pre-defined glyphset, and are redrawn if it does not match the bit-width of the character being formatted. Obfuscation rendering was been updated over the years, resulting in four different versions, which differ only in which characters are used in the glyphset.

The different glyphsets cause each version of obfuscation to have its own unique look and feel. I'm only interested in the version of obfuscation that existed in 1.7, which was the version I played most. It feels like home.

Minecraft 1.7 obfuscates using a glyphset called ascii.png, a font texture file, which consists of 256 characters:

Minecraft 1.7 ascii.png

Some of these characters are difficult to recognize. Instead of trying to find the codepoints manually, let's take a different approach. Decompilation projects for Minecraft have existed almost as long as Minecraft has. A 1.7 decomp project can be found at modcoderpack.com

After decompilation, we can find the code we are searching for in FontRenderer.java. It contains a string that only gets read from in order to find a random character with the same bit-width. Inspecting the codepoints used, we can see that it does indeed match up with ascii.png. What exactly is ascii.png then? Now that we know the codepoints, it is far easier to find out. ascii.png is a modified version of Code page 437, an oldschool extended ASCII charset. Gylphs 0-127 are identical to ASCII, with a few notable exceptions. Code page 437 has no non-printing characters besides the null-byte, whitespace, and the non-breaking space. Every other non-printing character ASCII has is instead replaced with a symbol. ascii.png takes this a step further by replacing glyphs 0 - 24 with an extended Latin alphabet. Some slots are free: glyphs 25 - 31 are unused and become null-bytes. Glyph 255, originally a non-breaking space (NBSP), is interpreted as a null-byte.

This gives us the first starting place for an accurate obfuscation implementation. We can export this string from FontRenderer.java and use it ourselves. Just make sure to properly escape the string, and voila. Here, we run into our first problem. We cannot print the non-printing null-bytes. How should we handle this? The source code has no special handling for null-bytes. If they are drawn, as long as the bit-width matches, it will be printed from ascii.png. The bit-width calculation, however, is not nearly as transparent as the glyphset was. My best guess is that the null-byte bit widths are calculated as one, but that is unhelpful without knowing what other glyphs also calculate to one.

A bit of a brainteaser, this one...

Fortunately, we can sidestep the issue entirely by using a monospaced font. This is a (mostly) required compromise, because a particular font is difficult to guarantee in a browser context, and measuring bit-widths on the fly in JS would quickly become CPU expensive. By monospacing, we can relax the bit-width requirement and use any character as a substitute for any character. We replace the null-bytes with whitespace and continue forward.

Obfuscated text is produced in the render stage, causing letters to flicker at a rate dependent on game framerate. Assuming a standard 60fps, we shift a string every 16 ms. Set up your CSS breaking and whitespace rules appropriately, and you should be done.

Related: Trust nobody, not even MDN

I love minecraft
<