Static Data
The Static Data mod introduces a new type of resource to Minecraft - static data, which allows mods to easily and structuredly exchange information about compatibility and interaction with each other and the game environment.
Main Advantages of Static Data
Data Immutability
Static data remains constant throughout the entire lifecycle of a mod - they are not affected by datapack and resource pack reloads. This guarantees stability and predictability for your modifications.
Early Availability
Data becomes available immediately after the first entrypoint runs in the loader, regardless of which specific mod or library initializes first.
Registration Management Capability
Since static data doesn't change and is available before registries are frozen, it can be used to register blocks and entities based on information obtained from other mods.
How to Provide Static Data
For Mod Developers
Static data is placed in the staticdata directory alongside the assets and data folders. For example, if the "architecture_extensions" mod is looking for files in the "blockgroups" path, the full file path would look like this:
src/main/resources/staticdata/architecture_extensions/blockgroups/obsidian.json
For Datapack Creators
Create zip archives with a root folder named "staticdata". Inside the archive, files should be located along a similar path:
/staticdata/architecture_extensions/blockgroups/obsidian.json
Static datapacks can be placed in two locations:
- inside mods in the
src/main/resources/staticdata/folder - in the root directory
.minecraft/staticdata/
Usage in Your Mod
To work with Static Data, add a dependency to your project:
// Use quilt-json5 or jankson for parsing
Gson gson = new GsonBuilder().create();
// Get all static data in the specified directory
List<StaticDataItem> dataItems = StaticData.getDataInDirectory(
new Identifier(MODID, "bees"), // Search for mymod:bees
true // Recursive search through subfolders
);
for(StaticDataItem dataItem : dataItems) {
MyDataObject dataObject = gson.fromJson(item.getAsString(), MyDataObject.class);
// Conditional data loading
String requiredMod = dataObject.only_if_present;
if (requiredMod != null && !requiredMod.isBlank()) {
if (!QuiltLoader.isModLoaded(requiredMod)) continue;
}
// Using the obtained data
doSomethingWithTheData(dataObject);
}
Example class for storing data:
public class MyDataObject {
public String only_if_present;
// other public fields for data
}
Usage in Modpacks
Static Data is typically embedded within other mods and provides seamless interaction between them without additional configuration. To extend functionality, create your own static datapacks and include them in your modpack.