Record Class WidgetHudElement
java.lang.Object
java.lang.Record
io.github.cottonmc.cotton.gui.client.WidgetHudElement
- Record Components:
widget- the drawn widgetpositioner- an optional positioner that moves the widget
- All Implemented Interfaces:
net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement
public record WidgetHudElement(WWidget widget, @Nullable WidgetHudElement.Positioner positioner)
extends Record
implements net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement
A HUD element wrapping a
WWidget.- Since:
- 14.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacePositioners can be used to change the position of a widget based on the window dimensions. -
Constructor Summary
ConstructorsConstructorDescriptionWidgetHudElement(WWidget widget) Constructs a newWidgetHudElementwithout a positioner.WidgetHudElement(WWidget widget, int x, int y) Constructs a newWidgetHudElement.WidgetHudElement(WWidget widget, int x, int y, int width, int height) Constructs a newWidgetHudElementand resizes the inner widget.WidgetHudElement(WWidget widget, @Nullable WidgetHudElement.Positioner positioner) Creates an instance of aWidgetHudElementrecord class.WidgetHudElement(WWidget widget, WidgetHudElement.Positioner positioner, int width, int height) Constructs a newWidgetHudElementand resizes the inner widget. -
Method Summary
Modifier and TypeMethodDescriptionvoidDisables this HUD element's widget ticking.voidEnables this HUD element's widget ticking.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thepositionerrecord component.voidrender(DrawContext context, RenderTickCounter tickCounter) final StringtoString()Returns a string representation of this record class.widget()Returns the value of thewidgetrecord component.
-
Constructor Details
-
WidgetHudElement
Constructs a newWidgetHudElementwithout a positioner.- Parameters:
widget- the drawn widget
-
WidgetHudElement
Constructs a newWidgetHudElement.- Parameters:
widget- the drawn widgetx- the widget's horizontal offsety- the widget's vertical offset- See Also:
-
WidgetHudElement
public WidgetHudElement(WWidget widget, WidgetHudElement.Positioner positioner, int width, int height) Constructs a newWidgetHudElementand resizes the inner widget.- Parameters:
widget- the drawn widgetpositioner- an optional positioner that moves the widgetwidth- the widget's new widthheight- the widget's new height
-
WidgetHudElement
Constructs a newWidgetHudElementand resizes the inner widget.- Parameters:
widget- the drawn widgetx- the widget's horizontal offsety- the widget's vertical offsetwidth- the widget's new widthheight- the widget's new height- See Also:
-
WidgetHudElement
Creates an instance of aWidgetHudElementrecord class.- Parameters:
widget- the value for thewidgetrecord componentpositioner- the value for thepositionerrecord component
-
-
Method Details
-
enableTicking
public void enableTicking()Enables this HUD element's widget ticking. -
disableTicking
public void disableTicking()Disables this HUD element's widget ticking. -
render
- Specified by:
renderin interfacenet.fabricmc.fabric.api.client.rendering.v1.hud.HudElement
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
widget
Returns the value of thewidgetrecord component.- Returns:
- the value of the
widgetrecord component
-
positioner
Returns the value of thepositionerrecord component.- Returns:
- the value of the
positionerrecord component
-