Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Stationapi Wiki › Guides › Save and Load Custom Mod Data to World Files

Save and Load Custom Mod Data to World Files

Understanding StationAPI's Save Format

StationAPI provides an updated world save format that safely stores extra mod data alongside vanilla world data. This prevents data loss when worlds are loaded by different mod configurations.

Your mod data is stored in a separate section within the world save, isolated from vanilla chunks and player data. This means your custom information persists across game sessions without corrupting the world.

Writing and Reading Custom Data

During world save events, serialize your mod's state (block data, entity properties, or global counters) into a data structure. StationAPI handles writing this to disk automatically.

When the world loads, listen for the world load event and deserialize your saved data back into memory. Reconstruct any custom objects or state from the stored information.

Test by saving a world with custom mod data, closing the game, reopening it, and verifying your data is intact. Try loading the world in different mod configurations to confirm data persists safely without causing errors.