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.
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.
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.
Last updated
Was this helpful?