You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MidnightConfigExample.java
+14-11Lines changed: 14 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
packageeu.midnightdust.core.config;
2
2
3
+
importcom.google.common.collect.Lists;
3
4
importeu.midnightdust.lib.config.MidnightConfig;
4
5
5
6
importjava.util.List;
@@ -14,19 +15,19 @@ public class MidnightConfigExample extends MidnightConfig {
14
15
15
16
@CommentpublicstaticCommenttext1; // Comments are rendered like an option without a button and are excluded from the config file
16
17
@Comment(centered = true) publicstaticCommenttext2; // Centered comments are the same as normal ones - just centered!
17
-
@Entrypublicstaticintfabric = 16777215; // Example for an int option
18
-
@Entrypublicstaticdoubleworld = 1.4D; // Example for a double option
19
18
@EntrypublicstaticbooleanshowInfo = true; // Example for a boolean option
20
-
@EntrypublicstaticStringname = "Hello World!"; // Example for a string option
21
-
@EntrypublicstaticTestEnumtestEnum = TestEnum.FABRIC; // Example for an enum option
19
+
@Entry(category = "text") publicstaticStringname = "Hello World!"; // Example for a string option, which is in a category!
20
+
@Entry(category = "text")publicstaticTestEnumtestEnum = TestEnum.FABRIC; // Example for an enum option
22
21
publicenumTestEnum { // Enums allow the user to cycle through predefined options
23
22
QUILT, FABRIC, FORGE
24
23
}
25
-
@Entry(min=69,max=420) publicstaticinthello = 420; // - The entered number has to be larger than 69 and smaller than 420
26
-
@Entry(width = 7, min = 7, isColor = true, name = "I am a color!") publicstaticStringtitleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
27
-
@Entry(name = "I am an array list!") publicstaticList<String> arrayList = List.of("String1", "String2"); // Array String Lists are also supported
28
-
@Entry(name = "I am an int slider.",isSlider = true, min = 0, max = 100) publicstaticintintSlider = 35; // Int fields can also be displayed as a Slider
29
-
@Entry(name = "I am a float slider!", isSlider = true, min = 0f, max = 1f, precision = 1000) publicstaticfloatfloatSlider = 0.24f; // And so can floats! Precision defines the amount of decimal places
24
+
@Entry(category = "numbers") publicstaticintfabric = 16777215; // Example for an int option
25
+
@Entry(category = "numbers") publicstaticdoubleworld = 1.4D; // Example for a double option
26
+
@Entry(category = "numbers", min=69,max=420) publicstaticinthello = 420; // - The entered number has to be larger than 69 and smaller than 420
27
+
@Entry(category = "text", width = 7, min = 7, isColor = true, name = "I am a color!") publicstaticStringtitleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
28
+
@Entry(category = "sliders", name = "I am an array list!") publicstaticList<String> arrayList = Lists.newArrayList("String1", "String2"); // Array String Lists are also supported
29
+
@Entry(category = "sliders", name = "I am an int slider.",isSlider = true, min = 0, max = 100) publicstaticintintSlider = 35; // Int fields can also be displayed as a Slider
30
+
@Entry(category = "sliders", name = "I am a float slider!", isSlider = true, min = 0f, max = 1f, precision = 1000) publicstaticfloatfloatSlider = 0.24f; // And so can floats! Precision defines the amount of decimal places
30
31
// The name field can be used to specify a custom translation string or plain text
31
32
32
33
publicstaticintimposter = 16777215; // - Entries without an @Entry or @Comment annotation are ignored
@@ -49,11 +50,13 @@ public enum TestEnum { // Enums allow the user to
To initialize the config you have to call "MidnightConfig.init("modid", MidnightConfigExample.class)" in your ModInitializer
55
59
To get an instance of the config screen you have to call "MidnightConfig.getScreen(parent, "modid");"
56
-
57
60
If you don't use the whole library and therefore not the automatic ModMenu integration, the code in your ModMenu integration class would look something like this:
58
61
@Override
59
62
public ConfigScreenFactory<?> getModConfigScreenFactory() {
0 commit comments