Interface ConfigEditor<T>

Type Parameters:
T -

public interface ConfigEditor<T>
A config editor provides the logic on how to display a config value in a GUI. The config editor may not store additional state, as the same editor can be used for multiple entries. However, the widgets created by an editor can store state.
  • Method Details

    • defaultValue

      T defaultValue()
      Gets the default value for places where elements with this editor are created that have no value set.
    • createWidget

      net.minecraft.client.gui.components.AbstractWidget createWidget(net.minecraft.client.gui.screens.Screen screen, T initialValue, WidgetProperties<T> properties)
      Creates a widget for a given initial value.
      Parameters:
      screen - The screen used for display. This screen must be used if the widget wants to draw tooltips, or they won't work correctly.
      initialValue - The initial value for the created widget.
      properties - Additional properties for the widget.
    • updateWidget

      net.minecraft.client.gui.components.AbstractWidget updateWidget(net.minecraft.client.gui.screens.Screen screen, net.minecraft.client.gui.components.AbstractWidget old, WidgetProperties<T> properties)
      Updates a previously created widget, for example, after a screen resize.
      Parameters:
      screen - The screen used for display. This screen must be used if the widget wants to draw tooltips, or they won't work correctly.
      old - The old widget that was created before, either by createWidget(net.minecraft.client.gui.screens.Screen, T, org.moddingx.libx.config.gui.WidgetProperties<T>) or by this method.
      properties - Additional properties for the widget.
    • unsupported

      static <T> ConfigEditor<T> unsupported(T defaultValue)
      Creates a new editor that states, that a value can't be edited through the GUI.
      Parameters:
      defaultValue - The value that should be used as the default value.
    • option

      static <T> ConfigEditor<Optional<T>> option(ConfigEditor<T> editor)
      Creates a new editor that represents an option of another editor by adding a checkbox to select whether a value is set or not.
    • toggle

      static <T> ConfigEditor<T> toggle(List<T> elems)
      Creates a toggle editor for a set of elements. This can be a single button that cycles on click or a sub screen so select the element, depending on the number of elements given.
    • toggle

      static <T> ConfigEditor<T> toggle(List<T> elems, Function<T,net.minecraft.network.chat.Component> name)
      Creates a toggle editor for a set of elements. This can be a single button that cycles on click or a sub screen so select the element, depending on the number of elements given.
      Parameters:
      name - A function that defines how to convert elements into a Component for display.
    • input

      static ConfigEditor<String> input()
      Creates a new text input editor.
    • input

      static ConfigEditor<String> input(ValidatorInfo<?> validator)
      Creates a new text input editor.
      Parameters:
      validator - Validator information used. This causes the widget to go red when invalid values are entered.
    • input

      static <T> ConfigEditor<T> input(InputProperties<T> input)
      Creates a new text input editor.
      Parameters:
      input - Information on which input to allow and how to process that input.
    • input

      static <T> ConfigEditor<T> input(InputProperties<T> input, ValidatorInfo<?> validator)
      Creates a new text input editor.
      Parameters:
      input - Information on which input to allow and how to process that input.
      validator - Validator information used. This causes the widget to go red when invalid values are entered.
    • slider

      static <T> ConfigEditor<T> slider(Function<T,Double> extractor, Function<Double,T> factory)
      Creates a new editor for a slider.
      Parameters:
      extractor - A function that extracts a value from a double between 0 and 1
      factory - A function that turns a double between 0 and 1 into a value
    • custom

      static <T> ConfigEditor<T> custom(T defaultValue, Function<T,ConfigScreenContent<T>> contentFactory)
      Creates a config editor with a button that will then open a sub-screen based on the given content.
      Parameters:
      contentFactory - A function that creates a new screen content from a given initial value.