Package net.uku3lig.ukulib.config.option
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.text.Text> 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.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) Constructs a new generic cycling option.CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory, boolean active) Constructs a new generic cycling option. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.client.gui.widget.ClickableWidgetcreateWidget(int x, int y, int width, int height) Creates the widget.static <T extends Enum<T>>
net.minecraft.text.TextenumNameToText(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.option.SimpleOption.TooltipFactory<Boolean> tooltipFactory) 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.text.Text> 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.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) Creates a new option based on an enum's values.static <T extends net.minecraft.util.TranslatableOption>
CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter) Creates a new option from aTranslatableOption, with an empty tooltip.static <T extends net.minecraft.util.TranslatableOption>
CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) Creates a new option from aTranslatableOption.static <T extends Enum<T> & net.minecraft.util.TranslatableOption>
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> & net.minecraft.util.TranslatableOption>
CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) Creates a new option based on atranslatableenum's values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.uku3lig.ukulib.config.option.WidgetCreator
wide
-
Field Details
-
BOOL_TO_TEXT
Boolean to text converter.
-
-
Constructor Details
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory, 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 texttooltipFactory- The tooltip factoryactive- Whether the button can be clicked
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) 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 texttooltipFactory- The tooltip factory
-
CyclingOption
public CyclingOption(String key, Collection<T> values, T initialValue, Consumer<T> setter, Function<T, net.minecraft.text.Text> 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.option.SimpleOption.TooltipFactory<Boolean> tooltipFactory) Creates a new boolean option.- Parameters:
key- The translation keyinitialValue- The initial boolean valuesetter- The callback for the modified valuetooltipFactory- The tooltip factory- 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 net.minecraft.util.TranslatableOption> CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) Creates a new option from aTranslatableOption.- 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 valuetooltipFactory- The tooltip factory- Returns:
- The newly constructed option
-
ofTranslatable
public static <T extends net.minecraft.util.TranslatableOption> CyclingOption<T> ofTranslatable(String key, Collection<T> values, T initialValue, Consumer<T> setter) Creates a new option from aTranslatableOption, 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.text.Text> valueToText, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) 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 texttooltipFactory- The tooltip factory- 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.text.Text> 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> & net.minecraft.util.TranslatableOption> CyclingOption<T> ofTranslatableEnum(String key, Class<T> klass, T initialValue, Consumer<T> setter, net.minecraft.client.option.SimpleOption.TooltipFactory<T> tooltipFactory) 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 valuetooltipFactory- The tooltip factory- Returns:
- The newly created option
-
ofTranslatableEnum
public static <T extends Enum<T> & net.minecraft.util.TranslatableOption> 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.widget.ClickableWidget 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
-