Background

CodecLib

ModsCodecLib
CodecLib

CodecLib

CurseForge
MiscellaneousQuality of LifeLibraryUtility

A simpler way to use Hytale config codecs

CodecLib

CodecLib is a lightweight Hytale config library that automates the creation of BuilderCodecs using reflection. It allows you to create complex configuration files and data structures using simple POJOs (Plain Old Java Objects), without manually defining every field and codec.


✨ Features

  • Zero Boilerplate: Automatically converts classes to Hytale BuilderCodecs.

  • Deep Nesting: Recursively handles nested objects and configurations.

  • Annotations: Custom field naming via @FieldName.

  • Type Support: Built-in handling for:

    • Primitives (int, boolean, double, etc.)
    • Arrays (String[], int[], etc.)
    • UUID and Instant
    • Nested custom objects

πŸ“¦ Installation

Replace with your actual JitPack/Maven instructions if hosted, otherwise shade or copy the library.

Gradle (Groovy)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.Emibergo02:CodecLib:main-SNAPSHOT'
}
//It is suggested to relocate the package in your project
shadowJar {
    relocate 'dev.unnm3d.codeclib', 'your.package.name.codeclib'
}

πŸš€ Usage

1. Basic Configuration

Create a class with the fields you want to serialize. You can initialize them to set default values.

/**
 * RULES:
 * 1. Fields MUST NOT be final, static or transient.
 * 2. Fields MUST start with an uppercase letter (Hytale Config convention).
 */
public class MyConfig {

    private String ExampleField = "defaultValue";

    @FieldName("DifferentName") //Inside config.json this field will be named "DifferentName"
    private String exampleFieldButWithDifferentName = "defaultValue2";

    @SkipConfigField //This will skip the field for serialization
    private String thisFieldWillNotExist = "defaultValue3";

    private int ExampleIntField = 42;
}

2. Generating the Codec

Use the CodecFactory to generate the codec and load your config.

// ... inside your plugin ...

public CodecLibPlugin(@Nonnull JavaPluginInit init) {
    super(init);
    instance = this;
    //Optionally, you can register your own codecs for your types
    CodecFactory.registerCustomCodec(Path.class, Codec.PATH);
    //Just use CodecFactory.createClassCodec(YourClass.class) as Codec
    CONFIG = withConfig("yourcustomconfig", CodecFactory.createClassCodec(ExampleConfig.class));
}

@Override
protected void setup() {
    CONFIG.save();//You can save normally like this
    assert Objects.equals(CONFIG.get().getExampleField(), "defaultValue");
    assert Objects.equals(CONFIG.get().getExampleIntField(), 42);
    assert Objects.equals(CONFIG.get().getExampleFieldButWithDifferentName(), "defaultValue2");
}

3. Nested Objects

You can put objects inside other objects. CodecLib will recursively generate codecs for them.

public class DatabaseConfig {
    public String Host = "localhost";
    public int Port = 3306;
}

public class MainConfig {
    public String PluginName = "MyPlugin";

    // This will be automatically handled!
    public DatabaseConfig Database = new DatabaseConfig();
}

βœ… Supported Types

The library automatically resolves codecs for the following types:

  • String, Boolean, Integer, Double, Long, Float, Byte, Short
  • UUID, Instant
  • String[], int[], double[], long[], float[]
  • Any other Class (via recursion)
  • More are coming, stay tuned

πŸ“‹ Requirements

  • Java 25+
  • Hytale Server API (for BuilderCodec, Codec, etc.)

Information

71
Downloads
Version
codeclib-1.1.0.jar
Updated
Jan 27, 2026
Support
Early Access

Project Links

Help the community thrive by sharing your feedback and reporting issues on the official tracker.

CodecLib - Hytale Mod | Hytale Wiki