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
  • Class Variables
  • Constructor
  • Methods

Was this helpful?

  1. Widget

Widget Renderer

The WidgetRenderer class is a key component in rendering widgets on the screen for your Minecraft mod. This class manages the list of widgets and controls their rendering based on the current screen and user interactions.

The Widget Renderer class is designed to segregate widget rendering by groups.

The AbstractMoveableScreen utilizes the WidgetRenderer to display and drag widgets from a single group, unlike earlier versions which allowed dragging widgets from all mods within a single screen. This makes it easier for mod developers as well as players to manage widgets.

Class Variables

  • List<Class<? extends Screen>> allowedScreens: A thread-safe list that holds the classes of screens where widgets are allowed to be rendered.

  • boolean isInEditor: A flag indicating whether the widget is in editor mode.

  • Widget selectedWidget: The currently selected widget.

  • List<Widget> widgets: The list of widgets that this renderer should render.

  • boolean renderInGameHud: A flag indicating whether widgets should be rendered in the in-game HUD.

Constructor

The constructor takes a list of widgets that the renderer should render.

public WidgetRenderer(List<Widget> widgets) {
    this.widgets = widgets;
    addScreen(GameMenuScreen.class);
}

Methods

  • void addWidget(Widget widget): Adds a widget to the list of widgets to be rendered.

  • void addScreen(Class<? extends Screen> screen): Adds a screen class to the list of allowed screens where widgets can be rendered.

  • void shouldRenderInGameHud(boolean renderInGameHud): Sets whether widgets should be rendered in the in-game HUD.

  • void renderWidgets(DrawContext context, int mouseX, int mouseY): Renders the widgets based on the current screen and whether the widget is in editor mode.

PreviousHow to create a custom widgetNextWidgetData

Last updated 1 year ago

Was this helpful?