Download MonkeyConfig538 — Minecraft Mods — MetaMods

MonkeyConfig538

Unpublished

Downloads

0

Last update

2 years ago

Versions

19w34a — 23w35a
Client
Fabric
Quilt
Forge
Neoforge
Libraries

MonkeyConfig538

MonkeyConfig538 is a specialized library for working with configuration files in Minecraft mods. Developed by author OffsetMonkey538, it offers a simple and understandable approach to creating and managing settings.

Main Features

The library is built on Jankson, which allows adding comments directly to configuration files. The configuration creation process is intuitive and doesn't require deep programming knowledge.

Usage for Players

Regular players don't need to take additional actions - mods should automatically include this library. If some mod doesn't contain it, the library can be downloaded separately.

Usage Examples

Test mods and documentation with code examples are available for familiarization with practical library application.

Project Integration

Developers need to add JitPack to the repository list in the build.gradle file to connect the library:

repositories {
    // Other repositories

    maven {
        name = "JitPack"
        url = "https://jitpack.io"
        content {
            includeGroup "top.offsetmonkey538"
        }
    }

    // Other repositories
}

Then add the dependency:

dependencies {
    include(modImplementation("top.offsetmonkey538:monkeyconfig538:[LIBRARY_VERSION]"))
}

Configuration Creation

Creating a configuration class is done by simple inheritance from the base Config class:

package my.mod.config;

import top.offsetmonkey538.monkeyconfig538.Config;

public class MyModConfig extends Config {
    // Default value is used when the entry is missing in the file
    public int itemUsageTimeInTicks = 120;
}

Initialization and Access

Configuration is initialized in the main mod class:

@Override
public void onInitialize() {
    ConfigManager.init(new MyModConfig(), "my-mod");
}

Access to values is done through a static method:

public static MyModConfig config() {
    return (MyModConfig) ConfigManager.get("my-mod");
}

// Usage
System.out.println("Item usage time: " + config().itemUsageTimeInTicks);

Comments and Organization

The library supports adding comments through annotations:

@Comment("Maximum item usage time in ticks")
public int itemUsageTimeInTicks = 120;

For organizing complex configurations, a nested class system is available:

public class MyModConfig extends Config {
    @Comment("Main item settings")
    public MainItemConfig mainItem = new MainItemConfig();

    public static class MainItemConfig {
        @Comment("Usage time in ticks")
        public int usageTime = 120;
    }
}

Data Serialization

The library includes ready-made serializers for standard Minecraft objects:

  • Item, Block, Potion, Enchantment - serialized into identifiers
  • ItemStack - saved with identifier, count and NBT
  • BlockPos, Vec3d - converted into number arrays

Creating custom serializers for complex data structures is also supported.

Customization

Developers can extend library functionality by adding their own serializers through overriding the configureJankson method in the configuration class.

Project members
OffsetMonkey538

OffsetMonkey538

Developer

Created: 19 Jul 2023

ID: 4435