Class Cycle.Builder<T>
- Type Parameters:
T- the value type
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the cycle.A fixed label; seelabel(Supplier).The text before ": value", re-read on every refresh.Stores the newly selected value; runs on the main thread.Reads the mod's current value; re-read on every refresh.The values to step through, in order.How a value is shown after "label: ".
-
Method Details
-
label
The text before ": value", re-read on every refresh. Required.- Parameters:
label- read on refresh- Returns:
- this builder
-
label
A fixed label; seelabel(Supplier).- Parameters:
label- the label- Returns:
- this builder
-
values
The values to step through, in order. Required, not empty. Copied at build time; later changes to the list don't show. For an enum:Arrays.asList(MyEnum.values()).- Parameters:
values- the values; must implementObject.equals(Object)consistently- Returns:
- this builder
-
value
Reads the mod's current value; re-read on every refresh. Required. If it returns something not invalues, the cycle shows the first value (and the next click selects the second).- Parameters:
value- reads the current value- Returns:
- this builder
-
valueText
How a value is shown after "label: ". Required. Use translatable text for enum constants, e.g.m -> Text.translatable("mymod.mode." + m.key, m.englishName).- Parameters:
valueText- maps a value to its text; never returnsnull- Returns:
- this builder
-
onChange
Stores the newly selected value; runs on the main thread. Required. The button shows the new value only ifvaluereturns it afterwards.- Parameters:
onChange- receives the selected value- Returns:
- this builder
-
build
Builds the cycle.- Returns:
- the cycle
- Throws:
IllegalStateException- if a required field is missing orvaluesis empty
-