---
title: Using the Config API
hide_meta: true
---

<Callout variant="warning">
The configuration API is only for versions 1.16.5 and higher.
</Callout>

# Creating the Config class

To create a new config class, define a class annotated with `@Config`. The `id` parameter of the annotation should match your mod's ID. Here's an example:

```java
@Config(id = "yourmodid")
public class ModConfig {
    // Configuration fields will be defined here
}
```

Once created, simply register your fields for the configs you wish to use. These can only public, non-final and instance fields only.

Supported datatypes include:

- `boolean`, `boolean[]`
- `char`
- `int`, `int[]`
- `long`, `long[]`
- `float`, `float[]`
- `double`, `double[]`
- `String`, `String[]`
- `Enums`

<Callout variant="info">
Objects are used for config nesting/splitting into multiple categories. Just include some [@Configurable](https://github.com/AzureDoom/AzureLib/blob/1.20/common/src/main/java/mod/azure/azurelib/config/Configurable.java) fields in the nested object instance.
</Callout>

- `Object`

Example:
```java
@Config(id = MyMod.MOD_ID)
public class ModConfig {

    @Configurable
    public boolean myBoolean = true;

    @Configurable
    public int myInt = 3;

    @Configurable
    public int[] myIntArray = {30, 20, 10, 5};

    @Configurable
    public CustomEnum myEnum = CustomEnum.SOME_VALUE;

    @Configurable
    public NestedObject myNest = new NestedObject();

    public static class NestedObject {
        @Configurable
        public double myDouble = 3.14159265359;
    }
}
```

## Registering the Config

<CodeTabs>

```java !!tabs NeoForge/Forge
In your mods constructor, add the following:
public static ModConfig config;

public YourMod() {
    config = AzureLibMod.registerConfig(ModConfig.class,
        //you can use .json or .yaml formats
        ConfigFormats.json()).getConfigInstance();
}
```

```java !!tabs Fabric
In your mods Initializer class, add the following:
public static ModConfig config;

@Override
public void onInitialize() {
    config = AzureLibMod.registerConfig(ModConfig.class,
        //you can use .json or .yaml formats
        ConfigFormats.json()).getConfigInstance();
}
```

</CodeTabs>

## Calling your Config class

To call, simply use above created config value where you wish to use it!

Example:
```java
public void someMethod() {
    MyMod.config.configvalue;
}
```