Sync GUI Values Between Server and Client
Understanding ModularUI Synchronization
ModularUI automatically handles server-client synchronization for GUIs attached to TileEntities. You don't need to write custom packets—the mod manages data transfer behind the scenes.
When you bind a GUI widget to a TileEntity value, ModularUI tracks changes and sends updates to connected clients. This works for numeric values, booleans, and other serializable data types.
Setting Up Value Binding
In your GUI class, use the mod's binding methods to connect widgets to your TileEntity's fields. Specify which values should be synchronized and how they should be displayed or modified.
For widgets that allow player input (like text fields or increment buttons), ModularUI automatically sends the new value back to the server and updates the TileEntity. This two-way synchronization ensures consistency across all players viewing the interface, preventing desync issues that plague custom GUIs.