Skip to content

Annotation System

@Config

Marks a class as a configuration class. You must specify the config name and type.

java
// Basic usage
@Config(name = "mymod", type = ModConfig.Type.COMMON)
public class MyConfig { ... }

// With group subdirectory — file generated as config/client/mymod-client.toml
@Config(name = "mymod", group = "client", type = ModConfig.Type.CLIENT)
public class MyClientConfig { ... }
AttributeTypeDescription
nameStringConfig primary key name, used to generate the file name and translation key prefix
groupStringConfig file subdirectory (optional, defaults to ""). When set, file path becomes config/<group>/<name>-<type>.toml
typeModConfig.TypeConfig type: COMMON / CLIENT / SERVER, defaults to COMMON

@Comment

Provides a comment for a config field, generating both a TOML comment and a tooltip translation key.

java
@Comment("The maximum speed of the machine.")
public int maxSpeed = 10;

Translation key format: <modid>.configuration.<fieldpath>.tooltip

@CollapsibleObject

Marks a nested object field so that its internal fields are displayed in a collapsible group within the config GUI.

java
@CollapsibleObject
public NestedConfig nested = new NestedConfig();

Fields inside the nested object also support annotations such as @Comment and @BoundedDiscrete.

@BoundedDiscrete

Restricts the value range of numeric type fields.

java
@BoundedDiscrete(min = 0, max = 100)
public int volume = 80;

@BoundedDiscrete(min = 1, max = Double.POSITIVE_INFINITY)
public double scale = 1.0;
AttributeTypeDefaultDescription
mindouble-InfinityMinimum value (incl.)
maxdouble+InfinityMaximum value (incl.)

Supported field types: byte, short, int, long, float, double.

BoundedDiscrete.Util

Internal utility class that converts the double bounds from the annotation into the actual range for each type:

java
// Called internally
BoundedDiscrete.Util.parseIntRange(min, max);  // -> int
BoundedDiscrete.Util.parseLongRange(min, max); // -> long
// etc.

Automatically uses defineInRange during ConfigManager.register.

Full Example

java
@Config(name = "example", type = ModConfig.Type.COMMON)
public class ExampleConfig {
    @Comment("The number of uses.")
    @BoundedDiscrete(min = 1, max = 64)
    public int durability = 10;

    @Comment("The speed multiplier.")
    @BoundedDiscrete(min = 0.1, max = 10.0)
    public double speed = 1.0;

    @Comment("Enable experimental mode.")
    public boolean experimental = false;

    @CollapsibleObject
    public Inner inner = new Inner();

    public static class Inner {
        @Comment("Inner factor value")
        public double factor = 1.0;
    }
}

Released under the CC-BY-NC-SA 4.0 License.