MCPcopy Create free account
hub / github.com/NeoForgeMDKs/MDK-1.21-ModDevGradle / Config

Class Config

src/main/java/com/example/examplemod/Config.java:17–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
16// Demonstrates how to use Neo's config APIs
17public class Config {
18 private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
19
20 public static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
21 .comment("Whether to log the dirt block on common setup")
22 .define("logDirtBlock", true);
23
24 public static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER
25 .comment("A magic number")
26 .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
27
28 public static final ModConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
29 .comment("What you want the introduction message to be for the magic number")
30 .define("magicNumberIntroduction", "The magic number is... ");
31
32 // a list of strings that are treated as resource locations for items
33 public static final ModConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
34 .comment("A list of items to log on common setup.")
35 .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), () -> "", Config::validateItemName);
36
37 static final ModConfigSpec SPEC = BUILDER.build();
38
39 private static boolean validateItemName(final Object obj) {
40 return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName));
41 }
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected