Wiki 9Minecraft Wiki 9Minecraft

Sync Custom Data Between Client and Server

Java EditionModGuides 4FAQ 20Related mods 60
DownloadLibrarianlib

Get the files on 9Minecraft

Contents (4)
  1. Automatic Field Synchronization
  2. Marking Fields for Sync
  3. Important Setup
  4. Verification

Automatic Field Synchronization

LibrarianLib can automatically send tile entity and packet data across the network without manual packet handling.

Marking Fields for Sync

1. Add the @Save annotation to any field in your tile entity or packet class that needs to sync

2. Supported types include primitives, strings, and complex objects—the library handles serialization automatically

3. For tile entities, the mod will sync marked fields whenever they change, updating all clients watching that chunk

4. For packets, marked fields are automatically serialized when the packet is sent and deserialized when received

Important Setup

Ensure your mod's setup phase properly registers your tile entity or packet class with LibrarianLib. Some versions require explicit registration calls during mod initialization.

Verification

Change a @Save field on the server side and verify the change appears on all connected clients without writing network code. If sync doesn't work, check that your class is properly registered and that the field type is serializable.