Skip to content

GUI Toolkit

MehVahdJukaar edited this page Jul 25, 2026 · 1 revision

GUI Toolkit

Widgets and drawing helpers vanilla doesn't have.

Written for Moonlight's own config screen, but they're plain AbstractWidgets and work in any screen.

Widgets

Widget
DropdownWidget Proper dropdown list
ColorSwatchWidget / ColorFieldWidget Color preview and hex field, backed by ColorPickerScreen
NumberFieldWidget Numeric field with clamping and scroll to change
RangedSlider / RangeControlWidget Slider, and a two handle min/max control
Vec3ControlWidget Three coupled number fields
BooleanToggleWidget ✓/✗ switch with an icon
SyntaxEditBox / PanningEditBox Multiline editor with syntax highlighting, and a single line box that pans instead of clipping
BreadcrumbWidget Navigation trail
IconButton / MediaButton Icon buttons, and the link buttons (CurseForge, Modrinth, Discord...)
ItemCarouselWidget Slowly panning strip of items
ChatBubbleWidget Speech bubble, also usable as an in world overlay with PointingChatBubbleOverlay
CompositeWidget Group several widgets as one

Syntax highlighting is pluggable: JsonHighlighter, NbtHighlighter, RegexHighlighter, or your own SyntaxHighlighter.

Two ready made screens you can just open: ColorPickerScreen and JsonEditScreen.

Drawing helpers

GuiHelper has the drawing bits that keep getting rewritten: header bars, separators, list backgrounds, scrollbars, horizontal gradients, mod icons, scrolling text that fits a row, number formatting, and the click sound.

Popup and PopupHost add a modal layer on top of a screen without opening a new one, and OverlayLayer draws over the whole game.

Tip

Don't scale GUI content with the pose stack. Blit at the size you want instead, or the pixels stop lining up with the rest of the interface.

Opening a screen from a block

IScreenProvider on a block entity or entity gives you sendOpenGuiPacket(player, face), which handles the server to client round trip for a screen that isn't a menu.

Clone this wiki locally