Wiki 9Minecraft Wiki 9Minecraft
Librarianlib Wiki › Guides › Create a Custom GUI Without Magic Numbers

Create a Custom GUI Without Magic Numbers

Using the Modular GUI System

LibrarianLib's GUI library eliminates hardcoded pixel positions by breaking interfaces into reusable, positioned components.

Setting Up Your GUI

1. Create a GUI class that extends the appropriate LibrarianLib GUI base class for your Minecraft version

2. Define your components (buttons, text fields, panels) as fields in your class

3. Position components relative to each other using the library's layout system instead of absolute coordinates—this keeps your code clean and responsive

4. Bind data to your GUI elements using the automatic syncing features; fields marked with @Save will automatically update between client and server

5. Add event handlers to buttons and interactive elements by implementing the appropriate listener interfaces

The key advantage is that if you need to resize or reorganize your GUI, you adjust positioning logic once rather than recalculating every coordinate. The library handles rendering, input detection, and screen scaling automatically.

Testing

Open your GUI in-game and verify that all elements appear correctly and respond to clicks. Use the debug features to visualize component boundaries if positioning seems off.