MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Show me how to make an advanced config file that has different sections?"
/* Here's an example of how to create an advanced config file with different sections in Minecraft Forge. The Config class is used to define the configuration and the Config annotation is used to create different sections. */ @Config(modid = "yourmodid") public class ModConfig { @Config.Comment("Settings related to gameplay") public static Gameplay gameplay = new Gameplay(); @Config.Comment("Settings related to graphics") public static Graphics graphics = new Graphics(); public static class Gameplay { @Config.Comment("Enable or disable a feature") public boolean enableFeature = true; @Config.RangeInt(min = 1, max = 10) @Config.Comment("Set the difficulty level") public int difficulty = 1; } public static class Graphics { @Config.Comment("Enable or disable fancy graphics") public boolean fancyGraphics = true; @Config.Comment("Set the render distance") @Config.RangeInt(min = 2, max = 32) public int renderDistance = 8; } } /* After defining the configuration, you can access the values in your code like this: */ if (ModConfig.gameplay.enableFeature) { /* Do something */ } /* And you can change the values like this: */ ModConfig.gameplay.difficulty = 5; /* The configuration will automatically be saved to a file and loaded when the game starts. */