Skip to content
brachy84 edited this page Mar 29, 2023 · 5 revisions

This wiki is intended for people who want to use ModularUI in their mod or for resourcepack/modpack developers who want to customize ModularUI.

What is ModularUI?

ModularUI is a UI library for Minecraft. The first appearance of something like ModularUI was in GTCE. Since then a lot of improvements have been made and is now completely standalone (apart from Mixinbooter). The main goal of this lib is being able to easily create complex and beautiful UI's without having to go through the GUI mess from Minecraft (it's really bad).

Key features:

  • panel system similar to windows
  • automatic rendering of widgets in the right layer
  • handeling of interactions
  • syncing of values
  • also good for client only GUI's
  • Themes that are customizable via resourcepacks

How does it work?

To understand how it works we have to diffirentiate between server and client. The server side is optional depending on if you need to sync values.

Server side

  • GuiSyncHandler stores sync handlers for widgets. Is responsible for syncing values of widgets between server and client.
  • ModularContainer is the wrapper for the minecraft Container class. This is important for item slots.

Client side

  • ModularScreen is the heart of every modular UI. It needs to be instanciated every time a GUI is opened. It also stores a list of ModularPanels.
  • ModularPanel is basically a window in a gui. A ModularScreen must always have at least one panel to be considered open. A panel can sometimes be dragged around. It stores a list of widgets, which in turn can also contain lists of widgets. This creates a tree like structure of widgets with the ModularPanel always being at the top.
  • GuiContext is a helper class which is instanciated for every ModularScreen. It keeps track of pressed buttons, dragged, focused or hovered elements and viewports.
  • IWidget is the base interface for all widgets. Furthermore GuiSyncHandler and ModularContainer also exist on client side.

Development tools

I highly recommend to use Intellij as an IDE with the Single Hotswap plugin. It allows to hot reload the current class, while the game is running. Perfect for GUI development.

Where do I start?

For beginners you can start reading this. You can find test examples here and here. You can also check out InventoryBogoSorter where i use ModularUI for the config UI.

Clone this wiki locally