Class CyclingOption<T>
java.lang.Object
net.uku3lig.ukulib.config.option.CyclingOption<T>
- Type Parameters:
T- The type of the value
- All Implemented Interfaces:
WidgetCreator
An option type based on a finite amount of cycling values of the same type.
-
Field Summary
FieldsModifier and TypeFieldDescriptionBoolean to text converter. -
Constructor Summary
ConstructorsConstructorDescriptionCyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText) Constructs a new generic cycling option, with no tooltip.CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Constructs a new generic cycling option.CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier, boolean active) Constructs a new generic cycling option. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.client.gui.components.AbstractWidgetcreateWidget(int x, int y, int width, int height) Creates the widget.static <T extends Enum<T>>
net.minecraft.network.chat.ComponentenumNameToText(T value) Returns a text that contains the name of the enum constant.static CyclingOption<Boolean> Creates a new boolean option, with an empty tooltip.static CyclingOption<Boolean> ofBoolean(String key, boolean initialValue, Consumer<Boolean> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull Boolean> tooltipSupplier) Creates a new boolean option.static <T extends Enum<T>>
CyclingOption<T> Creates a new option based on an enum's values, with an empty tooltip.static <T extends Enum<T>>
CyclingOption<T> ofEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText) Creates a new option based on an enum's values, with an empty tooltip.static <T extends Enum<T>>
CyclingOption<T> ofEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option based on an enum's values.static <T extends StringTranslatable>
CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter) Creates a new option from aStringTranslatable, with an empty tooltip.static <T extends StringTranslatable>
CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option from aStringTranslatable.static <T extends Enum<T> & StringTranslatable>
CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter) Creates a new option based on atranslatableenum's values, with an empty tooltip.static <T extends Enum<T> & StringTranslatable>
CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option based on atranslatableenum's values.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WidgetCreator
createWidget, wide
-
Field Details
-
BOOL_TO_TEXT
-
-
Constructor Details
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier, boolean active) Constructs a new generic cycling option.- Parameters:
key- The translation keyvalues- The possible option valuesinitialValue- The initial displayed valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable texttooltipSupplier- The tooltip supplieractive- Whether the button can be clicked
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Constructs a new generic cycling option.- Parameters:
key- The translation keyvalues- The possible option valuesinitialValue- The initial displayed valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable texttooltipSupplier- The tooltip supplier
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText) Constructs a new generic cycling option, with no tooltip.- Parameters:
key- The translation keyvalues- The possible option valuesinitialValue- The initial displayed valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable text- See Also:
-
-
Method Details
-
ofBoolean
public static CyclingOption<Boolean> ofBoolean(String key, boolean initialValue, Consumer<Boolean> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull Boolean> tooltipSupplier) Creates a new boolean option.- Parameters:
key- The translation keyinitialValue- The initial boolean valuesetter- The callback for the modified valuetooltipSupplier- The tooltip supplier- Returns:
- The newly constructed option
-
ofBoolean
public static CyclingOption<Boolean> ofBoolean(String key, boolean initialValue, Consumer<Boolean> setter) Creates a new boolean option, with an empty tooltip.- Parameters:
key- The translation keyinitialValue- The initial boolean valuesetter- The callback for the modified value- Returns:
- The newly constructed option
- See Also:
-
ofTranslatable
public static <T extends StringTranslatable> CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option from aStringTranslatable.- Type Parameters:
T- The type of the option- Parameters:
key- The translation keyvalues- The values to be displayedinitialValue- The initial valuesetter- The callback for the modified valuetooltipSupplier- The tooltip supplier- Returns:
- The newly constructed option
-
ofTranslatable
public static <T extends StringTranslatable> CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter) Creates a new option from aStringTranslatable, with an empty tooltip.- Type Parameters:
T- The type of the option- Parameters:
key- The translation keyvalues- The values to be displayedinitialValue- The initial valuesetter- The callback for the modified value- Returns:
- The newly constructed option
-
ofEnum
public static <T extends Enum<T>> CyclingOption<T> ofEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option based on an enum's values.- Type Parameters:
T- The type of the enum- Parameters:
key- The translation keyklass- The class type of the enuminitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable texttooltipSupplier- The tooltip supplier- Returns:
- The newly created option
-
ofEnum
public static <T extends Enum<T>> CyclingOption<T> ofEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, Function<T, net.minecraft.network.chat.Component> valueToText) Creates a new option based on an enum's values, with an empty tooltip.- Type Parameters:
T- The type of the enum- Parameters:
key- The translation keyklass- The class type of the enuminitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable text- Returns:
- The newly created option
- See Also:
-
ofEnum
public static <T extends Enum<T>> CyclingOption<T> ofEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter) Creates a new option based on an enum's values, with an empty tooltip. The value text is the constant's name.- Type Parameters:
T- The type of the enum- Parameters:
key- The translation keyklass- The class type of the enuminitialValue- The initial valuesetter- The callback for the modified value- Returns:
- The newly created option
- See Also:
-
ofTranslatableEnum
public static <T extends Enum<T> & StringTranslatable> CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull T> tooltipSupplier) Creates a new option based on atranslatableenum's values.- Type Parameters:
T- The type of the enum- Parameters:
key- The translation keyklass- The class type of the enuminitialValue- The initial valuesetter- The callback for the modified valuetooltipSupplier- The tooltip supplier- Returns:
- The newly created option
-
ofTranslatableEnum
public static <T extends Enum<T> & StringTranslatable> CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter) Creates a new option based on atranslatableenum's values, with an empty tooltip.- Type Parameters:
T- The type of the enum- Parameters:
key- The translation keyklass- The class type of the enuminitialValue- The initial valuesetter- The callback for the modified value- Returns:
- The newly created option
- See Also:
-
createWidget
public net.minecraft.client.gui.components.AbstractWidget createWidget(int x, int y, int width, int height) Description copied from interface:WidgetCreatorCreates the widget.- Specified by:
createWidgetin interfaceWidgetCreator- Parameters:
x- The x positiony- The y positionwidth- The widget widthheight- The widget height- Returns:
- The created widget
-
enumNameToText
Returns a text that contains the name of the enum constant.- Type Parameters:
T- The type of the enum- Parameters:
value- The enum constant- Returns:
- The text
-