Getting Started - Type-32/OverseerUI GitHub Wiki

Overseer GUI & HUD Documentation

GUI System

The GUI system provides a way to create ImGui-based screens in Minecraft.

Creating a Screen

public class MyScreen extends OverseerScreen {
    public MyScreen() {
        super(Component.literal("My Screen"));
    }

    @Override
    protected List<ImGuiWindow> initImGui() {
        return List.of(
            // Create windows using the builder pattern
            window("Settings")
                .theme(new ImGuiDarkTheme())
                .notCloseable()  // Optional: make window uncloseable
                .addFlag(ImGuiWindowFlags.NoResize)  // Optional: add ImGui flags
                .build(() -> {
                    // Your ImGui code here
                    ImGui.text("Hello World!");
                    if (ImGui.button("Click me!")) {
                        // Handle click
                    }
                })
        );
    }
}

// Opening the screen
Minecraft.getInstance().setScreen(new MyScreen());

Key Features

  • Builder pattern for window creation
  • Theme support
  • ImGui flag customization
  • Multiple windows per screen

HUD System

The HUD system allows creation of in-game overlay elements using ImGui.

Creating a HUD Element

public class MyHUD extends OverseerHUD.HUDElement {
    public MyHUD() {
        super("my_hud", new ImGuiDarkTheme());
        
        // Configure when to render
        setRenderWhenPaused(false)
        .setRenderInChat(true)
        .setRenderWithGuiHidden(false)
        .setRenderInMenus(false);

        // Configure window flags
        removeFlags(ImGuiWindowFlags.NoInputs)  // Allow input if needed
        .addFlags(ImGuiWindowFlags.NoMove);     // Prevent window movement
    }

    @Override
    protected void renderContent() {
        // Your ImGui rendering code here
        ImGui.text("Hello World!");
    }
}

Adding HUD to Game

// In your mod's client initialization
public class ModClient {
    public static void init() {
        MyHUD hud = new MyHUD();
        OverseerHUD.addElement(hud);
    }
}

Render Control

Control when your HUD element appears:

setRenderWhenPaused(boolean)  // Show when game is paused
setRenderInChat(boolean)      // Show when chat is open
setRenderWithGuiHidden(boolean) // Show when GUI is hidden (F1)
setRenderInMenus(boolean)     // Show in menu screens

Window Flags

Customize ImGui window behavior:

addFlags(ImGuiWindowFlags.XXX)    // Add flags
removeFlags(ImGuiWindowFlags.XXX)  // Remove flags
setFlags(flags)                    // Set all flags

Common flags:

  • NoInputs: Prevent interaction
  • NoMove: Prevent window movement
  • NoBackground: Hide window background
  • NoDecoration: Remove window decorations

Example: Notification HUD

public class NotificationHUD extends OverseerHUD.HUDElement {
    private final List<Notification> notifications = new CopyOnWriteArrayList<>();

    public NotificationHUD() {
        super("notifications", new ImGuiDarkTheme());
        removeFlags(ImGuiWindowFlags.NoInputs);
        addFlags(ImGuiWindowFlags.NoMove);
    }

    @Override
    protected void renderContent() {
        for (int i = 0; i < notifications.size(); i++) {
            Notification notification = notifications.get(i);
            ImGui.pushID(i);
            
            ImGui.text(notification.getMessage());
            if (ImGui.button("Accept")) {
                notification.accept();
                notifications.remove(notification);
            }
            
            ImGui.popID();
        }
    }
}

Best Practices

  1. Always use unique IDs for ImGui elements when rendering multiple similar items
  2. Clean up resources when HUD elements are removed
  3. Consider performance impact of complex HUD elements
  4. Use appropriate flags to control window behavior
  5. Test HUD elements in different game states (paused, chat open, etc.)

Common Issues

  • If buttons/inputs don't work, check if NoInputs flag is set
  • If HUD doesn't align correctly, verify viewport scaling
  • If elements appear in wrong contexts, check render control settings