Class CottonHud

java.lang.Object
io.github.cottonmc.cotton.gui.client.CottonHud

@Environment(CLIENT) public final class CottonHud extends Object
Manages widgets that are painted on the in-game HUD.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Positioners can be used to change the position of a widget based on the window dimensions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    add(WWidget widget)
    Adds a new widget to the HUD.
    static void
    add(WWidget widget, int x, int y)
    Adds a new widget to the HUD at the specified offsets.
    static void
    add(WWidget widget, int x, int y, int width, int height)
    Adds a new widget to the HUD at the specified offsets and resizes it.
    static void
    add(WWidget widget, CottonHud.Positioner positioner)
    Adds a new widget to the HUD with a custom positioner.
    static void
    add(WWidget widget, CottonHud.Positioner positioner, int width, int height)
    Adds a new widget to the HUD with a custom positioner and resizes it.
    static void
    remove(WWidget widget)
    Removes the widget from the HUD.
    static void
    Sets the positioner of the widget.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CottonHud

      public CottonHud()
  • Method Details

    • add

      public static void add(WWidget widget)
      Adds a new widget to the HUD.
      Parameters:
      widget - the widget
    • add

      public static void add(WWidget widget, int x, int y)
      Adds a new widget to the HUD at the specified offsets.
      Parameters:
      widget - the widget
      x - the x offset
      y - the y offset
      See Also:
    • add

      public static void add(WWidget widget, int x, int y, int width, int height)
      Adds a new widget to the HUD at the specified offsets and resizes it.
      Parameters:
      widget - the widget
      x - the x offset
      y - the y offset
      width - the width of the widget
      height - the height of the widget
      See Also:
    • add

      public static void add(WWidget widget, CottonHud.Positioner positioner)
      Adds a new widget to the HUD with a custom positioner.
      Parameters:
      widget - the widget
      positioner - the positioner
    • add

      public static void add(WWidget widget, CottonHud.Positioner positioner, int width, int height)
      Adds a new widget to the HUD with a custom positioner and resizes it.
      Parameters:
      widget - the widget
      positioner - the positioner
      width - the width of the widget
      height - the height of the widget
    • setPositioner

      public static void setPositioner(WWidget widget, CottonHud.Positioner positioner)
      Sets the positioner of the widget.
      Parameters:
      widget - the widget
      positioner - the positioner
    • remove

      public static void remove(WWidget widget)
      Removes the widget from the HUD.
      Parameters:
      widget - the widget