Skip to content

PartyPackage/PixelFont

Repository files navigation

PixelFont

This project is a set of scripts which generates a custom font for a Minecraft resource pack.

The custom font provides a range of unicode characters (U+FFF to U+1FFE), each of which is a single color from a 12 bit color palette that is generated by one of the scripts. Each unicode character is represented by its component RGB channels as 0xBGR, offset by 0xFFF to avoid the special formatting characters hardcoded in Minecraft's resource pack engine. Along with the color unicode characters, there is a negative space character represented as a basic space character (" ", or U+20).

Purpose

This font makes it feasible to stream video content to many players on a minecraft server network. While less efficient than streaming the raw color data, it still appears to be the best practical solution. It is not ideal as even though it is 12 bit color, each pixel is a combination of a UTF-16 unicode character and a UTF-8 negative space unicode character. The negative space character is required to correctly format the pixels to not have any padding between them.

This approach is still vastly more efficient than the typical method of displaying a colored pixel in a text display.

Old Approach

One approach would be to use a unicode full block character (█, U+2588) and color it via a tag in the entity's json object.

/summon minecraft:text_display ~ ~2 ~ {text: [{color: "#e01b24", text: "█"}, {color: "#33ee55", text: "█"}, {color: "#3584e4", text: "█"}]}

Although this allows you to use 24 bit color, the size of the overall json object can quickly exceed Minecraft's maximum packet size with even the smallest of images using this approach. Another approach, as explored by Cymaera, would be to use a single text entity per pixel. Each pixel would be a blank character and the color of the pixel would be determined by the background color and alpha value of the text display's background. As shown by Cymaera, this is a very powerful approach as you can use 24 bit color and an alpha channel, but has the drawback of using tons of entities to acheive an end result.


New Approach

With using fonts, you can keep displays as one entity, but be limited to only 12 bit color and no alpha channel. The size of the json object is much smaller when using the font, as each pixel does not need to be its own json object. The only additional data included is specifying the custom font with the unicode characters.

/summon minecraft:text_display ~ ~2 ~ {text: {font: "lfx:pxl", text: "\u100e \u10ef \u1eff "}}

Using this approach, I was able to stream 4k video to players on a server without exceeding the maximum packet size. The main drawback of this approach is client performance. Even though you can stream 4k video to players, it will lag their games to 1-3fps. For lower resolution video, it is feasible to stream to many players on a server.

Display Anything

I created a script early on into testing that generates a command which summons a text display entity of whatever image you would like to display. You can use this script as well to quickly generate commands to spawn custom text display art in your worlds. Make sure to keep in mind the maximum command size of command blocks will dictate the maximum resolution of your image.

image

Of course I had to do the obligatory Bad Apple showcase with it as well. Here is a recording from a friend's perspective with all video and audio being streamed over WAN, with hundreds of miles between us and the game server as well. We built a web based audio client to accompany the video being streamed in-game and the latency stacks almost perfectly together creating a seamless viewing experience.

bad_apple_minecraft_pixelfont.mp4

Case Study

This technology was used in my custom DMX controlled lighting plugin, MCLiveFX, for Bundle Group's Coasters and Crafters Live night club events (Twitch VOD). The font was used for the pixel mapped RGB matrices above the crowd.

(EPILEPSY WARNING)

MCLiveFX_Showcase.mp4

If you wish to work with us to bring your ideas to life, feel free to contact us via the Bundle Group website!

About

Python scripts to generate the font used in MCLiveFX's text display video screens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages