Skip to main content

Get 25% OFF on your first order with BisectHosting using code "DAQEM"!

Getting Started

To start building GUIs with UI Lib, you need to add the library to your project's dependencies.

Dependency Setup

UI Lib is hosted on the DAQEM Studios Maven.

1. Add Repository

Add the following maven repository to your build.gradle file:

repositories {
maven {
name = "DAQEM Studios Maven"
url = "https://maven.daqem.com/releases"
}
}

2. Add Dependencies

Add the dependency corresponding to your loader. Replace ${uilib_version} with the latest version found on the Project Page or Maven.

dependencies {
// UI Lib Fabric
modImplementation "com.daqem.uilib:uilib-fabric:${uilib_version}"
}

Basic Concepts

UI Lib introduces a few core interfaces that you should be familiar with:

  1. IScreen: The root of any UI. It holds a list of components and widgets.
  2. IComponent: A visual element that can contain other components. It handles relative positioning (parentX + x).
  3. IWidget: An interactive element (buttons, text fields) that usually extends standard Minecraft widgets but implements UI Lib positioning logic.
  4. IBackground: A dedicated renderer for the screen background (blur, color, gradient).

Your First Screen

To create a screen, extend AbstractScreen.

public class MyFirstScreen extends AbstractScreen {

public MyFirstScreen() {
super(Component.literal("My First Screen"));
}

@Override
protected void init() {
// Create a text component at 10, 10
TextComponent hello = new TextComponent(10, 10, Component.literal("Hello World"));

// Add it to the screen
this.addComponent(hello);

// Add a standard button
ButtonWidget button = new ButtonWidget(10, 30, 100, 20, Component.literal("Click Me"), (btn) -> {
System.out.println("Clicked!");
});

this.addWidget(button);

super.init();
}
}