Class ColorPicker.Builder

Enclosing class:
ColorPicker

public static final class ColorPicker.Builder extends Entry.Builder<ColorPicker.Builder>
Builds a ColorPicker; from ColorPicker.builder(String). Also has the options every entry has (Entry.Builder).
  • Method Details

    • label

      public ColorPicker.Builder label(Supplier<Text> label)
      The text before ": #RRGGBB" and the editor's title, re-read on every refresh. Required.
      Parameters:
      label - read on refresh
      Returns:
      this builder
    • label

      public ColorPicker.Builder label(Text label)
      A fixed label; see label(Supplier).
      Parameters:
      label - the label
      Returns:
      this builder
    • value

      public ColorPicker.Builder value(IntSupplier value)
      Reads the mod's current color; re-read on every refresh. Required.
      Parameters:
      value - reads 0xRRGGBB, or 0xAARRGGBB with alpha
      Returns:
      this builder
    • onChange

      public ColorPicker.Builder onChange(IntConsumer onChange)
      Stores the color when the player presses Done in the editor; runs on the main thread. Required.
      Parameters:
      onChange - receives 0xRRGGBB (top byte 0), or 0xAARRGGBB with alpha
      Returns:
      this builder
    • alpha

      public ColorPicker.Builder alpha(boolean alpha)
      Whether the color has an alpha (opacity) byte the player can edit; false by default. With alpha the editor has a fourth slider, the hex form is #AARRGGBB, and the swatch is drawn translucent.
      Parameters:
      alpha - whether to edit alpha
      Returns:
      this builder
    • build

      public ColorPicker build()
      Builds the color picker.
      Returns:
      the picker
      Throws:
      IllegalStateException - if label, value or onChange is missing