/
ModConfig.java
65 lines (52 loc) · 1.73 KB
/
ModConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package io.github.cadiboo.examplemod.config;
import io.github.cadiboo.examplemod.util.ModReference;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.Config.Comment;
import net.minecraftforge.common.config.Config.LangKey;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import static io.github.cadiboo.examplemod.util.ModReference.*;
/**
* Our Mod's configuration
*
* @author Cadiboo
*/
@SuppressWarnings("WeakerAccess")
@Config(modid = MOD_ID)
@LangKey(MOD_ID + ".config.title")
public final class ModConfig {
@Comment("Boolean")
public static boolean exampleBoolean = false;
//sub category
@Comment("Numbers")
public static Numbers numbers = new Numbers(1, 2.5f, 3.1d);
public static class Numbers {
@Comment("An Integer (int) type number")
public int int_;
@Comment("A Float (floating point) type number")
public float float_;
@Comment("A Double (double length floating point) type number")
public double double_;
public Numbers(final int int_, final float float_, final double double_) {
this.int_ = int_;
this.float_ = float_;
this.double_ = double_;
}
}
@Mod.EventBusSubscriber(modid = MOD_ID)
private static class EventHandler {
/**
* Inject the new values and save to the config file when the config has been changed from the GUI.
*
* @param event The event
*/
@SubscribeEvent
public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(MOD_ID)) {
ConfigManager.sync(MOD_ID, Config.Type.INSTANCE);
}
}
}
}