1414
1515// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
1616// Demonstrates how to use Neo's config APIs
17- @ EventBusSubscriber (modid = ExampleMod .MODID , bus = EventBusSubscriber .Bus .MOD )
1817public class Config
1918{
2019 private static final ModConfigSpec .Builder BUILDER = new ModConfigSpec .Builder ();
2120
22- private static final ModConfigSpec .BooleanValue LOG_DIRT_BLOCK = BUILDER
21+ public static final ModConfigSpec .BooleanValue LOG_DIRT_BLOCK = BUILDER
2322 .comment ("Whether to log the dirt block on common setup" )
2423 .define ("logDirtBlock" , true );
2524
26- private static final ModConfigSpec .IntValue MAGIC_NUMBER = BUILDER
25+ public static final ModConfigSpec .IntValue MAGIC_NUMBER = BUILDER
2726 .comment ("A magic number" )
2827 .defineInRange ("magicNumber" , 42 , 0 , Integer .MAX_VALUE );
2928
@@ -32,32 +31,14 @@ public class Config
3231 .define ("magicNumberIntroduction" , "The magic number is... " );
3332
3433 // a list of strings that are treated as resource locations for items
35- private static final ModConfigSpec .ConfigValue <List <? extends String >> ITEM_STRINGS = BUILDER
34+ public static final ModConfigSpec .ConfigValue <List <? extends String >> ITEM_STRINGS = BUILDER
3635 .comment ("A list of items to log on common setup." )
37- .defineListAllowEmpty ("items" , List .of ("minecraft:iron_ingot" ), Config ::validateItemName );
36+ .defineListAllowEmpty ("items" , List .of ("minecraft:iron_ingot" ), () -> "" , Config ::validateItemName );
3837
3938 static final ModConfigSpec SPEC = BUILDER .build ();
4039
41- public static boolean logDirtBlock ;
42- public static int magicNumber ;
43- public static String magicNumberIntroduction ;
44- public static Set <Item > items ;
45-
4640 private static boolean validateItemName (final Object obj )
4741 {
4842 return obj instanceof String itemName && BuiltInRegistries .ITEM .containsKey (ResourceLocation .parse (itemName ));
4943 }
50-
51- @ SubscribeEvent
52- static void onLoad (final ModConfigEvent event )
53- {
54- logDirtBlock = LOG_DIRT_BLOCK .get ();
55- magicNumber = MAGIC_NUMBER .get ();
56- magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION .get ();
57-
58- // convert the list of strings into a set of items
59- items = ITEM_STRINGS .get ().stream ()
60- .map (itemName -> BuiltInRegistries .ITEM .getValue (ResourceLocation .parse (itemName )))
61- .collect (Collectors .toSet ());
62- }
6344}
0 commit comments