Widget class
This page explains the abstract Widget class..
Last updated
Was this helpful?
This page explains the abstract Widget class..
Last updated
Was this helpful?
The Widget
class is an abstract class that serves as a base for creating various types of widgets. It contains essential properties and methods for managing widget behavior and state.
UID: Each widget has a unique identifier (uid
) for loading and saving.
Display: A boolean indicating whether the widget should be displayed (display
).
Draggable: A boolean indicating whether the widget can be dragged (isDraggable
).
Position: The widget’s position on the screen is defined by x
and y
coordinates.
Scaling: A boolean indicating whether the widget should scale with the screen (shouldScale
).
*ModID* are an essential part of DynamicHUD. Each widget displayed is categorized into groups of "mod ids". This facilitates multi-Mod experience and becomes easier for DynamicHUD as well as users to segregate and identify widgets. Moreover, the secondary class uses this data to manage different widgets.
displayBg: Renders a background for the widget, with a different color depending on whether it is enabled or disabled.
readFromTag: Reads the widget’s state from an NBT tag.
writeToTag: Writes the widget’s state to an NBT tag.
shouldDisplay: Returns whether the widget should be displayed.
getWidgetBox: Returns the widget’s bounding box.
The WidgetBuilder
is an abstract nested class used to construct widget instances. It provides methods to set properties such as position, visibility, and scaling.
This is how the builder is normally used: