Create a Custom Data Type with Data Managers
Understanding Data Managers
Data Managers are the core tool for defining new data types in your datapack. They handle automatic serialization, reload detection, and synchronization between server and client without requiring you to write networking code.
Setting Up Your Data Manager
1. Create a new data manager class in your datapack's code structure
2. Define the fields that will store your custom data (these become the properties players can configure)
3. Specify how data should be loaded from JSON files in your datapack directory
4. Register your Data Manager so the mod recognizes it during datapack load
Enabling Automatic Features
Once registered, your Data Manager automatically:
- Detects when datapacks are reloaded (via
/reloadcommand) - Broadcasts updated data from server to all connected clients
- Handles JSON parsing and validation
- Manages data persistence across game sessions
This means you can modify your datapack's JSON files, reload, and see changes instantly without restarting the server or writing custom packet handlers.