Reference: Network Sync
Library of Exile has a built-in sync mechanism for registry data. It is automatic for all
ON_LOGIN types and requires no code from dependent mods.
SyncTime
public enum SyncTime {
ON_LOGIN, // Data is sent to the client when the player logs in or /reload fires
NEVER // Data stays on the server only
}
How ON_LOGIN sync works
-
After each datapack reload —
ExileRegistryContainer.onAllDatapacksLoaded()serializes all entries from that container to bytes and caches the result incachedBuf. This step happens once regardless of how many players are online. -
On player login or
/reload—OnDatapackSyncEventfires (Forge).CommonInitresponds by callingDatabase.sendPacketsToClient(player, SyncTime.ON_LOGIN)for everyON_LOGINtype. The pre-cached bytes are sent as anEfficientRegistryPacketfor each type. -
On the client —
RegistryPacketsreceives each packet, deserializes the JSON entries, and re-registers them viaClientSyncRegistration.INSTANCE. This re-populates the client'sDatabasewith the same data the server has.
Performance note: The serialization-to-bytes step runs once per reload, not once per login. This keeps login fast on servers with many connected players.
What is synced
All entries that came from datapacks (i.e. isFromDatapack() == true) are included in the sync
packet. Hardcoded entries (registered in Java) are not synced — clients are expected to
register those via their own FMLCommonSetupEvent flow.
This means: if you add a hardcoded entry to a ON_LOGIN type, it must be registered in the
dependent mod's client-side code too, or the client's Database will be missing it.
ON_LOGIN types (built-in)
| Type | Why synced |
|---|---|
MOB_AFFIX |
Clients display affix names on mob tooltips |
MAP_FINISH_RARITY |
Clients display map reward tiers |
MAP_CONTENT |
Clients show map content possibilities in UI |
RELIC_STAT |
Clients render relic stat values on items |
RELIC_TYPE |
Clients display relic type names |
RELIC_AFFIX |
Clients show affix descriptions on relics |
RELIC_RARITY |
Clients display rarity colors/names |
ITEM_MOD |
Client item modification display |
ITEM_REQ |
Client item requirement display |
CURRENCY |
Currency display in client UI |
ORB_EDIT |
Orbs of Crafting mod: client display |
NEVER types (built-in)
| Type | Why server-only |
|---|---|
MAP_DATA_BLOCK |
Map generation is purely server-side |
MOB_LIST |
Mob spawning is purely server-side |
LEAGUE |
League evaluation is server-side |
Registering your own ON_LOGIN type
When you register a new ExileRegistryType with SyncTime.ON_LOGIN, the sync mechanism picks
it up automatically for JSON entries. No extra registration is needed.
Your content class must implement IAutoGson<T> so the serialization layer knows how to write
and read it.
Client-side access
On the client, Database.getRegistry(type) works the same way as on the server. After
ON_LOGIN packets are applied, the client's Database contains all synced entries.
The client never receives NEVER entries. Calling Database.get(LibDatabase.MOB_LIST, ...) on
a client will return the default empty entry.