-
Notifications
You must be signed in to change notification settings - Fork 56
World Data
Saved data attached to a world, synced to clients, without the vanilla boilerplate.
Vanilla's SavedData is server only and you write the codec plumbing and the sync packet yourself.
WorldSavedData handles both: register a type, call sync(), and clients get it.
public static final WorldSavedDataType<MyData> MY_DATA = RegHelper.registerWorldSavedData(
MyMod.res("my_data"), MyData::new, MyData.CODEC);public class MyData extends WorldSavedData {
private int counter;
public void increment() {
counter++;
setDirty(true);
sync(); // pushes to clients
}
@Override
public WorldSavedDataType<? extends WorldSavedData> getType() {
return MY_DATA;
}
}For data attached to an entity, block entity or chunk rather than the world, use data attachments instead.
ModSharedVariables is a tiny cross mod bulletin board: register a named supplier and any other mod
can read it without a compile time dependency.
// in your mod
ModSharedVariables.registerBool("mymod:feature_enabled", () -> CONFIG_VALUE.get());
// in another mod, no dependency needed
Boolean enabled = ModSharedVariables.getBool("mymod:feature_enabled");Strings, doubles, booleans and functions. Meant for small integration points where a full API is overkill.
Basics Platform Helpers Registration Networking Events Configs Config Screen
Resources Runtime Resource Packs Texture Manipulation Resource Helpers Block Set API
Client Custom Models Item Rendering Rendered Textures Post Shaders GUI Toolkit Colors
World Block and Item Interfaces Additional Item Placements Improved Entities Fake Levels World Data Dispenser Behaviors
Utilities Codec Utilities Misc Helpers Commands
Datapacks Villagers Soft Fluids Map Markers Spawn Boxes Global Datapack Folder