Skip to content

World Data

MehVahdJukaar edited this page Jul 25, 2026 · 1 revision

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.

Getting Started

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.

Shared variables

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.

Clone this wiki locally