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

Passing AbstractMoveableScreen instance

PreviousAdding your own WidgetRendererNextChanging default key bind

Last updated 7 months ago

Was this helpful?

DynamicHUD integration necessitates a key object. The mod must return an , which will display the widgets and record user inputs.

Since the AbstractMoveableScreen is well, abstract, you can extend the class, add your own features, and still pass it to DynamicHudIntegration.

public class MyIntegration implements DynamicHudIntegration{
    TextWidget exampleWidget;
    WidgetRenderer renderer;
    
    @Override
    public void init() {
       //Previously added and initialised text widget
    }

    @Override
    public void addWidgets() {
       //Previously added and initialised text widget
    }
  
    public void initAfter() {
       //Previously initialised WidgetRenderer object
    }

    @Override
    public WidgetRenderer getWidgetRenderer() {
        return renderer;
    }
    
    @Override
    public AbstractMoveableScreen getMovableScreen() {
        return new AbstractMoveableScreen(Text.literal("MyText"), renderer) {
        };
    }
}

The AbstractMoveableScreen instance returned should never be null.

AbstractMoveableScreen
AbstractMoveableScreen