Class Keybind.Builder

Enclosing class:
Keybind

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

    • label

      public Keybind.Builder label(Supplier<Text> label)
      The text before ": key", re-read on every refresh. Required.
      Parameters:
      label - read on refresh
      Returns:
      this builder
    • label

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

      public Keybind.Builder value(Supplier<Key> value)
      Reads the mod's current key; re-read on every refresh. Required. May return null or Key.UNBOUND for no key.
      Parameters:
      value - reads the key
      Returns:
      this builder
    • onChange

      public Keybind.Builder onChange(Consumer<Key> onChange)
      Stores the newly bound key; runs on the main thread. Required. Gets Key.UNBOUND when the player pressed Escape.
      Parameters:
      onChange - receives the new key, never null
      Returns:
      this builder
    • allowMouse

      public Keybind.Builder allowMouse(boolean allowMouse)
      Whether mouse buttons can be bound; true by default, as in vanilla. If false, a mouse click while waiting just stops waiting.
      Parameters:
      allowMouse - whether to accept mouse buttons
      Returns:
      this builder
    • build

      public Keybind build()
      Builds the key binding button.
      Returns:
      the button
      Throws:
      IllegalStateException - if label, value or onChange is missing