Download JasonConfig — Minecraft Mods — MetaMods
JasonConfig

JasonConfig

Active

Downloads

1

Last update

4 months ago

Versions

1.20.1 — 1.20.6
Client
Forge
Libraries
Control
Utils

JasonConfig

This modification is a library for Minecraft mod developers. Regular players only need to install it - further information is not required for basic usage.

For Developers

Project Integration Simply add the dependency through CurseMaven by copying the corresponding snippet from the "Files" section on the mod page. Example (insert actual data):

implementation "curse.maven:cloth-config-348521:5987045"

Comparison with Forge's Configuration System

Advantages

  • Uses JSON instead of TOML, increasing reliability and supporting all data types, including empty lists
  • Compatibility with more Java/Minecraft classes - for example, Vec3 works without issues thanks to JSON object structure
  • Simplified programming syntax while maintaining the familiar approach of creating configuration classes

Disadvantages

  • JSON format is less user-readable compared to TOML
  • Experimental stage - minor errors might occur since development is handled by a single person

Implementation Example

Setup instructions and code examples can be found in the "api" package after adding the dependency. All necessary elements are well documented for ease of use.

public class ExampleConfigClass {
    public static final Config EXAMPLE_CONFIG = new Config(MODID + "-example_config");

    // This file is only created in development environment
    public static final ConfigComment DEVCOMMENT
            = new ConfigComment("File generates only in dev environment", EXAMPLE_CONFIG);

    /// The following configuration values are automatically added to Config
    public static final ConfigValue<Float> EXAMPLE_FLOAT
            = new ConfigValue<>(10f, "exampleFloat", EXAMPLE_CONFIG, new TypeToken<Float>(){}.getType());

    /// Comments are placed in declaration order - this will appear after EXAMPLE_FLOAT and before EXAMPLE_LIST
    public static final ConfigComment EXAMPLE_COMMENT
            = new ConfigComment("This is a list!", EXAMPLE_CONFIG);
    public static final ConfigValue<List<String>> EXAMPLE_LIST
            = new ConfigValue<>(List.of("value1", "value2", "value3", "value4"), "exampleList", EXAMPLE_CONFIG, new TypeToken<List<String>>(){}.getType());

    /// Working with Vec3! Many Java classes incompatible with Forge configs are supported here
    public static final ConfigComment VEC3_COMMENT
            = new ConfigComment("This is Vec3! Works where Forge configs fail", EXAMPLE_CONFIG);
    public static final ConfigValue<List<Vec3>> EXAMPLE_VEC3
            = new ConfigValue<>(List.of(new Vec3(123,123,123), Vec3.ZERO), "exampleVec3", EXAMPLE_CONFIG, new TypeToken<List<Vec3>>(){}.getType());

    /// Support for custom classes, records are ideal for data storage
    public static final ConfigComment CLASS_COMMENT
            = new ConfigComment("Integration of new classes, records are optimal for data structuring", EXAMPLE_CONFIG);
    public static final ConfigValue<LinkedHashMap<String, Info>> EXAMPLE
            = new ConfigValue<>(new LinkedHashMap<>(Map.of("information", new Info(1.0f, false, 8))), "example", EXAMPLE_CONFIG, new TypeToken<LinkedHashMap<String, Info>>(){}.getType());

    /// This method must be called in your mod's main class
    /// You need to register the Config and add ConfigValue variables
    public static void init() {
        EXAMPLE_CONFIG.register();

        /// Examples of retrieving values
        /// Direct access (similar to working with Forge Configs)
    }

    public record Info(float f, boolean bool, int integer) { }
}
Project members
Corrinedev

Corrinedev

Developer

Created: 19 Mar 2025

ID: 84387