Class WDynamicLabel

java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WDynamicLabel

public class WDynamicLabel extends WWidget
Dynamic labels are labels that pull their text from a Supplier<String>. They can be used for automatically getting data from a block entity or another data source.

Translating strings in dynamic labels should be done using I18n.translate(String, Object...).

  • Field Details

  • Constructor Details

  • Method Details

    • paint

      @Environment(CLIENT) public void paint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY)
      Description copied from class: WWidget
      Paints this widget.
      Overrides:
      paint in class WWidget
      Parameters:
      matrices - the rendering matrix stack
      x - this widget's X coordinate on the screen
      y - this widget's Y coordinate on the screen
      mouseX - the X coordinate of the cursor
      mouseY - the X coordinate of the cursor
    • canResize

      public boolean canResize()
      Description copied from class: WWidget
      Checks whether this widget can be resized using WWidget.setSize(int, int).
      Overrides:
      canResize in class WWidget
      Returns:
      true if this widget can be resized, false otherwise
    • setSize

      public void setSize(int x, int y)
      Description copied from class: WWidget
      Sets the size of this widget.

      Overriding methods may restrict one of the dimensions to be a constant value, for example super.setSize(x, 20).

      Overrides:
      setSize in class WWidget
      Parameters:
      x - the new width
      y - the new height
    • setDarkmodeColor

      public WDynamicLabel setDarkmodeColor(int color)
    • disableDarkmode

      public WDynamicLabel disableDarkmode()
    • setColor

      public WDynamicLabel setColor(int color, int darkmodeColor)
    • setText

      public WDynamicLabel setText(Supplier<String> text)
    • setAlignment

      public WDynamicLabel setAlignment(HorizontalAlignment align)