Facade is LibrarianLib’s retained-mode GUI framework. The culmination of four years of development, it is by far the most powerful Minecraft GUI library I know of.
Facade is structured similarly to most retained-mode UI frameworks, where the UI consists of a hierarchy of elements, each of which is positioned relative to its parent. Every component in LibrarianLib can contain children, and there are functions to freely and easily transform positions from one component to another.
One of the core components of every GUI is sprites, since each icon, background, and button has to have a texture. Minecraft’s solution to this in its GUI code is essentially to hard-code UV coordinates from a sprite atlas texture, which when combined with the fact that every GUI element in Minecraft is manually positioned, means GUI code becomes a soup of magic numbers with very little to indicate what or where any of them are.
To solve this issue, LibrarianLib has a custom sprite sheet engine that stores all the sprite UV coordinates in the texture’s
.mcmeta file, so the code only has to refer to the sprite by name and can then position it without considering where from the atlas it is pulling from. The sprite engine can do more than just define UV coordinates however, it can also perform 9-slice scaling on some or all of the edges, stretch or tile the texture on the X and Y axes independently, and animate sprites.
Components can also have just about every attribute animated automatically, as well as have many values bound to a function instead of a fixed value so, for example, text elements can have their contents automatically update when values change. Most attributes can also be animated implicitly, so you can start an animation block, make any number of changes, some of which may involve refreshing layouts and moving many layers, then at the end all of those changes will be snapshotted and the two states will be animated between automatically.
Facade also includes a collection of components that are placed over every built-in HUD element, allowing other components to be added relative to them, such as having an element appear to the left of the health bar, above the offhand slot, below the boss bar, etc. With the help of Mixin in 1.14+, I hope to make this much more flexible and robust.
Components in Facade can be cropped to their bounds, cut to a custom shape using OpenGL’s stencil mask, or in recent versions can be rendered to a texture and then have their opacity or color changed, have shaders applied, and have other layers as alpha or luma mattes to modify their opacity.