CodecLib
A simpler way to use Hytale config codecs
About CodecLib
CodecLib
CodecLib is a lightweight Hytale config library that automates the creation of BuilderCodec 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.
š 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). * 3. Be sure that the custom class you use are annotated with @Configuration as well. */ @Configuration 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.
@Configuration public class DatabaseConfig { public String Host = "localhost"; public int Port = 3306; } @Configuration public class MainConfig { public String PluginName = "MyPlugin";
// This will be automatically handled! public DatabaseConfig Database = new DatabaseConfig(); }
š¦ 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' }
ā 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.)
Categories
Frequently Asked Questions
What is CodecLib?
A simpler way to use Hytale config codecs
How do I download CodecLib?
You can download CodecLib for free from CurseForge. Click the "Download on CurseForge" button on this page to go directly to the download page.
Who created CodecLib?
CodecLib was created by Emibergo02. The mod has been downloaded 12 times.
Is CodecLib compatible with Hytale servers?
CodecLib is designed for Hytale and can be used on both single-player and multiplayer servers. Check the mod page on CurseForge for specific compatibility information.
How do I install CodecLib?
To install CodecLib: 1) Download the mod from CurseForge, 2) Place the file in your Hytale mods folder, 3) Restart the game. The mod should load automatically.
Related Misc Mods
View all modsYmmersive Melodies
Conczin
Upload and play MIDI files in-game on various instruments to annoy your friends with custom melodies!
MultipleHUD
Buuz135
A simple mod that allows you to have multiple HUDs present at once.
Spanish Translation
Plexu5
A Spanish language translation for Hytale. Includes UI, items, and menus.
YUNG's HyDungeons
YUNGNICKYOUNG
Adds new procedurally generated dungeon instances!
Just Enough Tales (JEI mod)
uwudwagon
A JEI mod for Hytale.
[NoCube's] Simple Bags
NoCube
Adds bags that you can put anything in!