Klasse GameData

java.lang.Object
de.luckymcdev.foundryengine.common.game.GameData

public class GameData extends Object
Persistable data container identified by an Identifier, backed by NBT compounds.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    GameData(net.minecraft.resources.Identifier identifier)
     
  • Methodenübersicht

    Modifikator und Typ
    Methode
    Beschreibung
    net.minecraft.nbt.CompoundTag
    Returns the underlying NBT compound data.
    boolean
    Gets a boolean value from the data.
    double
    Gets a double value from the data.
    int
    Gets an integer value from the data.
    @Nullable String
    Gets a string value from the data, or null if absent.
    net.minecraft.resources.Identifier
    Returns the identifier for this game data.
    boolean
    Returns true if this data has been initialized at least once.
    final void
    loadFrom(Path directory)
    Loads the game data from a compressed NBT file in the given directory.
    onInit(Runnable handler)
    Registers a callback that fires once when the data is first loaded from disk.
    protected void
    onLoad(net.minecraft.nbt.CompoundTag tag)
     
    protected void
    onSave(net.minecraft.nbt.CompoundTag tag)
     
    void
    putBoolean(String key, boolean value)
    Puts a boolean value into the data.
    void
    putDouble(String key, double value)
    Puts a double value into the data.
    void
    putInt(String key, int value)
    Puts an integer value into the data.
    void
    putString(String key, String value)
    Puts a string value into the data.
    final void
    saveTo(Path directory)
    Saves the game data to a compressed NBT file in the given directory.
    void
    setInitialized(boolean initialized)
    Sets the initialization flag for this data.

    Von Klasse geerbte Methoden Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • GameData

      public GameData(net.minecraft.resources.Identifier identifier)
  • Methodendetails

    • identifier

      public net.minecraft.resources.Identifier identifier()
      Returns the identifier for this game data.
    • data

      public net.minecraft.nbt.CompoundTag data()
      Returns the underlying NBT compound data. The returned tag is shared via GameManager's persistent store and survives bundle reloads — modifications are visible to all sessions with the same ID.

      Threading contract: a session can be ticked from both the client and the server thread in the same process (integrated server), so the shared tag may be accessed concurrently. Every read/write that goes through the accessors is guarded by synchronizing on the tag itself. If the returned tag is mutated directly, the caller must synchronize on that tag object as well to avoid races.

    • isInitialized

      public boolean isInitialized()
      Returns true if this data has been initialized at least once.
    • setInitialized

      public void setInitialized(boolean initialized)
      Sets the initialization flag for this data.
    • onInit

      public GameData onInit(Runnable handler)
      Registers a callback that fires once when the data is first loaded from disk.
    • getBoolean

      public boolean getBoolean(String key)
      Gets a boolean value from the data.
    • putBoolean

      public void putBoolean(String key, boolean value)
      Puts a boolean value into the data.
    • getDouble

      public double getDouble(String key)
      Gets a double value from the data.
    • putDouble

      public void putDouble(String key, double value)
      Puts a double value into the data.
    • getInt

      public int getInt(String key)
      Gets an integer value from the data.
    • putInt

      public void putInt(String key, int value)
      Puts an integer value into the data.
    • getString

      public @Nullable String getString(String key)
      Gets a string value from the data, or null if absent.
    • putString

      public void putString(String key, String value)
      Puts a string value into the data.
    • onSave

      protected void onSave(net.minecraft.nbt.CompoundTag tag)
    • onLoad

      protected void onLoad(net.minecraft.nbt.CompoundTag tag)
    • saveTo

      public final void saveTo(Path directory)
      Saves the game data to a compressed NBT file in the given directory.
    • loadFrom

      public final void loadFrom(Path directory)
      Loads the game data from a compressed NBT file in the given directory.