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 interface
Positioners can be used to change the position of a widget based on the window dimensions. -
Constructor Summary
ConstructorsConstructorDescriptionWidgetHudElement
(WWidget widget) Constructs a newWidgetHudElement
without 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 newWidgetHudElement
and resizes the inner widget.WidgetHudElement
(WWidget widget, @Nullable WidgetHudElement.Positioner positioner) Creates an instance of aWidgetHudElement
record class.WidgetHudElement
(WWidget widget, WidgetHudElement.Positioner positioner, int width, int height) Constructs a newWidgetHudElement
and resizes the inner widget. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Disables this HUD element's widget ticking.void
Enables this HUD element's widget ticking.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of thepositioner
record component.void
render
(DrawContext context, RenderTickCounter tickCounter) final String
toString()
Returns a string representation of this record class.widget()
Returns the value of thewidget
record component.
-
Constructor Details
-
WidgetHudElement
Constructs a newWidgetHudElement
without 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 newWidgetHudElement
and 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 newWidgetHudElement
and 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 aWidgetHudElement
record class.- Parameters:
widget
- the value for thewidget
record componentpositioner
- the value for thepositioner
record 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:
render
in 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 thewidget
record component.- Returns:
- the value of the
widget
record component
-
positioner
Returns the value of thepositioner
record component.- Returns:
- the value of the
positioner
record component
-