DynamicHUD Dev Guide
DownloadNeed Support?
  • Dynamic HUD
  • Import using Gradle
  • Integrating DynamicHUD
    • Integrating DynamicHUD
    • Adding Widgets
    • Adding your own WidgetRenderer
    • Passing AbstractMoveableScreen instance
    • Changing default key bind
    • Changing save and load file
    • Registering Custom Widgets
  • Widget
    • Widget class
    • How to create a custom widget
    • Widget Renderer
    • WidgetData
    • DynamicValueRegistry
    • Scaling
  • Screens
    • AbstractMoveableScreen
  • ContextMenu
    • ContextMenu class
    • Using context menu
    • Option<T> class
      • Color Option
      • Boolean Option
      • Double Option
      • Runnable Option
      • Enum Option
      • List Option
      • SubMenu Option
Powered by GitBook
On this page

Was this helpful?

  1. Integrating DynamicHUD

Adding Widgets

Now that DynamicHUD is aware of your mod, you can start adding widgets. Widgets are the components that will be displayed on your HUD. This is done in the addWidgets() method of your MyIntegration class.

In this example, we will be using the included TextWidget.

MyIntegration.java
public class MyIntegration implements DynamicHudIntegration {
    TextWidget exampleWidget;

   @Override
   public void init() {
   // Learn more about the TextWidget Builder in the widgets Page.
    textWidget = new TextWidget.Builder()
                .setX(300)
                .setY(100)
                .setDraggable(true)
                .rainbow(false)
                .setDRKey("null")
                .setModID(MyMod.MOD_ID)
                .shouldScale(false)
                .build();
   }

   @Override
   public void addWidgets() {
     WidgetManager.addWidget(textWidget);
   }

   @Override
   public AbstractMoveableScreen getMovableScreen() {
    return null; // Replace with your implementation
   }
}

DRKey refers to DynamicRegistryKey which is used to support changing values.

  • TextWidget exampleWidget;: This line declares a TextWidget object named exampleWidget. TextWidget is a type of widget that can be added to the HUD.

  • public void addWidgets(): This method is called to add widgets to the HUD. Inside this method, the addWidget method of WidgetManager is called with textWidget as the argument, adding the previously created TextWidget to the HUD.

PreviousIntegrating DynamicHUDNextAdding your own WidgetRenderer

Last updated 9 months ago

Was this helpful?

about DynamicValueRegistry.

public void init(): This method is called when the mod is initialized by DynamicHUD. Inside this method, a new TextWidget is created using the TextWidget.Builder class. The builder is used to set various properties of the widget. about WidgetBuilder.

Learn more
Learn More