Data Sync Lib

Quick rating

Data Sync Lib

No reviews yet

Annotation-driven automatic data sync and persistence framework for Minecraft mod development.

Mod Loaders
Forge
Minecraft

Community voices

Reviews

Versions
Loading versionsโ€ฆ
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

About

Project Details

Type
Mod
Latest Version
datasynclib-forge-1.20.1-26.7.4.jar
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID

Resources

External Links

Source Issues Wiki Discord

About

Description

DataSyncLib

Annotation-driven automatic data sync and persistence framework for Minecraft mod development.


๐Ÿ“– Overview

DataSyncLib is a powerful data synchronization library designed for Minecraft mod developers. It eliminates the boilerplate of manual network packet handling and NBT persistence by using declarative Java annotations.

Simply annotate your fields with @SyncToClient, @SyncToServer, or @SaveToDisk, and DataSyncLib automatically handles:

  • ๐Ÿ” Client-server field synchronization โ€” async-safe, incremental delta sync
  • ๐Ÿ’พ Disk persistence โ€” automatic NBT save/load with change detection
  • ๐Ÿ“ก Network transmission โ€” index-addressed protocol, only changed fields are sent
  • ๐Ÿ”ง Custom codecs โ€” 30+ pre-registered types, extensible via @Codec

โœจ Key Features

Feature Description
๐Ÿ” Bidirectional Sync @SyncToClient and @SyncToServer handle serverโ†”client field sync. Fully async-safe.
๐Ÿ’พ Auto Persistence @SaveToDisk fields are automatically written to and read from NBT.
๐Ÿ“ก Incremental Sync Built-in dirty flag detection โ€” only changed fields are transmitted over the network.
๐Ÿ”ง Extensible Codec System DataSyncCodec registry with 30+ pre-registered types. Register custom codecs via @Codec.
๐Ÿ“ข Change Notification Per-field listener callbacks + NotifiableHolder system for reactive UI updates.
๐Ÿ“ฆ DataComponent System Identity-keyed component data model with DataComponentRegistry + DataComponentMap.
๐Ÿ—‚๏ธ Registry Utility Generic registry with freeze/unfreeze lifecycle and built-in serialization.
โšก High Performance MethodHandle instead of reflection, FastUtil collections, multi-level caching, VarInt encoding.
๐Ÿ—œ๏ธ Compact Data Format Custom 19-type binary Data system, more compact than NBT Tag.
๐Ÿงฉ Ready to Use Extend FieldDataHolderBlockEntity โ€” full capabilities out of the box.
๐Ÿช† Nested Holders @AdditionalHolder recursively discovers annotated fields in nested objects.
๐ŸŽฏ Custom Strategies @Strategy for custom hash/equality change detection on complex types (ItemStack, FluidStack, etc.).

๐Ÿš€ Quick Start

public class MyBlockEntity extends FieldDataHolderBlockEntity {

    @SyncToClient
    @SaveToDisk
    private int energy = 0;

    @SyncToClient(notifyUpdate = true)  // Triggers scheduleUpdate on client
    private String status = "idle";

    @SyncToServer(autoUpdate = false)   // Only synced when explicitly marked
    private int clientConfig = 0;

    public MyBlockEntity(BlockPos pos, BlockState state) {
        super(ModBlockEntities.MY_BLOCK_ENTITY.get(), pos, state);
    }

    public void serverTick(ServerLevel level) {
        energy++;
        setChanged();  // Mark chunk for saving
        DataSyncNetwork.syncBlockEntityToClient(this, false, true);  // Async-safe
    }

    @Override
    public void scheduleUpdate(LogicalSide side) {
        if (side.isClient()) {
            // Re-render or refresh UI on client
        }
    }
}

Nested Holders

public class MachineBlockEntity extends FieldDataHolderBlockEntity {

    @AdditionalHolder  // Scans InventoryData for annotated fields
    private InventoryData inventory = new InventoryData();

    @AdditionalHolder
    private EnergyData energy = new EnergyData();
}

class InventoryData {
    @SaveToDisk @SyncToClient
    private int itemCount;
}

class EnergyData {
    @SaveToDisk @SyncToClient(condition = "shouldSyncEnergy")
    private long storedEnergy;

    private boolean shouldSyncEnergy(long value) {
        return value > 0;  // Skip sync when empty
    }
}

Custom Codec

// 1. Define codec โ€” FieldDataManager auto-discovers @SaveToDisk fields on the POJO
private static final FieldDataCodec<MyConfig> CONFIG_CODEC =
    FieldDataManager.createCodec(MyConfig.class, MyConfig::new);

// 2. Reference on the field
@SaveToDisk @SyncToClient
@Codec(saveCodec = "CONFIG_CODEC", syncCodec = "CONFIG_CODEC")
private MyConfig config = new MyConfig();

Entity Sync

public class MyEntity extends Entity implements IFieldDataHolder {

    private final LazyFieldDataManager fieldDataManager = new LazyFieldDataManager(this);

    @SyncToClient
    private int state = 0;

    @Override
    public FieldDataManager getFieldDataManager() {
        return fieldDataManager.get();
    }

    @Override
    public void tick() {
        if (!level().isClientSide()) {
            state = calculateState();
            DataSyncNetwork.syncEntityToClient(this);
        }
    }
}

๐Ÿ“‹ Annotation Reference

Annotation Purpose Key Attributes
@SyncToClient Serverโ†’Client sync autoUpdate, notifyUpdate, condition, listener
@SyncToServer Clientโ†’Server sync autoUpdate, notifyUpdate, condition, listener
@SaveToDisk Disk persistence key, condition, saveNull, defaultValue, defaultValueGetter
@Access Force access-mode for containers createInstance
@AdditionalHolder Recursively scan nested object fields โ€”
@Codec Custom serialization saveCodec / syncCodec / writeToData / readFromData
@Strategy Custom change detection strategy value (static field name)
@Generic Force generic-type factory resolution โ€”
@AddToManager Add to manager without auto sync/persist โ€”

๐Ÿ“ฆ Installation

Prerequisites

  • Java 21

For Developers

repositories {
    maven {
        url = "https://maven.gtodyssey.com/releases"
    }
}

dependencies {
    implementation fg.deobf("com.gto:datasynclib-forge-1.20.1:26.7.4")
}

๐Ÿ“– Full Documentation

Detailed documentation with architecture diagrams, data flow charts, API reference, and advanced usage guides:


๐Ÿ—๏ธ Architecture

Annotations โ†’ FieldDefinitionStorage โ†’ DataFieldDefinition[]
                                            โ†“
IFieldDataHolder โ†’ LazyFieldDataManager โ†’ FieldDataManager โ†’ DataField[]
                    (DCL lazy init)          (per-instance)     (AbstractField / AbstractFieldAccess)
Component Role
FieldDefinitionStorage Global cache โ€” scans class hierarchy for annotated fields
FieldDataManager Per-instance lifecycle manager โ€” field discovery, change detection, serialization
DataField hierarchy AbstractField (primitive values), ObjField (objects with codecs), AbstractFieldAccess (collections/maps/arrays)
DataSyncCodec Unified codec registry pairing ByteStreamCodec (network) with DataCodec (persistence)
Data type system 19-type sealed binary format, more compact than NBT, with VarInt encoding

๐Ÿ’ก Inspiration

This project draws inspiration from LDLib's syncdata package by Low-Drag-MC, a powerful multi-loader library for Minecraft mod development.


๐Ÿ“„ License

This project is licensed under the GNU LGPL 3.0 โ€” you are free to use, modify, and distribute this library in your own mods.

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Downloads
Last Updated
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works