Class SyncedAutoSaveData<T>

Type Parameters:
T - The type of the data being saved.
All Implemented Interfaces:
Data<T>, SyncedData<T>

@AvailableSince("1.0.0") public final class SyncedAutoSaveData<T> extends AutoSaveData<T> implements SyncedData<T>
A helper class for save data. Automatically saves and loads data. Additionally, this class automatically syncs data to client using the utility class, Synchronisation.
  • Constructor Details

    • SyncedAutoSaveData

      @AvailableSince("1.0.0") public SyncedAutoSaveData(Supplier<@NotNull T> defaultValue, CodecHolder<T> codecHolder, Supplier<File> fileGetter, SaveData.Type type, net.minecraft.util.Identifier id)
      Creates new synced auto save data.
      Parameters:
      defaultValue - A supplier that returns the default value for this savable. Used if there isn't any existing data during loading.
      codecHolder - A codec holder for serializing the save data.
      fileGetter - A supplier that returns the file that the data will be saved to.
      type - What should the data be saved as.
      id - The id of this synced object. Used to find the synced object on the client.
  • Method Details

    • markDirty

      public void markDirty()
      Description copied from class: SaveData
      Tell the savable that it was updated. Failing to call this method after an update will result in the data not getting saved.
      Overrides:
      markDirty in class AutoSaveData<T>
    • getSyncedData

      public T getSyncedData()
      Description copied from interface: SyncedData
      Get the data synced over from the server.
      Specified by:
      getSyncedData in interface SyncedData<T>
      Returns:
      The synced data.
    • setSyncedData

      public void setSyncedData(T syncedData)
      Description copied from interface: SyncedData
      Set the data synced from the server. Please don't use this, it should only be called by CoreLib during data synchronisation.
      Specified by:
      setSyncedData in interface SyncedData<T>
      Parameters:
      syncedData - The new data
    • getSyncId

      public net.minecraft.util.Identifier getSyncId()
      Description copied from interface: SyncedData
      Used to get the id of this object.
      Specified by:
      getSyncId in interface SyncedData<T>
      Returns:
      The object's id.