Record Class WidgetHudElement

java.lang.Object
java.lang.Record
io.github.cottonmc.cotton.gui.client.WidgetHudElement
Record Components:
widget - the drawn widget
positioner - 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
  • Constructor Details

    • WidgetHudElement

      public WidgetHudElement(WWidget widget)
      Constructs a new WidgetHudElement without a positioner.
      Parameters:
      widget - the drawn widget
    • WidgetHudElement

      public WidgetHudElement(WWidget widget, int x, int y)
      Constructs a new WidgetHudElement.
      Parameters:
      widget - the drawn widget
      x - the widget's horizontal offset
      y - the widget's vertical offset
      See Also:
    • WidgetHudElement

      public WidgetHudElement(WWidget widget, WidgetHudElement.Positioner positioner, int width, int height)
      Constructs a new WidgetHudElement and resizes the inner widget.
      Parameters:
      widget - the drawn widget
      positioner - an optional positioner that moves the widget
      width - the widget's new width
      height - the widget's new height
    • WidgetHudElement

      public WidgetHudElement(WWidget widget, int x, int y, int width, int height)
      Constructs a new WidgetHudElement and resizes the inner widget.
      Parameters:
      widget - the drawn widget
      x - the widget's horizontal offset
      y - the widget's vertical offset
      width - the widget's new width
      height - the widget's new height
      See Also:
    • WidgetHudElement

      public WidgetHudElement(WWidget widget, @Nullable @Nullable WidgetHudElement.Positioner positioner)
      Creates an instance of a WidgetHudElement record class.
      Parameters:
      widget - the value for the widget record component
      positioner - the value for the positioner 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

      public void render(DrawContext context, RenderTickCounter tickCounter)
      Specified by:
      render in interface net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • widget

      public WWidget widget()
      Returns the value of the widget record component.
      Returns:
      the value of the widget record component
    • positioner

      Returns the value of the positioner record component.
      Returns:
      the value of the positioner record component